-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add builder, testing and production images
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.