-
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.73 KB
/
Dockerfile
File metadata and controls
66 lines (54 loc) · 1.73 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
FROM python:3.14-slim
# Set environment variables to prevent interactive prompts and optimize Python
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PUID=1000 \
PGID=1000
# Install system dependencies including build tools for Python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
zip \
unzip \
cron \
gosu \
gcc \
g++ \
make \
libffi-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/*
# Create app directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies with optimizations
RUN pip install --upgrade pip setuptools wheel && \
pip install --no-cache-dir --disable-pip-version-check \
-r requirements.txt
# Copy application code
COPY . .
# Create necessary directories and set permissions in one layer
RUN mkdir -p /app/backups /app/logs /app/data && \
chmod +x start.sh && \
chmod +x entrypoint.sh
# Create user with configurable UID/GID
RUN groupadd -g ${PGID} appuser && \
useradd -u ${PUID} -g ${PGID} -m -s /bin/bash appuser && \
chown -R appuser:appuser /app
# Switch back to root for entrypoint (needed for user/group modifications)
USER root
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Set entrypoint and default command
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["./start.sh"]