38 lines
855 B
Docker
38 lines
855 B
Docker
# build stage
|
|
FROM python:3.11 AS builder
|
|
|
|
# install PDM
|
|
RUN pip install -U pip setuptools wheel
|
|
RUN pip install pdm
|
|
|
|
# copy files
|
|
COPY pyproject.toml pdm.lock README.md /backend/
|
|
COPY install.sh /backend/
|
|
COPY src/ /backend/src
|
|
|
|
# import ENV
|
|
ARG ENV
|
|
|
|
# install dependencies and project into the local packages directory
|
|
WORKDIR /backend
|
|
RUN mkdir __pypackages__ && chmod u+x install.sh && ./install.sh
|
|
|
|
# run stage
|
|
FROM python:3.11
|
|
|
|
# retrieve packages from build stage
|
|
ENV PYTHONPATH=/backend/pkgs
|
|
COPY --from=builder /backend/__pypackages__/3.11/lib /backend/pkgs
|
|
|
|
# set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
# retrieve executables
|
|
COPY --from=builder /backend/__pypackages__/3.11/bin/* /bin/
|
|
|
|
EXPOSE 8080
|
|
|
|
# set command/entrypoint, adapt to fit your needs
|
|
CMD ["python3","-m", "uvicorn", "neo_neo_todo.main:app"]
|