diff --git a/.coverage b/.coverage deleted file mode 100644 index 6b6701342..000000000 Binary files a/.coverage and /dev/null differ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..d8e071531 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose +{ + "name": "tapir", + + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "../docker-compose.yml", + "docker-compose.dev.override.yml" + ], + + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. + "service": "web", + + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml + "workspaceFolder": "/app", + "remoteUser": "noroot", + "shutdownAction": "stopCompose", +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.dev.override.yml b/.devcontainer/docker-compose.dev.override.yml new file mode 100644 index 000000000..e45129bae --- /dev/null +++ b/.devcontainer/docker-compose.dev.override.yml @@ -0,0 +1,5 @@ +services: + web: + build: + args: + UID: 1000 diff --git a/django.Dockerfile b/django.Dockerfile index 2f2a5a4f9..5c79ca255 100644 --- a/django.Dockerfile +++ b/django.Dockerfile @@ -1,7 +1,9 @@ FROM python:3.13 ENV PYTHONUNBUFFERED=1 -WORKDIR /app -COPY . /app + +ARG UID=1000 +ARG GID=$UID +ARG USERNAME=noroot RUN apt-get update -y \ && apt-get --no-install-recommends install -y \ @@ -9,8 +11,22 @@ RUN apt-get update -y \ 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 + postgresql-client-common \ + python3-poetry \ + && rm -rf /var/lib/apt/lists/* + +RUN if [ "$UID" -ne 0 ]; then \ + addgroup --gid "$GID" "$USERNAME" \ + && adduser --disabled-password --gecos "" --uid "$UID" --gid "$GID" "$USERNAME"; \ + fi + +WORKDIR /app +COPY --chown=$UID:$GID . /app +# change ownership of the app dir itself +RUN chown $UID:$GID /app + +USER ${UID}:${GID} + +RUN poetry config virtualenvs.in-project true + +CMD bash -c "poetry install && poetry run python manage.py compilemessages --ignore '.venv' && poetry run python manage.py runserver_plus 0.0.0.0:80" diff --git a/docker-compose.yml b/docker-compose.yml index 325bc90c4..6c0bc2ff3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,9 +17,8 @@ services: build: context: . dockerfile: ./django.Dockerfile - command: bash -c "poetry install && - poetry run python manage.py compilemessages --ignore \".venv\" && - poetry run python manage.py runserver_plus 0.0.0.0:80" + args: + UID: 0 volumes: - .:/app environment: