mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 17:46:53 +00:00
Added non-root user creation** (`appuser` with UID/GID 1000) - **Set proper file ownership** for all application directories - **Switched container execution** to non-root user with `USER appuser` - **Fixed permission issues** for static files directory
56 lines
1.5 KiB
Docker
56 lines
1.5 KiB
Docker
FROM python:3.10
|
|
|
|
# Create non-root user
|
|
RUN groupadd --gid 1000 appuser \
|
|
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
postgresql-client \
|
|
python3-tk \
|
|
tk \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Python dependencies
|
|
COPY requirements.txt /app/
|
|
RUN pip install --upgrade pip \
|
|
&& pip install -r requirements.txt \
|
|
&& pip install dj-database-url
|
|
|
|
# Copy project files explicitly
|
|
COPY requirements.txt /app/
|
|
COPY apimanager/ /app/apimanager/
|
|
COPY static/ /app/static/
|
|
COPY demo/ /app/demo/
|
|
COPY gunicorn.conf.py /app/
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/logs /app/static /app/db /static-collected
|
|
|
|
# Copy development local settings directly to the correct location
|
|
COPY development/local_settings_dev.py /app/apimanager/apimanager/local_settings.py
|
|
# Copy entrypoint script to /usr/local/bin
|
|
COPY development/docker-entrypoint-dev.sh /usr/local/bin/docker-entrypoint-dev.sh
|
|
|
|
# Set proper permissions and ownership
|
|
RUN chmod +x /app/apimanager/manage.py /usr/local/bin/docker-entrypoint-dev.sh \
|
|
&& chown -R appuser:appuser /app \
|
|
&& chown -R appuser:appuser /static-collected
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Use entrypoint script
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-dev.sh"]
|