37 lines
1.2 KiB
Docker
37 lines
1.2 KiB
Docker
|
|
# BookWyrm Worker Container - Production Optimized
|
||
|
|
# Celery background task processor
|
||
|
|
|
||
|
|
FROM bookwyrm-base AS bookwyrm-worker
|
||
|
|
|
||
|
|
# Switch to root for system package installation
|
||
|
|
USER root
|
||
|
|
|
||
|
|
# Install only supervisor for worker management
|
||
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
|
|
supervisor \
|
||
|
|
&& rm -rf /var/lib/apt/lists/* \
|
||
|
|
&& apt-get clean \
|
||
|
|
&& apt-get autoremove -y
|
||
|
|
|
||
|
|
# Install Celery in virtual environment
|
||
|
|
RUN /opt/venv/bin/pip install --no-cache-dir celery[redis]
|
||
|
|
|
||
|
|
# Copy worker-specific configuration
|
||
|
|
COPY supervisord-worker.conf /etc/supervisor/conf.d/supervisord.conf
|
||
|
|
COPY entrypoint-worker.sh /entrypoint.sh
|
||
|
|
|
||
|
|
# Set permissions efficiently
|
||
|
|
RUN chmod +x /entrypoint.sh \
|
||
|
|
&& mkdir -p /var/log/supervisor /var/log/celery \
|
||
|
|
&& chown -R bookwyrm:bookwyrm /var/log/celery \
|
||
|
|
&& chown -R bookwyrm:bookwyrm /app
|
||
|
|
|
||
|
|
# Health check for worker
|
||
|
|
HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 \
|
||
|
|
CMD /opt/venv/bin/celery -A celerywyrm inspect ping -d celery@$HOSTNAME || exit 1
|
||
|
|
|
||
|
|
# Run as root to manage celery via supervisor
|
||
|
|
USER root
|
||
|
|
|
||
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
||
|
|
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|