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

The api image weighs too much #1

Open
0xBLCKLPTN opened this issue May 12, 2023 · 0 comments
Open

The api image weighs too much #1

0xBLCKLPTN opened this issue May 12, 2023 · 0 comments

Comments

@0xBLCKLPTN
Copy link
Owner

This can be fixed by slightly optimizing the Dockerfile

FROM rust:1.67 as build

# create a new empty shell project
RUN USER=root cargo new --bin api
WORKDIR /api

# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

# this build step will cache your dependencies
RUN cargo build --release
RUN rm src/*.rs

# copy your source tree
COPY ./src ./src

# build for release
RUN rm ./target/release/deps/holodeck*
RUN cargo build --release

# our final base
FROM rust:1.67

# copy the build artifact from the build stage
COPY --from=build /api/target/release/api .

# set the startup command to run your binary
CMD ["./api"]
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

1 participant