-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM python:3.10-slim-bookworm | ||
# Builder stage | ||
FROM python:3.10-slim-bookworm as builder | ||
|
||
ENV POETRY_VERSION=1.6 \ | ||
POETRY_VIRTUALENVS_CREATE=false | ||
ENV POETRY_VERSION=1.6 | ||
|
||
# Install poetry | ||
# Install dependencies | ||
RUN pip install "poetry==$POETRY_VERSION" | ||
|
||
# Copy only requirements to cache them in docker layer | ||
WORKDIR /code | ||
COPY poetry.lock pyproject.toml /code/ | ||
|
||
# Project initialization: | ||
RUN poetry install --no-interaction --no-ansi --no-root --no-dev | ||
# Install dependencies in a virtual environment | ||
RUN poetry config virtualenvs.create true \ | ||
&& poetry install --no-interaction --no-ansi --no-root --no-dev \ | ||
&& poetry export -f requirements.txt > requirements.txt | ||
|
||
# Copy Python code to the Docker image | ||
COPY pypi_scout /code/pypi_scout/ | ||
# Final stage | ||
FROM python:3.10-slim-bookworm | ||
|
||
ENV PYTHONPATH=/code | ||
WORKDIR /code | ||
|
||
# Install dependencies | ||
COPY --from=builder /code/requirements.txt /code/requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt \ | ||
&& rm -rf /root/.cache/pip | ||
|
||
# Copy the start script and make executable | ||
# Copy only necessary files | ||
COPY pypi_scout /code/pypi_scout/ | ||
COPY start.sh /start.sh | ||
RUN chmod +x /start.sh | ||
|
||
# Make empty data directory | ||
RUN chmod +x /start.sh | ||
RUN mkdir -p /code/data | ||
|
||
# Use the script as the entrypoint | ||
ENV PYTHONPATH=/code | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["/start.sh"] |