From 72f960cff1f5d4033342a501724db5056db3070b Mon Sep 17 00:00:00 2001 From: Naramsim Date: Tue, 7 Jan 2025 12:39:51 +0100 Subject: [PATCH] feat: switch to debian --- Resources/docker/app/Dockerfile | 34 ++++++-------------------- Resources/docker/app/README.md | 2 +- Resources/docker/app/alpine/Dockerfile | 33 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 Resources/docker/app/alpine/Dockerfile diff --git a/Resources/docker/app/Dockerfile b/Resources/docker/app/Dockerfile index e2e551b75..54559dcdd 100644 --- a/Resources/docker/app/Dockerfile +++ b/Resources/docker/app/Dockerfile @@ -1,33 +1,15 @@ -FROM python:3.11.11-alpine3.21 AS builder +FROM python:3.10.16-bookworm -ENV PYTHONUNBUFFERED=1 - -RUN mkdir /code +ENV PYTHONUNBUFFERED 1 +ENV DJANGO_SETTINGS_MODULE 'config.docker-compose' 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 binutils rust cargo && \ - python3 -m pip install -r requirements.txt --no-cache-dir - -FROM python:3.11.11-alpine3.21 - -ENV PYTHONUNBUFFERED=1 -ENV DJANGO_SETTINGS_MODULE='config.docker-compose' - -RUN mkdir /code -WORKDIR /code - -COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages -COPY --from=builder /usr/local/bin /usr/local/bin - +RUN pip install --no-cache-dir -r requirements.txt ADD . /code/ -RUN addgroup -g 1000 -S pokeapi && \ - adduser -u 1000 -S pokeapi -G pokeapi -USER pokeapi +RUN groupadd -g 1000 pokeapi && \ + useradd -u 1000 -g pokeapi pokeapi -CMD ["gunicorn", "config.wsgi:application", "-c", "gunicorn.conf.py"] - -EXPOSE 80 +USER pokeapi +CMD gunicorn config.wsgi:application -c gunicorn.conf.py \ No newline at end of file diff --git a/Resources/docker/app/README.md b/Resources/docker/app/README.md index 48c5d5486..bcc1ecff4 100644 --- a/Resources/docker/app/README.md +++ b/Resources/docker/app/README.md @@ -17,7 +17,7 @@ - [`master`](https://github.com/PokeAPI/pokeapi/blob/master/Resources/docker/app/Dockerfile) - [`staging`](https://github.com/PokeAPI/pokeapi/blob/staging/Resources/docker/app/Dockerfile) -> `pokeapi` uses `python:3.10-alpine` as base image. +> `pokeapi` uses `python:3.10-bookworm` as base image. ## What is PokeAPI? diff --git a/Resources/docker/app/alpine/Dockerfile b/Resources/docker/app/alpine/Dockerfile new file mode 100644 index 000000000..e2e551b75 --- /dev/null +++ b/Resources/docker/app/alpine/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.11.11-alpine3.21 AS builder + +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 binutils rust cargo && \ + python3 -m pip install -r requirements.txt --no-cache-dir + +FROM python:3.11.11-alpine3.21 + +ENV PYTHONUNBUFFERED=1 +ENV DJANGO_SETTINGS_MODULE='config.docker-compose' + +RUN mkdir /code +WORKDIR /code + +COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/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"] + +EXPOSE 80