-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (38 loc) · 1.48 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
52
53
54
FROM docker.io/rust:1-slim-bookworm AS build
## cargo package name: customize here or provide via --build-arg
ARG pkg=rocket-app
WORKDIR /build
COPY . .
# RUN cp ./MyRootCA.crt /usr/local/share/ca-certificates/
# RUN update-ca-certificates
RUN apt-get update -y
RUN apt-get install -y pkg-config libssl-dev
RUN --mount=type=cache,target=/build/target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
set -eux; \
cargo build --release; \
objcopy --compress-debug-sections target/release/$pkg ./main
################################################################################
FROM docker.io/debian:bookworm-slim
WORKDIR /app
RUN apt-get update -y
RUN apt-get install -y pkg-config libssl-dev
RUN apt-get install -y ca-certificates
## copy the main binary
COPY --from=build /build/main ./
## copy runtime assets which may or may not exist
COPY --from=build /build/json/ ./json
COPY --from=build /build/src/public/ ./src/public
## COPY --from=build /build/Rocket.tom[l] ./static
## COPY --from=build /build/stati[c] ./static
## COPY --from=build /build/template[s] ./templates
# Define an argument for the OpenWeatherMap API key
ARG OPENWEATHER_API_KEY
# Set it as an environment variable inside the container
ENV OPENWEATHER_API_KEY=${OPENWEATHER_API_KEY}
## ensure the container listens globally on port 8080
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8080
RUN echo OPENWEATHER_API_KEY $OPENWEATHER_API_KEY
CMD ./main