Skip to content

Commit

Permalink
Add builder, testing and production images
Browse files Browse the repository at this point in the history
  • Loading branch information
RealVishy authored Oct 27, 2024
1 parent 54a9f05 commit 109e3d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hello-docker/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM rust:latest AS builder
WORKDIR /usr/src/myapp
COPY . .
RUN cargo build --release
CMD ["/usr/src/myapp/target/release/hello-docker"]
18 changes: 18 additions & 0 deletions hello-docker/Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# First stage: Build the Rust project
FROM rust:latest AS builder

# Install musl-tools for static linking
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /usr/src/myapp
COPY . .

# Build the binary
RUN cargo build --release --target x86_64-unknown-linux-musl

# Second stage: Create a minimal image using scratch
FROM scratch
# Copy the statically linked binary from the builder stage
COPY --from=builder /usr/src/myapp/target/x86_64-unknown-linux-musl/release/hello-docker /hello-docker

# Run the binary
CMD ["/hello-docker"]
File renamed without changes.

0 comments on commit 109e3d6

Please sign in to comment.