Skip to content

Commit

Permalink
chore: reduce docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
japsu committed Apr 16, 2023
1 parent 1b6cbb9 commit 9ebe927
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
FROM python:3.11
FROM python:3.11 AS deps
WORKDIR /tmp
RUN mkdir /deps
ADD requirements.txt ./
RUN pip install -U pip setuptools wheel && \
pip wheel -r requirements.txt --no-cache-dir --wheel-dir /deps && \
rm -f /deps/setuptools-*.whl

FROM python:3.11-slim
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN groupadd -g 998 -r kompassi && useradd -r -g kompassi -u 998 kompassi && \
pip install -U pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
RUN groupadd -g 998 -r kompassi && useradd -r -g kompassi -u 998 kompassi && apt-get update && apt-get -y install libpq5 && rm -rf /var/lib/apt/lists
ADD requirements.txt ./
RUN --mount=type=bind,from=deps,source=/deps,target=/deps \
pip install --no-cache-dir --no-index --find-links /deps /deps/*.whl
ADD . .
RUN env DEBUG=1 python manage.py collectstatic --noinput && \
env DEBUG=1 python manage.py kompassi_i18n -ac && \
python -m compileall -q . && \
chmod 755 manage.py scripts/*.sh
USER kompassi
EXPOSE 8000
ENTRYPOINT ["/usr/src/app/scripts/docker-entrypoint.sh"]
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
6 changes: 3 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git+https://github.com/kcsry/lippukala.git
git+https://github.com/kcsry/paikkala.git
lippukala @ https://github.com/kcsry/lippukala/archive/fd6f55f499b12062887f6c78ff2c6749df8ba5cc.zip
paikkala @ https://github.com/kcsry/paikkala/archive/205a72f3f6a1b49c7886f1062b600f42a8ebb127.zip
Babel
black
bleach
Expand Down Expand Up @@ -32,7 +32,7 @@ paramiko
passlib
phonenumberslite
Pillow
psycopg
psycopg[c]
pypugjs
pytest-django
python-dateutil
Expand Down
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jwcrypto==1.4.2
# via django-oauth-toolkit
kombu==5.2.4
# via celery
lippukala @ git+https://github.com/kcsry/lippukala.git
lippukala @ https://github.com/kcsry/lippukala/archive/fd6f55f499b12062887f6c78ff2c6749df8ba5cc.zip
# via -r requirements.in
markdown==3.4.3
# via -r requirements.in
Expand All @@ -173,7 +173,7 @@ packaging==23.1
# black
# deprecation
# pytest
paikkala @ git+https://github.com/kcsry/paikkala.git
paikkala @ https://github.com/kcsry/paikkala/archive/205a72f3f6a1b49c7886f1062b600f42a8ebb127.zip
# via -r requirements.in
paramiko==3.1.0
# via -r requirements.in
Expand Down Expand Up @@ -201,8 +201,10 @@ prompt-toolkit==3.0.38
# via
# click-repl
# ipython
psycopg==3.1.8
psycopg[c]==3.1.8
# via -r requirements.in
psycopg-c==3.1.8
# via psycopg
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
Expand Down

0 comments on commit 9ebe927

Please sign in to comment.