Skip to content

Commit

Permalink
added dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
benzlokzik committed Nov 6, 2023
1 parent 905d695 commit 184b590
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# official Rust image as a builder
FROM rust:1.70 as builder

# new empty project
RUN USER=root cargo new --bin app
WORKDIR /app

# copy my manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

# build only the dependencies to cache them
RUN cargo build --release
RUN rm src/*.rs

# copy the source code
COPY ./src ./src

# remove the dummy target
RUN rm ./target/release/deps/fahrenheit_celsius_kelvin_converter*

# set the build to be statically linked
RUN RUSTFLAGS='-C target-feature=+crt-static'

# build for release
RUN cargo build --release

# final base image, use the same Debian version as the builder
FROM debian:bullseye-slim

# copy the build artifact from the build stage
COPY --from=builder /app/target/release/fahrenheit_celsius_kelvin_converter .

# set the startup command to run binary
CMD ["./fahrenheit_celsius_kelvin_converter"]

0 comments on commit 184b590

Please sign in to comment.