fooder-api/Dockerfile

33 lines
753 B
Docker
Raw Normal View History

2023-09-03 16:04:13 +02:00
# builder
FROM python:3.11.5-bullseye as builder
RUN mkdir /opt/fooder
WORKDIR /opt/fooder
RUN pip install setuptools
COPY fooder /opt/fooder/fooder
COPY setup.py /opt/fooder/setup.py
RUN python /opt/fooder/setup.py sdist
RUN mv /opt/fooder/dist/FooderApi*.tar.gz /opt/fooder/dist/fooder.tar.gz
# final image
FROM python:3.11.5-bullseye
2023-04-01 16:19:12 +02:00
2023-04-01 16:24:51 +02:00
RUN apt-get -y install libpq-dev
2023-04-01 16:19:12 +02:00
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
2023-09-03 16:04:13 +02:00
RUN useradd fooder
RUN mkdir /opt/fooder && chown fooder:fooder /opt/fooder
2023-04-01 16:19:12 +02:00
WORKDIR /opt/fooder
2023-09-03 16:04:13 +02:00
COPY --from=builder /opt/fooder/dist/fooder.tar.gz /opt/fooder/fooder.tar.gz
RUN pip install fooder.tar.gz
RUN rm fooder.tar.gz
2023-04-01 16:19:12 +02:00
CMD ["uvicorn", "fooder.app:app", "--host", "0.0.0.0", "--port", "8000"]