fix dockerfile

main
Cizz22 10 months ago
parent 319f3ea99c
commit 4972734d30

@ -19,28 +19,26 @@ COPY pyproject.toml poetry.lock ./
# Install dependencies # Install dependencies
RUN poetry install --no-root RUN poetry install --no-root
# Use Google's distroless Python image for runtime # Use a new slim image for the runtime
FROM gcr.io/distroless/python3:3.11 as runtime FROM python:3.11-slim as runtime
# Copy Poetry virtual environment from builder # Install necessary tools for running the app, including `make`
COPY --from=builder /app/.venv /app/.venv RUN apt-get update && apt-get install -y --no-install-recommends \
make \
# Set environment variables for Python && rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH" \
PYTHONPATH="/app"
# Copy only necessary application files # Set environment variables for Poetry
COPY --chown=nonroot:nonroot . /app/ ENV POETRY_VIRTUALENVS_IN_PROJECT=1 \
PATH="/app/.venv/bin:$PATH"
# Delete Tests for production # Copy Poetry installation from builder
RUN ["rm", "-rf", "/app/tests/"] COPY --from=builder /app/.venv /app/.venv
# Create a directory for any necessary data with proper permissions # Copy application files
RUN ["mkdir", "-p", "/app/data"] COPY . /app/
# Switch to non-root user # Delete Tests for production
USER nonroot RUN rm -rf /app/tests/
# Expose port for the application # Expose port for the application
EXPOSE 3000 EXPOSE 3000
@ -48,6 +46,5 @@ EXPOSE 3000
# Set the working directory # Set the working directory
WORKDIR /app WORKDIR /app
# Run the application directly instead of using make # Run `make run` as the entry point
# Assuming your application is started with python -m app.main or similar CMD ["make", "run"]
CMD ["python", "-m", "app.main"]

Loading…
Cancel
Save