Last active
January 19, 2023 11:09
-
-
Save ArinFaraj/9380f62155f463c02a651f60f888390d to your computer and use it in GitHub Desktop.
Good enough rust + actix web dockerfile [replace the APP_NAME]
This file contains hidden or 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
| target | |
| Dockerfile | |
| .dockerignore | |
| .git | |
| .gitignore | |
| .env |
This file contains hidden or 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
| FROM rust:1.66.1 as builder | |
| WORKDIR /usr/src | |
| RUN USER=root cargo new docker-app | |
| COPY Cargo.toml Cargo.lock /usr/src/docker-app/ | |
| WORKDIR /usr/src/docker-app | |
| RUN cargo build --release | |
| # Now copy in the rest of the sources | |
| COPY src /usr/src/docker-app/src/ | |
| ## Touch main.rs to prevent cached release build | |
| RUN touch /usr/src/docker-app/src/main.rs | |
| # This is the actual application build. | |
| RUN cargo build --release | |
| FROM gcr.io/distroless/cc-debian11 | |
| # Copy application binary from builder image | |
| COPY --from=builder /usr/src/docker-app/target/release/[APP_NAME] /usr/local/bin/ | |
| COPY .env.example /usr/local/bin/.env | |
| EXPOSE 3030 | |
| # Run the application | |
| CMD ["/usr/local/bin/[APP_NAME]"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment