Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A multi-stage example #5

Closed
uint opened this issue Sep 14, 2019 · 2 comments
Closed

A multi-stage example #5

uint opened this issue Sep 14, 2019 · 2 comments

Comments

@uint
Copy link

uint commented Sep 14, 2019

Hi!

Docker features multi-stage builds nowadays: https://docs.docker.com/develop/develop-images/multistage-build/

This pretty much lets you create a temporary build image, then copy an artifact from the build image over to your actual target image, all in one Dockerfile. Have you considered that approach? I got the same size from that, but I feel the Dockerfile is "cleaner".

tom@tomian:~/code/mini-docker-rust$ docker image ls
REPOSITORY              TAG                 IMAGE ID            CREATED              SIZE
mdrr                    latest              6dbc2cd0676e        11 seconds ago       7.52MB
mdr                     latest              0f65f756e698        9 minutes ago        7.52MB
<snip>
@uint
Copy link
Author

uint commented Sep 14, 2019

Oh, and here's my Dockerfile for reference. I'm happy to create a PR.

FROM alpine:latest AS builder
COPY ./ /app
WORKDIR /app
RUN apk add --no-cache rust cargo \
    && cargo build --release

FROM alpine:latest
WORKDIR /
COPY --from=builder /app/target/release/mini-docker-rust .
RUN apk add --no-cache libgcc
ENTRYPOINT ["/mini-docker-rust"]

@kpcyrd
Copy link
Owner

kpcyrd commented Sep 15, 2019

I've updated it to a multi-stage build that is based on the rust:alpine image that became available recently. Thanks!

@kpcyrd kpcyrd closed this as completed Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants