docker container for daemons

This commit is contained in:
2026-09-09 18:01:48 +03:00
parent 1aa3085468
commit b4e88a6ff4
7 changed files with 134 additions and 203 deletions
+34
View File
@@ -1,6 +1,7 @@
name: disexcel
services:
backend-dev:
profiles: ["dev"]
image: "${DOCKER_REGISTRY:-local}/excel-dev:${IMAGE_TAG:-local}"
@@ -13,6 +14,8 @@ services:
ipc: private #Inter-Process Communication (IPC) namespace for high-performance applications
environment:
- DB_HOST=psql #rewrite DB_HOST var to communicate inside the docker network
- RABBITMQ_HOST=rabbitmq
- REDIS_HOST=redis
volumes:
- type: bind
source: ../src
@@ -32,6 +35,9 @@ services:
- type: bind
source: ../logs
target: /home/excel-project/logs
- type: bind
source: ../daemon_run.py
target: /home/excel-project/daemon_run.py
networks:
- backend
depends_on:
@@ -57,6 +63,8 @@ services:
ipc: private #Inter-Process Communication (IPC) namespace for high-performance applications
environment:
- DB_HOST=psql
- RABBITMQ_HOST=rabbitmq
- REDIS_HOST=redis
volumes:
- type: bind
source: ../configs
@@ -83,6 +91,32 @@ services:
ports:
- "80:8000"
daemons:
profiles: ["prod", "dev"]
image: "${DOCKER_REGISTRY:-local}/excel-daemons:${IMAGE_TAG:-local}"
container_name: daemons
environment:
- RABBITMQ_HOST=rabbitmq
build:
dockerfile: ./docker/dockerfile
context: ../
target: daemon
init: true
ipc: private
volumes:
- type: bind
source: ../configs
target: /home/excel-project/configs
- type: bind
source: ../logs
target: /home/excel-project/logs
depends_on:
rabbitmq:
condition: service_healthy
networks:
- backend
restart: unless-stopped
psql:
profiles: ["prod", "dev", "local"]
image: postgres:16-alpine
+48 -2
View File
@@ -34,7 +34,7 @@ COPY pyproject.toml poetry.lock ./
RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --only main \
&& poetry install --no-root --no-interaction --only main,web \
&& pip uninstall -y poetry poetry-core poetry-plugin-export
# --- Stage 2: Python Backend prod ---
@@ -62,4 +62,50 @@ RUN groupadd --gid 1000 appuser \
USER appuser
ENTRYPOINT ["./entrypoint.sh", "--prod"]
ENTRYPOINT ["./entrypoint.sh", "--prod"]
# --- Stage 1: Python daemon builder ---
FROM python:3.14-slim AS worker-builder
LABEL org.opencontainers.image.title="The-DisExcel-project-dev"
LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_DisExcel_project"
WORKDIR /home/excel-project
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python -m venv "$VIRTUAL_ENV"
COPY pyproject.toml poetry.lock ./
RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --only main,daemon \
&& pip uninstall -y poetry poetry-core poetry-plugin-export
# --- Stage 2: Python daemons ---
FROM python:3.14-slim AS daemon
LABEL org.opencontainers.image.title="The-DisExcel-project-prod"
LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_DisExcel_project"
WORKDIR /home/excel-project
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=worker-builder /opt/venv /opt/venv
COPY pyproject.toml poetry.lock alembic.ini daemon_run.py ./
COPY src/ ./src/
RUN groupadd --gid 1000 appuser \
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser \
&& chown -R appuser:appuser /home/excel-project
USER appuser
ENTRYPOINT ["python","-u", "daemon_run.py", "--all"]