From 4c0dc9e10e0f347fb7ecf352d54ad8d67cac61ac Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 6 May 2023 00:09:46 +0200 Subject: [PATCH] Extend docker-compose.yml to provide a complete dev setup --- Dockerfile-dev | 17 ++++++++++++++++ docker-compose.yml | 49 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 Dockerfile-dev diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 0000000..f381002 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,17 @@ +FROM python:3.10-alpine3.17 + +RUN apk add --no-cache git + +RUN adduser -h /home/shiftregister -D shiftregister + +USER shiftregister +WORKDIR /home/shiftregister + +ENV PATH="$PATH:/home/shiftregister/.local/bin" + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +WORKDIR /opt/shiftregister + +EXPOSE 8000 diff --git a/docker-compose.yml b/docker-compose.yml index f0cdc6b..73611f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,15 +2,58 @@ services: broker: - container_name: shiftregister_broker image: rabbitmq:3-alpine restart: unless-stopped + networks: + - dev ports: - 127.0.0.1:5672:5672 - result_backend: - container_name: shiftregister_result_backend + result-backend: image: redis:6-alpine restart: unless-stopped + networks: + - dev ports: - 127.0.0.1:6379:6379 + + server: + build: + context: . + dockerfile: Dockerfile-dev + image: shiftregister:dev + restart: unless-stopped + command: + - python + - manage.py + - runserver + - 0.0.0.0:8000 + environment: &celery + CELERY_BROKER_URL: amqp://guest:guest@broker:5672// + CELERY_RESULT_BACKEND: redis://result-backend + networks: + - dev + ports: + - 127.0.0.1:8000:8000 + volumes: + - .:/opt/shiftregister + + worker: + image: shiftregister:dev + restart: unless-stopped + command: + - celery + - -A + - shiftregister + - worker + - -B + - -l + - DEBUG + environment: *celery + networks: + - dev + volumes: + - .:/opt/shiftregister + +networks: + dev: