-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.old
51 lines (36 loc) · 1.69 KB
/
Dockerfile.old
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
42
43
44
45
46
47
48
49
50
51
# Base image with Python 3.8 and Alpine Linux
FROM python:3.8-alpine
# Set the working directory for the container
WORKDIR /app
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN python -m pip install --no-cache-dir --upgrade \
pip \
setuptools \
wheel
# Copy the requirements.txt file to the container and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application files to the container
COPY . .
# Set environment variables for Celery
ENV CELERY_BROKER_URL amqp://guest:guest@localhost:5672//
# Set environment variables for Flask
ENV FLASK_APP app.py
ENV FLASK_ENV production
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Expose the port that the Flask app will run on
EXPOSE 5000
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
# Set the entry point for the container to run the Flask app with gunicorn and start celery worker
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:5000", "--access-logfile", "-", "--error-logfile", "-", "app:app", "--worker-class", "eventlet", "--workers", "1", "--timeout", "3600", "--graceful-timeout", "120", "--keep-alive", "120", "--preload", "&&", "celery", "-A", "app.celery", "worker", "--loglevel=INFO", "--concurrency=1", "--time-limit=3600", "-Ofair"]
# WORKDIR /app
# COPY . /app