dnscms: use poetry in dockerfile (cheating)
This commit is contained in:
@ -1,60 +1,41 @@
|
|||||||
# Use an official Python runtime based on Debian 10 "buster" as a parent image.
|
FROM python:3.12-slim-bullseye
|
||||||
FROM python:3.8.1-slim-buster
|
|
||||||
|
|
||||||
# Add user that will be used in the container.
|
|
||||||
RUN useradd wagtail
|
RUN useradd wagtail
|
||||||
|
|
||||||
# Port used by this container to serve HTTP.
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Set environment variables.
|
|
||||||
# 1. Force Python stdout and stderr streams to be unbuffered.
|
|
||||||
# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE"
|
|
||||||
# command.
|
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
PORT=8000
|
PORT=8000
|
||||||
|
|
||||||
# Install system packages required by Wagtail and Django.
|
|
||||||
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
|
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
|
||||||
build-essential \
|
build-essential \
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
libmariadbclient-dev \
|
|
||||||
libjpeg62-turbo-dev \
|
libjpeg62-turbo-dev \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
libwebp-dev \
|
libwebp-dev \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install the application server.
|
ENV POETRY_VERSION=""
|
||||||
RUN pip install "gunicorn==20.0.4"
|
ENV POETRY_HOME="/opt/poetry"
|
||||||
|
ENV PIP_NO_CACHE_DIR=1
|
||||||
|
ENV POETRY_VIRTUALENVS_CREATE=false
|
||||||
|
ENV POETRY_NO_INTERACTION=1
|
||||||
|
ENV PATH="$POETRY_HOME/bin:$PATH"
|
||||||
|
|
||||||
# Install the project requirements.
|
RUN apt-get update \
|
||||||
COPY requirements.txt /
|
&& apt-get install --no-install-recommends --assume-yes curl
|
||||||
RUN pip install -r /requirements.txt
|
|
||||||
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||||
|
|
||||||
# Use /app folder as a directory where the source code is stored.
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY pyproject.toml poetry.lock README.md /app/
|
||||||
# Set this directory to be owned by the "wagtail" user. This Wagtail project
|
RUN pip install "gunicorn==20.0.4"
|
||||||
# uses SQLite, the folder needs to be owned by the user that
|
RUN poetry install --without=dev
|
||||||
# will be writing to the database file.
|
COPY . /app
|
||||||
RUN chown wagtail:wagtail /app
|
RUN chown wagtail:wagtail /app
|
||||||
|
|
||||||
# Copy the source code of the project into the container.
|
|
||||||
COPY --chown=wagtail:wagtail . .
|
COPY --chown=wagtail:wagtail . .
|
||||||
|
|
||||||
# Use user "wagtail" to run the build commands below and the server itself.
|
|
||||||
USER wagtail
|
USER wagtail
|
||||||
|
|
||||||
# Collect static files.
|
|
||||||
RUN python manage.py collectstatic --noinput --clear
|
RUN python manage.py collectstatic --noinput --clear
|
||||||
|
|
||||||
# Runtime command that executes when "docker run" is called, it does the
|
|
||||||
# following:
|
|
||||||
# 1. Migrate the database.
|
|
||||||
# 2. Start the application server.
|
|
||||||
# WARNING:
|
|
||||||
# Migrating database at the same time as starting the server IS NOT THE BEST
|
|
||||||
# PRACTICE. The database should be migrated manually or using the release
|
|
||||||
# phase facilities of your hosting platform. This is used only so the
|
|
||||||
# Wagtail instance can be started with a simple "docker run" command.
|
|
||||||
CMD set -xe; python manage.py migrate --noinput; gunicorn dnscms.wsgi:application
|
CMD set -xe; python manage.py migrate --noinput; gunicorn dnscms.wsgi:application
|
||||||
|
Reference in New Issue
Block a user