Added worker tasks to docker-compose

This commit is contained in:
2026-04-21 17:24:03 +09:30
parent 1778dd85d5
commit 33a7fdac59
2 changed files with 76 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
FROM python:3.11-slim as builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY requirements/base.txt requirements/base.txt
COPY requirements/production.txt requirements/production.txt
RUN pip install --no-cache-dir --upgrade pip wheel && \
pip install --no-cache-dir -r requirements/production.txt
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 1000 appgroup && \
useradd --uid 1000 --gid appgroup --shell /bin/bash --create-home appuser
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY --chown=appuser:appgroup . .
RUN mkdir -p /app/logs && chown -R appuser:appgroup /app/logs
USER appuser
HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 \
CMD pgrep -f "job_runner" || exit 1
CMD ["python", "scripts/job_runner.py"]
+36
View File
@@ -78,6 +78,42 @@ services:
timeout: 10s timeout: 10s
retries: 3 retries: 3
zerotier-reconciler:
build:
context: .
dockerfile: Dockerfile.job
env_file:
- .env
environment:
- JOB_NAME=zerotier_reconciliation
- JOB_INTERVAL_SECONDS=${ZEROTIER_RECONCILE_INTERVAL:-120}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- authy2-network
restart: unless-stopped
mfa-compliance:
build:
context: .
dockerfile: Dockerfile.job
env_file:
- .env
environment:
- JOB_NAME=mfa_compliance
- JOB_INTERVAL_SECONDS=${MFA_COMPLIANCE_INTERVAL:-3600}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- authy2-network
restart: unless-stopped
networks: networks:
authy2-network: authy2-network:
driver: bridge driver: bridge