-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.localdev
43 lines (34 loc) · 1.53 KB
/
Dockerfile.localdev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
##
# This Dockerfile is used to build the uptime-checker binary for local development.
# It is not used for production. We need this because certain error messages
# are Linux specific so we have to run the binary on Linux to get the correct
# error messages.
# HOW TO USE:
# 1. Build the binary: `docker build -f Dockerfile.localdev -t my-uptime-checker`
# 2. Run the container with a mounted volume for src: `docker run -it -v $(pwd)/src:/app/src --entrypoint /bin/sh my-uptime-checker`
# e. in the container you can do `cargo test`, etc. and updating the src directory on your host will reflect in the container,
# so you can test your changes without having to rebuild the container.
##
FROM rust:1.80-alpine3.20 as builder
ARG UPTIME_CHECKER_GIT_REVISION
ENV UPTIME_CHECKER_GIT_REVISION=$UPTIME_CHECKER_GIT_REVISION
ENV UPTIME_CHECKER_VERSION=0.0.1
RUN mkdir -p ~/.cargo && \
echo '[registries.crates-io]' > ~/.cargo/config && \
echo 'protocol = "sparse"' >> ~/.cargo/config
RUN apk add --no-cache libc-dev cmake make g++
RUN apk add --no-cache pkgconfig openssl-dev
RUN cargo new --bin /app
WORKDIR /app
# Mount src directory as a volume instead of copying
RUN mkdir -p /app/src
VOLUME /app/src
COPY src /app/src
# Just copy the Cargo.toml files and trigger a build so that we compile our
# dependencies only. This way we avoid layer cache invalidation if our
# dependencies haven't changed, resulting in faster builds.
COPY Cargo.toml .
COPY Cargo.lock .
ENV RUSTFLAGS="-Ctarget-feature=-crt-static"
ENV PKG_CONFIG_ALLOW_CROSS=1
RUN cargo build