Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove race conditions in docker volumes during build/runtime #22912

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ${PIP_COMMAND} install --progress-bar=off --no-deps --exists-action=w -r require
npm ci ${NPM_ARGS} --include=prod
EOF

FROM base AS pip_development
FROM pip_production AS pip_development

RUN \
# Files required to install pip dependencies
Expand Down
12 changes: 9 additions & 3 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
services:
worker:
olympia_volumes:
environment:
- HOST_UID=9500
volumes:
- storage:/data/olympia/storage
- /data/olympia

worker:
extends:
service: olympia_volumes
depends_on:
- olympia_volumes
web:
extends:
service: worker
volumes:
- storage:/data/olympia/storage

nginx:
volumes:
- storage:/srv/storage
depends_on:
- olympia_volumes

volumes:
storage:
34 changes: 26 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ x-env-mapping: &env
- DEBUG
- DATA_BACKUP_SKIP

x-site-static-mount: &site-static-mount
data_site_static:/data/olympia/site-static

x-olympia: &olympia
<<: *env
image: ${DOCKER_TAG:-}
Expand All @@ -39,6 +42,14 @@ x-olympia: &olympia
entrypoint: ["/data/olympia/docker/entrypoint.sh"]

services:
olympia_volumes:
<<: *olympia
# We could let this container exit 0, but docker compose --wait
# interprets this as a failure, even with a passing healtcheck.
# so we just sleep indefinitely instead.
command: ["sleep", "infinity"]
volumes:
- *site-static-mount
worker:
<<: *olympia
command: [
Expand All @@ -53,12 +64,7 @@ services:
]
volumes:
- .:/data/olympia
# Don't mount generated files. They only exist in the container
# and would otherwiser be deleted by mounting the cwd volume above
- /data/olympia/static-build
- /data/olympia/site-static
- ./package.json:/deps/package.json
- ./package-lock.json:/deps/package-lock.json

extra_hosts:
- "olympia.test:127.0.0.1"
restart: on-failure:5
Expand Down Expand Up @@ -93,21 +99,30 @@ services:
start_period: 120s
command:
- uwsgi --ini /data/olympia/docker/uwsgi.ini
volumes:
# Don't mount generated files. They only exist in the container
# and would otherwiser be deleted by mounting the cwd volume above
- /data/olympia/static-build
- *site-static-mount
- ./package.json:/deps/package.json
- ./package-lock.json:/deps/package-lock.json
depends_on:
- olympia_volumes

nginx:
image: nginx
volumes:
- ./docker/nginx/addons.conf:/etc/nginx/conf.d/addons.conf
- .:/srv
- *site-static-mount
ports:
- "80:80"
networks:
default:
aliases:
- olympia.test
depends_on:
- web
- addons-frontend
- olympia_volumes

memcached:
image: memcached:1.4
Expand Down Expand Up @@ -183,6 +198,9 @@ networks:
default:

volumes:
# Volumes for static files that should not be
# mounted from the host.
data_site_static:
data_mysqld:
# Keep this value in sync with Makefile-os
# External volumes must be manually created/destroyed
Expand Down
Loading