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

obs-443: switch to docker compose watch #6873

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Next Next commit
obs-443: switch to docker compose watch
Currently for the local dev environment, we volume mount the local
directory as `/app` which causes anything built during docker image
build to be shadowed by the user's local directory. We get around this
by having docker image build any artifacts into directories in the image
that are not under `/app`. This is a little wonky and there are hacks
strewn about to alleviate the consequences.

Instead of doing that, this PR is an initial pass and switching to
docker compose watch. In this new model, we no longer volume mount the
local directory as `/app` and instead docker compose watches for changes
on the local file system and syncs them with the container and will run
any rebuilding scripts.

This should work with the local dev environment, CI, and server
environments.

This requires v2.22.0 of docker compose plugin.

This doesn't update documentation and doesn't document edge cases to be
aware of.
  • Loading branch information
willkg committed Jan 23, 2025
commit dea8886eb22619a48651b4b215cdcbd9e19a3039
37 changes: 0 additions & 37 deletions docker-compose.override.yml

This file was deleted.

30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,11 @@ services:
- postgresql
- legacy-elasticsearch
- elasticsearch
develop:
watch:
- action: sync
path: .
target: /app

# For development

@@ -44,6 +49,11 @@ services:
- postgresql
- legacy-elasticsearch
- elasticsearch
develop:
watch:
- action: sync
path: .
target: /app

devcontainer:
build:
@@ -82,6 +92,11 @@ services:
- elasticsearch
- symbolsserver
command: ["processor"]
develop:
watch:
- action: sync
path: .
target: /app

crontabber:
image: local/socorro_app
@@ -95,6 +110,11 @@ services:
- legacy-elasticsearch
- elasticsearch
command: ["crontabber"]
develop:
watch:
- action: sync
path: .
target: /app

webapp:
image: local/socorro_app
@@ -114,6 +134,11 @@ services:
command: ["webapp", "--dev"]
ports:
- "8000:8000"
develop:
watch:
- action: sync
path: .
target: /app
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes the sync action which will copy files from the host to the container.

There's also a rebuild action which I think we want to use to run manage.py collectstatic and esbuild when js and css files change.

We only need this rebuild on the webapp service because that's the only one using js and css files.


stage_submitter:
image: local/socorro_app
@@ -125,6 +150,11 @@ services:
- gcs-emulator
- pubsub
command: ["stage_submitter"]
develop:
watch:
- action: sync
path: .
target: /app

# https://github.com/willkg/kent
fakesentry:
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ _env:

# Build docker images
build *args: _env
docker compose build --progress plain {{args}}
docker compose --progress plain build {{args}}

# Set up Postgres, Elasticsearch, local Pub/Sub, and local GCS services.
setup: _env
@@ -25,8 +25,8 @@ update-data: _env
docker compose run --rm app shell /app/bin/update_data.sh

# Run services, defaults to socorro and fakesentry for debugging
run *args='--attach=processor --attach=webapp --attach=fakesentry processor webapp': _env
docker compose up {{args}}
run *args='--attach=processor --attach=webapp --attach=fakesentry processor webapp': _env build
docker compose up --watch {{args}}

# Run stage submitter and fake collector
run-submitter *args='--attach=stage_submitter --attach=fakecollector': _env