-
Couldn't load subscription status.
- Fork 55
chore: parametize debian codename #78
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,43 @@ | ||||||||||
| # Use the official Python image as the base image | ||||||||||
| FROM python:3.9 | ||||||||||
| # Define an argument for the Debian version with a default value | ||||||||||
| # This allows you to build for a specific version, e.g., bullseye, bookworm, or trixie | ||||||||||
| ARG DEBIAN_VERSION=bookworm | ||||||||||
|
|
||||||||||
| # Set the working directory within the container | ||||||||||
| # Use the argument in the FROM instruction | ||||||||||
| FROM python:3.9-slim-${DEBIAN_VERSION} | ||||||||||
|
|
||||||||||
| # --- DNS/NSS fix (bullseye-slim often lacks these) --- | ||||||||||
| RUN set -eux; \ | ||||||||||
| apt-get update; \ | ||||||||||
| apt-get install -y --no-install-recommends \ | ||||||||||
| libnss-dns libnss-files netbase ca-certificates && \ | ||||||||||
| rm -rf /var/lib/apt/lists/*; \ | ||||||||||
| # Ensure glibc actually consults DNS | ||||||||||
| if ! grep -q '^hosts:.*\bdns\b' /etc/nsswitch.conf 2>/dev/null; then \ | ||||||||||
| echo 'hosts: files dns' > /etc/nsswitch.conf; \ | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Set the working directory | ||||||||||
| WORKDIR /app | ||||||||||
|
|
||||||||||
| # Copy the application code into the container | ||||||||||
| # Create a non-root user to run the application | ||||||||||
| RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser | ||||||||||
|
|
||||||||||
| # Copy the requirements file and install dependencies | ||||||||||
| # This is done first to leverage Docker's layer caching | ||||||||||
|
||||||||||
| # This is done first to leverage Docker's layer caching | |
| # This is done first to leverage Docker's layer caching | |
| # NOTE: requirements.txt must exist in the build context (the directory you run `docker build` from). | |
| # If it is missing, the build will fail at this step. |
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.
[nitpick] Consider using a more stable default like 'bullseye' instead of 'bookworm'. The 'bookworm' codename refers to Debian 12 which is relatively new, and using 'bullseye' (Debian 11) as default would provide better stability for production environments.