-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.observer
More file actions
41 lines (31 loc) · 1.21 KB
/
Copy pathDockerfile.observer
File metadata and controls
41 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# docker build -f Dockerfile.server -t observer .
# docker run -d --name observer -e ENVIRONMENT=production observer
FROM --platform=linux/amd64 python:3.12-slim
ENV APP_NAME observer
ENV WORKDIR /app
ENV PYTHONPATH ${WORKDIR}/src
ENV PYTHONUNBUFFERED 1
WORKDIR ${WORKDIR}
EXPOSE 80
# System update
RUN apt-get update && \
apt-get install -y --no-install-recommends netcat-openbsd curl git wget bash ssh git openssh-client && \
rm -rf /var/lib/apt/lists/* /var/tmp/*
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create true && \
poetry config virtualenvs.path --unset && \
poetry config virtualenvs.in-project true
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml ./poetry.lock* ./
ARG INSTALL_DEV=false
RUN poetry lock --no-update && \
bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
COPY . ./
RUN poetry run pip install "fastapi[standard]"
CMD ["/bin/bash", "-c", \
"poetry run fastapi run \
src/${APP_NAME}/api/app.py \
--port 80"]