fahd200581 commited on
Commit
c779193
·
verified ·
1 Parent(s): 25c5e2d

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONDONTWRITEBYTECODE="1"
5
+ ENV PYTHONUNBUFFERED="1"
6
+ ENV PORT="8888"
7
+
8
+ # Set work directory
9
+ WORKDIR /mediaflow_proxy
10
+
11
+ # Create a non-root user
12
+ RUN useradd -m mediaflow_proxy
13
+ RUN chown -R mediaflow_proxy:mediaflow_proxy /mediaflow_proxy
14
+
15
+ # Set up the PATH to include the user's local bin
16
+ ENV PATH="/home/mediaflow_proxy/.local/bin:$PATH"
17
+
18
+ # Switch to non-root user
19
+ USER mediaflow_proxy
20
+
21
+ # Install Poetry
22
+ RUN pip install --user --no-cache-dir poetry
23
+
24
+ # Copy only requirements to cache them in docker layer
25
+ COPY --chown=mediaflow_proxy:mediaflow_proxy pyproject.toml poetry.lock* /mediaflow_proxy/
26
+
27
+ # Project initialization:
28
+ RUN poetry config virtualenvs.in-project true \
29
+ && poetry install --no-interaction --no-ansi --no-dev
30
+
31
+ # Copy project files
32
+ COPY --chown=mediaflow_proxy:mediaflow_proxy . /mediaflow_proxy
33
+
34
+ # Expose the port the app runs on
35
+ EXPOSE 8888
36
+
37
+ # Activate virtual environment and run the application with Gunicorn
38
+ CMD ["poetry", "run", "gunicorn", "mediaflow_proxy.main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8888", "--timeout", "120", "--max-requests", "500", "--max-requests-jitter", "200", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info"]