48 lines
1.2 KiB
Docker
48 lines
1.2 KiB
Docker
FROM python:3.8.1-slim-buster
|
|
|
|
RUN useradd wagtail
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PORT=8000
|
|
|
|
# Install system packages required by Wagtail and Django
|
|
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
|
|
build-essential \
|
|
libpq-dev \
|
|
libmariadbclient-dev \
|
|
libjpeg62-turbo-dev \
|
|
zlib1g-dev \
|
|
libwebp-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Upgrade pip to the latest version
|
|
RUN pip install --upgrade pip
|
|
|
|
# Install the application server
|
|
RUN pip install "gunicorn==20.0.4"
|
|
|
|
COPY requirements.txt /app/requirements.txt
|
|
RUN pip install -r /app/requirements.txt
|
|
|
|
# Copy the source code of the project into the container
|
|
COPY --chown=wagtail:wagtail . .
|
|
|
|
# Set this directory to be owned by the "wagtail" user
|
|
RUN chown wagtail:wagtail /app
|
|
|
|
# Use user "wagtail" to run the build commands below and the server itself
|
|
USER wagtail
|
|
|
|
# Collect static files
|
|
RUN python manage.py collectstatic --noinput --clear
|
|
|
|
# Port used by this container to serve HTTP
|
|
EXPOSE 8000
|
|
|
|
# Runtime command that executes when "docker run" is called
|
|
CMD ["sh", "-c", "python manage.py migrate --noinput && gunicorn saburly.wsgi:application"]
|