Refactor Docker CI workflow for improved structure #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Start from a Python base image | ||
| FROM python:3.10-slim | ||
| # Set environment variables | ||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
| # Install system dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| redis-server \ | ||
| libmagic1 \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Create a non-root user and group | ||
| RUN addgroup --system omnipkg && adduser --system --ingroup omnipkg omnipkg | ||
| # Set the working directory | ||
| WORKDIR /home/omnipkg | ||
| # Copy project files (including src/) BEFORE installing | ||
| COPY --chown=omnipkg:omnipkg pyproject.toml poetry.lock* ./ | ||
| COPY --chown=omnipkg:omnipkg src/ ./src/ | ||
| COPY --chown=omnipkg:omnipkg README.md ./ | ||
| # Install Python dependencies | ||
| RUN pip install --no-cache-dir . | ||
| # Copy the entrypoint script | ||
| COPY --chown=omnipkg:omnipkg docker-entrypoint.sh ./ | ||
| RUN chmod +x /home/omnipkg/docker-entrypoint.sh | ||
| # Create directories for omnipkg data BEFORE switching user | ||
| RUN mkdir -p /home/omnipkg/.omnipkg && \ | ||
| chown -R omnipkg:omnipkg /home/omnipkg | ||
| # NOW switch to non-root user | ||
| USER omnipkg | ||
| # Expose Redis port (in case external access needed) | ||
| EXPOSE 6379 | ||
| # Expose the application port | ||
| EXPOSE 8000 | ||
| # Specify the entrypoint script | ||
| ENTRYPOINT ["/home/omnipkg/docker-entrypoint.sh"] | ||