-
Notifications
You must be signed in to change notification settings - Fork 30
Refactor Dockerfile #712
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
Open
crosspolar
wants to merge
63
commits into
master
Choose a base branch
from
dockerfile_without_poetry_dev_dependencies
base: master
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.
Open
Refactor Dockerfile #712
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
62ad5f8
build: Create dockerfile without
crosspolar 1b5f41b
move drf-spectacular and icecream to prod
crosspolar 3509e63
add dockerfile for prod
crosspolar d5bf3b8
Revert "build: Create dockerfile without"
crosspolar 590468e
remove poetry and initiate first-attempt of multi-stage and add user...
crosspolar 8b3d1c1
linux reduce installed packages
crosspolar a14ec3c
comments
crosspolar 5548afd
use python-slim with weasyprint-dependencies
crosspolar cef345a
set DEV in Dockerfile to decide whether to install dev-dependencies o…
crosspolar 629e4f0
install poetry the curl-way (more recommended)
crosspolar 16b6f71
remove unneeded COPY
crosspolar 8f1735d
smaller apt-get in second layer
crosspolar 6e36394
remove \
crosspolar 3a823cb
remove obsolete prod reference
crosspolar c64a61e
compilemessages in dockerfile
crosspolar 33b7099
Merge branch 'master' into dockerfile_without_poetry_dev_dependencies
crosspolar 01fd77f
poetry lock
crosspolar 97dc198
use uid 1000
crosspolar ca31ccb
have git installed in container
crosspolar 47184be
update translation
crosspolar 17716db
fix: reintroduce cd
crosspolar 4af8d73
test if adding user 1000 to compose-run helps
crosspolar 7c7f53d
temp add ls -la
crosspolar 70bab2b
temp add ls -la 2
crosspolar 23c804d
$(id -u):$(id -g)
crosspolar 8312b7a
fix $(id -u):$(id -g)
crosspolar 5faddcf
add $(id -u):$(id -g) to test
crosspolar f771e9c
add $(id -u):$(id -g) to to documentation
crosspolar a9d7a20
Make sure no write permissions are assigned to the copied resource.
crosspolar ab98ef8
username nonroot
crosspolar b4e167b
Revert "Make sure no write permissions are assigned to the copied res…
crosspolar 393cd13
username nonroot
crosspolar 1e3e0ac
copy only specific files, loose general writing-permission and hence …
crosspolar 44fb9de
create volume only here to get coverage.xml
crosspolar 7526e13
chown app before writing
crosspolar facc760
use env, if available
crosspolar ebcd700
Merge branch 'master' into dockerfile_without_poetry_dev_dependencies
crosspolar 245c7d7
poetry lock: only changed content hash
crosspolar bd48180
remove auto-purge (same as removing lists it seems)
crosspolar ee3c379
give nonroot-user full permission of app-directory, otherwise thos jo…
crosspolar eee1c6f
remove comment
crosspolar d509691
remove chown -R $USERNAME:$USERNAME /app
crosspolar 075358b
use tempfile-package
crosspolar d097d31
mock tempfile
crosspolar 684744d
add prexix -
crosspolar bbead6b
Merge branch 'master' into dockerfile_without_poetry_dev_dependencies
crosspolar d9171ed
omit -L when installing poetry
crosspolar ce7efda
merge tests
crosspolar 7be9980
remove unlink
crosspolar e7fd7d5
remove tmp
crosspolar a88b14f
make sure members-current is written to correct target file
crosspolar 9f9f62b
remove unused EXPORT_FILE
crosspolar 0d214f7
use tempfile.TemporaryFile
crosspolar 3389b9f
Update django.Dockerfile
crosspolar afcf5e2
Merge branch 'master' into dockerfile_without_poetry_dev_dependencies
crosspolar dd04093
poetry lock
crosspolar 0ca6877
use TapirUserFactory.create()
crosspolar a26ee07
fix: duplicated args in compose
crosspolar 76a6dea
remove --user=$(id -u):$(id -g)
crosspolar 30cf98f
you need to export GID AND UID
crosspolar a23c0d6
you need to export GID AND UID to checks.yml too
crosspolar a24d3e5
set default in compose not in dockerfile
crosspolar 9426724
set USER_UID and USER_GID
crosspolar 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
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
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 |
|---|---|---|
| @@ -1,17 +1,18 @@ | ||
| lint: | ||
| poetry run black . | ||
| black . | ||
|
|
||
| check-formatting: | ||
| poetry run black --check . | ||
| black --check . | ||
|
|
||
| test: | ||
| poetry run pytest --cov-report xml:coverage.xml --cov=tapir --cov-config=pyproject.toml | ||
| pytest --cov-report xml:coverage.xml --cov=tapir --cov-config=pyproject.toml | ||
|
|
||
| check-translations: | ||
| ls -la /app | ||
| cp tapir/translations/locale/de/LC_MESSAGES/django.po tapir/translations/locale/de/LC_MESSAGES/django-old.po | ||
| cd tapir && poetry run python ../manage.py makemessages --no-wrap -l de | ||
| cd tapir && python ../manage.py makemessages --no-wrap -l de | ||
| git diff --ignore-matching-lines=POT-Creation-Date --exit-code --no-index tapir/translations/locale/de/LC_MESSAGES/django.po tapir/translations/locale/de/LC_MESSAGES/django-old.po | ||
| rm tapir/translations/locale/de/LC_MESSAGES/django-old.po | ||
|
|
||
| check-migrations: | ||
| poetry run python manage.py makemigrations --check | ||
| python manage.py makemigrations --check |
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 |
|---|---|---|
| @@ -1,18 +1,84 @@ | ||
| FROM python:3.13 | ||
| ENV PYTHONUNBUFFERED=1 | ||
| # syntax=docker/dockerfile:1 | ||
| ARG USER_UID | ||
| ARG USER_GID | ||
|
|
||
|
|
||
| FROM python:3.13-slim AS build | ||
| ARG DEV=false | ||
| ENV POETRY_VERSION=2.2.1 \ | ||
| PYTHONUNBUFFERED=1 \ | ||
| # prevents python creating .pyc files | ||
| PYTHONDONTWRITEBYTECODE=1 \ | ||
| PIP_NO_CACHE_DIR=off \ | ||
| PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
| PIP_DEFAULT_TIMEOUT=100 \ | ||
| # make poetry install to this location | ||
| POETRY_HOME="/opt/poetry" \ | ||
| # make poetry create the virtual environment in the project's root | ||
| # it gets named `.venv` | ||
| POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
| # do not ask any interactive question | ||
| POETRY_NO_INTERACTION=1 \ | ||
| # this is where our requirements + virtual environment will live | ||
| PYSETUP_PATH="/opt/pysetup" \ | ||
| VENV_PATH="/opt/pysetup/.venv" | ||
|
|
||
| ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
|
||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install --no-install-recommends -y \ | ||
| build-essential curl \ | ||
| # psycopg2 dependencies | ||
| libpq-dev \ | ||
| # Translations dependencies | ||
| gettext \ | ||
| # LDAP dependencies | ||
| libldap2-dev libsasl2-dev \ | ||
| # cleaning up unused files | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN curl -sS https://install.python-poetry.org | POETRY_HOME=$POETRY_HOME python3 - && \ | ||
| ln -s $POETRY_HOME/bin/poetry /usr/local/bin/poetry | ||
|
|
||
| WORKDIR $PYSETUP_PATH | ||
|
|
||
| COPY poetry.lock pyproject.toml ./ | ||
|
|
||
| RUN if [ "$DEV" = "true" ]; then \ | ||
| poetry install --with dev --no-root; \ | ||
| else \ | ||
| poetry install --without dev --no-root; \ | ||
| fi | ||
|
|
||
|
|
||
| FROM python:3.13-slim AS runtime | ||
| ARG USERNAME=nonroot | ||
| ARG ARG_VERSION | ||
| ARG USER_UID | ||
| ARG USER_GID | ||
| ENV TAPIR_VERSION=${ARG_VERSION} | ||
| ENV VENV_PATH="/opt/pysetup/.venv" \ | ||
| PATH="/opt/pysetup/.venv/bin:$PATH" | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install --no-install-recommends -y libpq-dev gettext libldap2-dev libsasl2-dev \ | ||
| libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0 \ | ||
| make git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN groupadd --gid $USER_GID $USERNAME && \ | ||
| useradd --uid $USER_UID --gid $USER_GID -m $USERNAME | ||
|
|
||
| WORKDIR /app | ||
| COPY . /app | ||
|
|
||
| RUN apt-get update -y \ | ||
| && apt-get --no-install-recommends install -y \ | ||
| gettext \ | ||
| libldap2-dev \ | ||
| libsasl2-dev \ | ||
| postgresql-client \ | ||
| postgresql-client-common \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && pip install poetry \ | ||
| && poetry install \ | ||
| && poetry run python manage.py compilemessages | ||
|
|
||
| COPY --from=build /opt/pysetup/.venv /opt/pysetup/.venv | ||
| COPY --from=build /opt/pysetup/ ./ | ||
|
|
||
| COPY tapir /app/tapir | ||
| COPY manage.py /app/manage.py | ||
| COPY Makefile /app/Makefile | ||
|
|
||
| RUN python manage.py compilemessages | ||
|
|
||
| USER $USERNAME | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.