mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
Merge pull request #298 from learnhouse/fix/api-dockerfile-image
Fix Dockerfile for learnhouse-api
This commit is contained in:
commit
0f2b8689c4
1 changed files with 24 additions and 21 deletions
|
|
@ -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
|
||||||
CMD ["python" , "app.py"]
|
COPY . .
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
CMD ["python", "app.py"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue