-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.Celery
More file actions
41 lines (30 loc) · 1.13 KB
/
Dockerfile.Celery
File metadata and controls
41 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Dockerfile.Celery
# Use an official Python runtime as a parent image
FROM python:3.10.13-bookworm
# Set the working directory
WORKDIR /app
# Copy application files into the container
COPY . /app
# Environment variables to prevent Python from writing .pyc files and enable unbuffered stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set PYTHONPATH to include /app
ENV PYTHONPATH="/app:${PYTHONPATH}"
# Set MODEL_PATH to point to ResNet50 model
ENV MODEL_PATH="/app/cv_model/ResNet50_TCM1.pth"
# Install necessary system dependencies and upgrade pip
RUN apt-get update && apt-get install -y \
build-essential \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& pip install redis \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -ms /bin/bash celeryuser
# Change ownership of /app and its subdirectories to celeryuser
RUN chown -R celeryuser:celeryuser /app
# Switch to celeryuser
USER celeryuser
# Set the default command to run the Celery worker
CMD ["celery", "-A", "app.services.celery.celery_config.celery_app", "worker", "--loglevel=info"]