-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (54 loc) · 1.61 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (54 loc) · 1.61 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Use a minimal Debian base
FROM debian:bookworm-slim
# Set working directory
WORKDIR /app
# Install dependencies for building Python and system tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
wget \
curl \
ffmpeg \
libffi-dev \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
liblzma-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Download and compile Python 3.13.5 free-threaded
RUN wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tgz \
&& tar -xzf Python-3.13.5.tgz \
&& cd Python-3.13.5 \
&& ./configure --disable-gil --enable-optimizations --with-lto --enable-shared \
&& make -j"$(nproc)" \
&& make altinstall \
&& cd .. \
&& rm -rf Python-3.13.5*
# Fix shared library search path so libpython3.13t.so.1.0 can be found
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/python3.13.conf \
&& ldconfig
# Copy requirements and install them
COPY requirements.txt .
RUN pip3.13 install --no-cache-dir -r requirements.txt gunicorn
# Non-root user setup
RUN addgroup --system app && adduser --system --ingroup app app
# Create upload directory
RUN mkdir -p /app/temporary_uploads \
&& chown -R app:app /app/temporary_uploads
# Copy app source code
COPY --chown=app:app . .
# Switch to non-root user
USER app
# Expose port
EXPOSE 8080
# Start the app with Gunicorn (single worker for stability)
ENV PYTHON_GIL=0
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]