Skip to content

Commit 8377146

Browse files
Update Dockerfile
1 parent 5998d8a commit 8377146

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
FROM python:3.11-slim
22

3+
# Default UID and GID (can be overridden)
4+
ARG USER_UID=1000
5+
ARG USER_GID=1000
6+
37
WORKDIR /app
48

5-
# Install system dependencies
9+
# Install system dependencies and create user
610
RUN apt-get update && apt-get install -y \
711
gcc \
8-
&& rm -rf /var/lib/apt/lists/*
12+
gosu \
13+
&& rm -rf /var/lib/apt/lists/* \
14+
&& groupadd -g ${USER_GID} appuser \
15+
&& useradd -m -u ${USER_UID} -g appuser appuser
916

1017
# Copy requirements first for better caching
1118
COPY requirements.txt .
1219
RUN pip install --no-cache-dir -r requirements.txt
1320

1421
# Copy application code
15-
COPY . .
22+
COPY --chown=appuser:appuser . .
1623

17-
# Create volume for database
24+
# Create volume for database with proper permissions
25+
RUN mkdir -p /app/data && chown -R appuser:appuser /app/data
1826
VOLUME ["/app/data"]
1927

2028
# Set environment variables
2129
ENV FLASK_APP=app.main:create_app
2230
ENV PYTHONUNBUFFERED=1
31+
ENV USER_UID=${USER_UID}
32+
ENV USER_GID=${USER_GID}
33+
34+
# Copy and set permissions for entrypoint script
35+
COPY docker-entrypoint.sh /usr/local/bin/
36+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
2337

2438
EXPOSE 5000
2539

40+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
2641
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--threads", "4", "app.main:create_app()"]

0 commit comments

Comments
 (0)