Skip to content

Commit

Permalink
build: introduce the worker as a separate node
Browse files Browse the repository at this point in the history
This makes the Docker environment feature-complete since no worker and
therefore no tasks were ran at all before this.

It also paves the way for that same separation to happen in production
because currently both the worker and the web server happen to run on
the same machine, which isn't the best idea for scalabilty or
resilience.

Introduce:
- a Redis node;
- a new "worker" service that runs off the tagged server
image ("ma-cantine-server");
- a Makefile to help administrate the Docker setup.
  • Loading branch information
freesteph committed Dec 12, 2024
1 parent d55a3f4 commit 9b416e8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DATA_WARE_HOUSE_PORT=
DATA_WARE_HOUSE_DB=
DEBUG_PERFORMANCE=True
ENVIRONMENT=dev
REDIS_URL=redis://localhost:6379/0
REDIS_URL=redis://redis
REDIS_PREPEND_KEY=LOCAL
OVERRIDE_TEST_SEED=
SIRET_API_KEY=
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DOCKER-RUN = docker compose run -e TERM --rm --entrypoint=""

build:
docker compose build

up:
docker compose up

down:
docker compose down

sh:
$(DOCKER-RUN) server bash
11 changes: 11 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# https://github.com/docker/awesome-compose
services:
server:
image: ma-cantine-server
build: .
volumes:
- "./:/app"
Expand Down Expand Up @@ -65,6 +66,16 @@ services:
interval: 10s
timeout: 5s
retries: 5
worker:
image: ma-cantine-server
env_file:
- ".env.docker"
command: ["celery", "-A", "macantine", "worker"]
depends_on:
- db
- redis
redis:
image: redis:latest
volumes:
# it's normal that this is empty, it simply defines the existance of persistent storage
db-data:

0 comments on commit 9b416e8

Please sign in to comment.