-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move database connection parameters to an environment file to avoid duplication * Update to modern command `docker compose` vs `docker-compose` * Remove the version number from the file since this is ignored by docker and causes IDEs to attempt to validate * Removed mount of `node_modules` volume in `web` container since the `web` container does not have `node` installed * Removed `:delegated,rw` since this was the incorrect option (it meant that the container had the authoritative view of the files, leading to long delays in synchronizing with the host which caused issues when trying to detect changes for migrations, etc.), and is no longer necessary in modern docker * Added health checks for containers to avoid warnings/errors * Updated base image to python:3.9-bullseye to at least match the version used in `bakerydemo`'s `docker-compose.yml` * Updated base image to postgres:14.1 to match `bakerydemo`'s `docker-compose.yml`
- Loading branch information
Showing
8 changed files
with
82 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DATABASE_HOST=db | ||
DATABASE_PORT=5432 | ||
DATABASE_NAME=app_db | ||
DATABASE_USER=app_user | ||
DATABASE_PASSWORD=changeme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
wagtail | ||
bakerydemo | ||
libs | ||
.env | ||
.idea | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.8-bullseye | ||
FROM python:3.9-bullseye | ||
LABEL maintainer="[email protected]" | ||
|
||
# Set environment varibles | ||
# Set environment variables | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Install libenchant and create the requirements folder. | ||
|
@@ -26,3 +26,5 @@ RUN cd /code/wagtail/ \ | |
COPY ./libs/Willow /code/willow/ | ||
RUN cd /code/willow/ \ | ||
&& pip install -e .[testing] | ||
|
||
WORKDIR /code/bakerydemo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
version: '3' | ||
|
||
volumes: | ||
postgres-data: | ||
node_modules: | ||
|
||
services: | ||
web: | ||
container_name: "web" | ||
build: ./ | ||
working_dir: /code/bakerydemo | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
command: python manage.py runserver 0.0.0.0:8000 | ||
restart: "no" | ||
volumes: | ||
- ./wagtail:/code/wagtail:delegated,rw | ||
- ./bakerydemo:/code/bakerydemo:delegated,rw | ||
- node_modules:/code/wagtail/node_modules/ | ||
- ./wagtail:/code/wagtail | ||
- ./bakerydemo:/code/bakerydemo | ||
ports: | ||
- "8000:8000" | ||
environment: | ||
DATABASE_URL: "postgres://wagtail:changeme@db/wagtail" | ||
DATABASE_URL: "postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}" | ||
depends_on: | ||
- db | ||
- frontend | ||
db: | ||
condition: service_healthy | ||
frontend: | ||
condition: service_started | ||
|
||
db: | ||
container_name: "db" | ||
image: postgres:12.3-alpine | ||
environment: | ||
POSTGRES_USER: wagtail | ||
POSTGRES_DB: wagtail | ||
POSTGRES_PASSWORD: changeme | ||
- "POSTGRES_DB=${DATABASE_NAME}" | ||
- "POSTGRES_USER=${DATABASE_USER}" | ||
- "POSTGRES_PASSWORD=${DATABASE_PASSWORD}" | ||
restart: unless-stopped | ||
image: postgres:14.1 | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
restart: "no" | ||
expose: | ||
- "5432" | ||
healthcheck: | ||
test: "pg_isready --quiet --dbname=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}" | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
frontend: | ||
container_name: "frontend" | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.frontend | ||
working_dir: /code/wagtail | ||
volumes: | ||
- ./wagtail:/code/wagtail:delegated,rw | ||
- node_modules:/code/wagtail/node_modules/ | ||
- ./wagtail:/code/wagtail | ||
- node_modules:/code/wagtail/node_modules | ||
command: bash -c "echo 'Copying node_modules, this may take a few minutes...' && rsync -rah --info=progress2 /node_modules /code/wagtail/ && npm run start" | ||
restart: "no" | ||
tty: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters