mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
chore: update Dockerfile for learnhouse-api
This commit is contained in:
parent
85709e9040
commit
3be642be6c
1 changed files with 24 additions and 21 deletions
|
|
@ -1,28 +1,31 @@
|
|||
#
|
||||
FROM python:3.12.3
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.12.3-slim
|
||||
|
||||
# poetry
|
||||
RUN pip install poetry
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=off \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=on
|
||||
|
||||
#
|
||||
WORKDIR /usr/learnhouse/apps/api
|
||||
# Set work directory
|
||||
WORKDIR /usr/learnhouse-api
|
||||
|
||||
# Copy poetry.lock* in case it doesn't exist in the repo
|
||||
COPY ./poetry.lock* /usr/learnhouse/
|
||||
|
||||
# Copy project requirement files here to ensure they will be cached.
|
||||
COPY pyproject.toml /usr/learnhouse/
|
||||
|
||||
# Install poetry
|
||||
RUN pip install --upgrade pip \
|
||||
&& pip install poetry \
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir poetry \
|
||||
&& poetry config virtualenvs.create false
|
||||
|
||||
# Install project dependencies.
|
||||
RUN poetry install --no-interaction --no-ansi
|
||||
# Copy only requirements to cache them in docker layer
|
||||
COPY poetry.lock pyproject.toml ./
|
||||
|
||||
#
|
||||
COPY ./ /usr/learnhouse
|
||||
# Install dependencies
|
||||
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"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue