-
Notifications
You must be signed in to change notification settings - Fork 19
Generate Dockerfile #219
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
Draft
oliverbarnes
wants to merge
8
commits into
mainmatter:main
Choose a base branch
from
oliverbarnes:generate-dockerfile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Generate Dockerfile #219
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
846760c
Copy over Pavex starter Dockerfile
oliverbarnes c003ca2
Remove --package arg in cargo build
oliverbarnes c2117bc
Fix the Dockerfile and make it a template
oliverbarnes 28b9fbc
Update README with Dockerfile info
oliverbarnes 950f39c
SQLX_OFFLINE=true
oliverbarnes c8b6765
Fix release ownership
oliverbarnes 343c23e
Remove user permissions
oliverbarnes d37d4db
Rename final binary
oliverbarnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # `cargo-chef` is a cargo-subcommand that provides | ||
| # enhanced Docker layer caching for Rust projects. | ||
| FROM lukemathwalker/cargo-chef:latest AS chef | ||
| WORKDIR /app | ||
| # Force `rustup` to sync the toolchain in the base `chef` layer | ||
| # so that it doesn't happen more than once | ||
| COPY rust-toolchain.toml . | ||
| RUN rustup toolchain install | ||
|
|
||
| FROM chef AS planner | ||
| COPY . . | ||
| # Compute a lock-like file for our project | ||
| RUN cargo chef prepare --recipe-path recipe.json | ||
|
|
||
| FROM chef AS builder | ||
| COPY --from=planner /app/recipe.json recipe.json | ||
| # Build our project's dependencies, not our application! | ||
| # this is the caching Docker layer. | ||
| RUN cargo chef cook --release --recipe-path recipe.json | ||
| COPY . . | ||
| # Build our project | ||
| ENV SQLX_OFFLINE=true | ||
| RUN cargo build --release --bin {{project-name}}-web | ||
|
|
||
| FROM debian:bookworm-slim AS runtime | ||
|
|
||
| RUN adduser \ | ||
| --disabled-password \ | ||
| --gecos "" \ | ||
| --home "/nonexistent" \ | ||
| --shell "/sbin/nologin" \ | ||
| --no-create-home \ | ||
| --uid 10001 \ | ||
| "{{project-name}}" | ||
|
|
||
| USER {{project-name}}:{{project-name}} | ||
|
|
||
| COPY --from=builder --chown={{project-name}}:{{project-name}} /app/target/release/{{project-name}}-web bin | ||
|
|
||
| # Enable backtraces to simplify debugging | ||
| # production panics. | ||
| ENV RUST_BACKTRACE=1 | ||
| # We don't want `anyhow` to capture backtraces for | ||
| # "routine" errors. Just panics. | ||
| ENV RUST_LIB_BACKTRACE=0 | ||
|
|
||
| ENV APP_ENVIRONMENT=production | ||
| ENV APP_SERVER__PORT=3000 | ||
| ENV APP_SERVER__IP="0.0.0.0" | ||
| ENTRYPOINT ["./bin"] | ||
| EXPOSE 3000 | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # If you're making changes here. | ||
| # Change the Dockerfile to also use a matching version. | ||
| [toolchain] | ||
| channel = "1.85" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ENVs ideally aren't defined here.
APP_SERVERones especiialy, they should be set by theconfigcrate directlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we actually have an open issue for that on restations too. Do you feel it's a must for this PR, or can it be done in a separate one?