forked from sorokya/reoserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (32 loc) · 1.19 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
# Builder
FROM rust:1.82.0-bookworm as builder
WORKDIR /usr/src
# Create blank project
RUN USER=root cargo new reoserv
# We want dependencies cached, so copy those first.
COPY Cargo.toml Cargo.lock /usr/src/reoserv/
# Set the working directory
WORKDIR /usr/src/reoserv
# Install target platform (Cross-Compilation) --> Needed for Alpine
RUN apt update && apt install -y musl-tools musl-dev && \
update-ca-certificates && \
rustup target add x86_64-unknown-linux-musl && \
rustup component add rustfmt
# Copy cargo config
COPY .cargo /usr/src/reoserv/.cargo/
# This is a dummy build to get the dependencies cached.
RUN cargo build --target x86_64-unknown-linux-musl --release
# Now copy in the rest of the sources
COPY src /usr/src/reoserv/src/
# Touch main.rs to prevent cached release build
RUN touch /usr/src/reoserv/src/main.rs
# This is the actual application build.
RUN cargo build --target x86_64-unknown-linux-musl --release
# Runtime
FROM alpine:3.18.4 as runtime
# Copy application binary from builder image
COPY --from=builder /usr/src/reoserv/target/x86_64-unknown-linux-musl/release/reoserv /usr/bin/
EXPOSE 8078
WORKDIR /reoserv
# Run the application
CMD ["/usr/bin/reoserv"]