Docker compose

- switch to postgres
- update/clean up default wagtail dockerfile
master
Pete Ley 6 months ago
parent 5de1503f84
commit f6f09d70b2

@ -1,60 +1,23 @@
# Use an official Python runtime based on Debian 10 "buster" as a parent image.
FROM python:3.8.1-slim-buster
# Add user that will be used in the container.
FROM python:3.11.6-slim-bookworm
RUN useradd wagtail
# Port used by this container to serve HTTP.
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 \
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 \
libmariadb-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libwebp-dev \
inetutils-ping \
&& rm -rf /var/lib/apt/lists/*
# Install the application server.
RUN pip install "gunicorn==20.0.4"
# Install the project requirements.
RUN pip install "gunicorn"
COPY requirements.txt /
RUN pip install -r /requirements.txt
# Use /app folder as a directory where the source code is stored.
WORKDIR /app
# Set this directory to be owned by the "wagtail" user. This Wagtail project
# uses SQLite, the folder needs to be owned by the user that
# will be writing to the database file.
RUN chown wagtail:wagtail /app
# Copy the source code of the project into the container.
COPY --chown=wagtail:wagtail . .
# 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
# 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 stairfield.wsgi:application
CMD set -xe; gunicorn --reload stairfield.wsgi:application

@ -0,0 +1,14 @@
services:
web:
build: .
ports:
- "8000:8000"
volumes:
- .:/app
depends_on:
- db
db:
image: "postgres"
restart: always
environment:
POSTGRES_PASSWORD: postpass

@ -14,16 +14,22 @@ djangorestframework==3.14.0
draftjs-exporter==2.1.7
et-xmlfile==1.1.0
filetype==1.2.0
greenlet==3.0.1
html5lib==1.1
idna==3.4
l18n==2021.3
mysql-connector-python==8.2.0
openpyxl==3.1.2
Pillow==10.1.0
pillow-heif==0.13.1
protobuf==4.21.12
psycopg==3.1.12
psycopg-binary==3.1.12
pytz==2023.3.post1
requests==2.31.0
six==1.16.0
soupsieve==2.5
SQLAlchemy==2.0.23
sqlparse==0.4.4
telepath==0.3.1
typing-extensions==4.8.0

@ -89,8 +89,12 @@ WSGI_APPLICATION = "stairfield.wsgi.application"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
"ENGINE": "django.db.backends.postgresql",
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'postpass',
'HOST': 'db',
'PORT': 5432,
}
}

Loading…
Cancel
Save