Skip to content

Commit

Permalink
Merge pull request #1177 from PokeAPI/deps
Browse files Browse the repository at this point in the history
Fix building arm6/7 docker image and reduce Docker image size
  • Loading branch information
Naramsim authored Jan 6, 2025
2 parents b809322 + cf62b20 commit c49b5bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
27 changes: 19 additions & 8 deletions Resources/docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
FROM python:3.10-alpine
FROM python:3.10.16-alpine3.21 AS builder

ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE 'config.docker-compose'
ENV PYTHONUNBUFFERED=1

RUN mkdir /code
WORKDIR /code

ADD requirements.txt /code/
RUN apk add --no-cache postgresql-libs libstdc++
RUN apk add --no-cache --virtual .build-deps gcc g++ musl-dev \
postgresql-dev rust cargo && \
python3 -m pip install -r requirements.txt --no-cache-dir && \
apk --purge del .build-deps
postgresql-dev binutils rust cargo && \
python3 -m pip install -r requirements.txt --no-cache-dir

FROM python:3.10.16-alpine3.21

ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE='config.docker-compose'

RUN mkdir /code
WORKDIR /code

COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin

ADD . /code/

RUN addgroup -g 1000 -S pokeapi && \
adduser -u 1000 -S pokeapi -G pokeapi

USER pokeapi
CMD gunicorn config.wsgi:application -c gunicorn.conf.py

CMD ["gunicorn", "config.wsgi:application", "-c", "gunicorn.conf.py"]

EXPOSE 80
4 changes: 2 additions & 2 deletions Resources/k8s/kustomize/base/other/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: Ingress
metadata:
name: pokeapi-ingress
annotations:
kubernetes.io/ingress.class: "haproxy"
ingress.kubernetes.io/config-backend: |
compression algo gzip
compression type application/json
Expand All @@ -13,6 +12,7 @@ spec:
name: default-backend
port:
number: 8080
ingressClassName: haproxy
rules:
- http:
paths:
Expand All @@ -29,7 +29,6 @@ kind: Ingress
metadata:
name: graphql-ingress
annotations:
kubernetes.io/ingress.class: "haproxy"
ingress.kubernetes.io/config-backend: |
http-request replace-path /graphql(.*) \1
spec:
Expand All @@ -38,6 +37,7 @@ spec:
name: default-backend
port:
number: 8080
ingressClassName: haproxy
rules:
- http:
paths:
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Django==3.2.23
Django==3.2.25
Unipath==1.1
coverage==4.5.4
django-cors-headers==3.14.0
django-discover-runner==1.0
django-redis==4.12.1
django-cachalot==2.4.2
django-cachalot==2.4.5
djangorestframework==3.14.0
gunicorn==21.2.0
gunicorn==23.0.0
mimeparse==0.1.3
psycopg2-binary==2.9.9
psycopg2-binary==2.9.10
python-dateutil==2.8.2
python-mimeparse==1.6.0
drf-spectacular==0.27.2
5 changes: 1 addition & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
-r requirements.txt
pylint===2.8.2
pylint-django===2.4.4
astroid==2.5.6
black==23.11.0
black==23.12.1

0 comments on commit c49b5bb

Please sign in to comment.