Skip to content

Commit

Permalink
updates Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Dec 20, 2024
1 parent 44a5d55 commit 7648e11
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 61 deletions.
28 changes: 14 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ LABEL distro="tests"
LABEL org.opencontainers.image.created="$BUILD_DATE"
LABEL org.opencontainers.image.version="$VERSION"

ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \
DJANGO_SETTINGS_MODULE=country_workspace.config.settings \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=""\
UV_PROJECT_ENVIRONMENT=/venv \
VIRTUAL_ENV=/venv \
UWSGI_PROCESSES=4

WORKDIR /app
COPY uv.lock README.md MANIFEST.in pyproject.toml /app/
COPY src /app/src/
Expand All @@ -94,8 +96,10 @@ ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
DJANGO_SETTINGS_MODULE=country_workspace.config.settings \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=""\
UV_PROJECT_ENVIRONMENT=/venv \
VIRTUAL_ENV=/venv \
UWSGI_PROCESSES=4

WORKDIR /app
COPY uv.lock README.md MANIFEST.in pyproject.toml /app/
COPY src /app/src/
Expand All @@ -114,7 +118,7 @@ ARG BUILD_DATE
ARG GIT_SHA
ARG BRANCH

ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \
BUILD_DATE=$BUILD_DATE \
GIT_SHA=$GIT_SHA \
VERSION=$VERSION \
Expand All @@ -124,6 +128,8 @@ ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \
STATIC_URL="/static/" \
PYTHONPATH=""\
PGSSLCERT="/tmp/postgresql.crt" \
UV_PROJECT_ENVIRONMENT=/venv \
VIRTUAL_ENV=/venv \
UWSGI_PROCESSES=4

RUN <<EOF cat> /RELEASE
Expand All @@ -135,20 +141,14 @@ EOF
WORKDIR /app
COPY docker/conf /conf/
COPY docker/bin/* /usr/local/bin/
COPY LICENSE.md README.md /
COPY src /app/src/
RUN rm -fr /app/src/

COPY . /app/

COPY --chown=hope:unicef --from=production /app/.venv /app/.venv
COPY --chown=hope:unicef --from=production /venv /venv
COPY --from=builder /usr/local/bin/uwsgi /usr/local/bin/uv /usr/local/bin/
RUN --mount=type=cache,target=/root/.uv-cache \
--mount=type=bind,source=uv.lock,target=/app/uv.lock \
--mount=type=bind,source=pyproject.toml,target=/app/pyproject.toml \
--mount=type=bind,source=MANIFEST.in,target=/app/MANIFEST.in \
--mount=type=bind,source=README.md,target=/app/README.md \
--mount=type=bind,source=./src/country_workspace,target=/app/src/country_workspace \
uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps .
uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps . \
&& rm -fr /app


EXPOSE 8000
Expand Down
7 changes: 4 additions & 3 deletions docker/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ case "$1" in
fi
set -- tini -- "$@"
set -- uwsgi --http :8000 \
-H /venv \
--module country_workspace.config.wsgi \
--mimefile=/conf/mime.types \
--uid hope \
Expand All @@ -29,16 +30,16 @@ case "$1" in
;;
worker)
set -- tini -- "$@"
set -- gosu user:app celery -A country_workspace.config.celery worker -E --loglevel=ERROR --concurrency=4
set -- gosu hope:unicef celery -A country_workspace.config.celery worker --statedb worker-E --loglevel=ERROR --concurrency=4
;;
beat)
set -- tini -- "$@"
set -- gosu user:app celery -A country_workspace.config.celery beat --loglevel=ERROR --scheduler django_celery_beat.schedulers:DatabaseScheduler
set -- gosu hope:unicef celery -A country_workspace.config.celery beat --loglevel=ERROR --scheduler django_celery_beat.schedulers:DatabaseScheduler
;;
flower)
export DATABASE_URL="sqlite://:memory:"
set -- tini -- "$@"
set -- gosu user:app celery -A country_workspace.config.celery flower
set -- gosu hope:unicef celery -A country_workspace.config.celery flower
;;
esac

Expand Down
28 changes: 0 additions & 28 deletions docker/conf/uwsgi.ini

This file was deleted.

4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ docs = [
"mkdocs-gen-files>=0.5.0",
]

distribution = [
"uwsgi>=2.0.27",
]

[tool.uv]
package = true
dev-dependencies = [
Expand Down
12 changes: 0 additions & 12 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7648e11

Please sign in to comment.