eventinvite / Dockerfile
ichieh
Improve data persistence with proper directory permissions
1335c94
Raw History Blame Contribute Delete
948 Bytes
FROM python:3.11-slim
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Create data directory with correct permissions
RUN mkdir -p /data && \
chmod -R 777 /data && \
chown -R 1000:1000 /data
# Copy the rest of the application
COPY . /code/
# Set code directory permissions
RUN chmod -R 777 /code && \
chown -R 1000:1000 /code
# Create instance directory with correct permissions
RUN mkdir -p /code/instance && \
chmod -R 777 /code/instance && \
chown -R 1000:1000 /code/instance
# Switch to non-root user
USER 1000:1000
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Run the application with proper permissions
CMD ["python", "app.py"]