-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (40 loc) · 1.5 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (40 loc) · 1.5 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM python:3.11-slim as python-base
# https://python-poetry.org/docs#ci-recommendations
ENV POETRY_VERSION=1.6.1
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
# Tell Poetry where to place its cache and virtual environment
ENV POETRY_CACHE_DIR=/opt/.cache
# Create stage for Poetry installation
FROM python-base as poetry-base
# Creating a virtual environment just for poetry and install it with pip
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
# Add Poetry to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"
# Create a new stage from the base python image
FROM python-base as rulesbot-app
# Add psycopg2
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libpq-dev
# Copy Poetry to app image
COPY --from=poetry-base ${POETRY_VENV} ${POETRY_VENV}
# Add Poetry to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"
# Set working directory
WORKDIR /app
# Copy Application
COPY . /app
# [OPTIONAL] Validate the project is properly configured
RUN poetry check
# Install Dependencies
RUN poetry install --no-interaction --no-cache --without dev
# Entrypoint prepares the database.
ENTRYPOINT ["/app/bin/docker-entrypoint"]
# Run Application
EXPOSE 5000
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/up/', timeout=3)" || exit 1
CMD [ "poetry", "run", "honcho", "start", "web" ]