chore: update Dockerfile for learnhouse-api

This commit is contained in:
swve 2024-08-13 00:19:10 +02:00
parent 85709e9040
commit 3be642be6c

View file

@ -1,28 +1,31 @@
# # Use an official Python runtime as a parent image
FROM python:3.12.3 FROM python:3.12.3-slim
# poetry # Set environment variables
RUN pip install poetry ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on
# # Set work directory
WORKDIR /usr/learnhouse/apps/api WORKDIR /usr/learnhouse-api
# Copy poetry.lock* in case it doesn't exist in the repo # Install system dependencies and Poetry
COPY ./poetry.lock* /usr/learnhouse/ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
# Copy project requirement files here to ensure they will be cached. build-essential \
COPY pyproject.toml /usr/learnhouse/ && rm -rf /var/lib/apt/lists/* \
&& pip install --no-cache-dir poetry \
# Install poetry
RUN pip install --upgrade pip \
&& pip install poetry \
&& poetry config virtualenvs.create false && poetry config virtualenvs.create false
# Install project dependencies. # Copy only requirements to cache them in docker layer
RUN poetry install --no-interaction --no-ansi COPY poetry.lock pyproject.toml ./
# # Install dependencies
COPY ./ /usr/learnhouse RUN poetry install --no-interaction --no-ansi --no-root --only main
# # Copy the current directory contents into the container
COPY . .
# Run the application
CMD ["python", "app.py"] CMD ["python", "app.py"]