-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (38 loc) · 1.42 KB
/
Dockerfile
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
56
##### Stage 'base' - Base image #####
FROM python:3.12.2-slim AS base
# Update Ubuntu repos and install required dependencies
RUN apt-get update -y && \
apt-get install -y openssl && \
python3 -m pip install --upgrade pip
##### Stage 'builder' - Build wheel #####
FROM base AS builder
ENV POETRY_HOME=/opt/poetry \
POETRY_NO_INTERACTION=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
ENV PATH="${PATH}:${POETRY_HOME}/bin"
# Create directory for build artifacts
RUN mkdir -p /build
# Install poetry
ADD https://install.python-poetry.org install_poetry.py
RUN python3 install_poetry.py
# Copy source code
WORKDIR /app/src
COPY . .
# Create a blank Readme file for poetry build
RUN touch README.md
# Build package wheel
RUN poetry check && \
poetry build -f wheel -o /build/dist/
##### Stage 'server' - Build application #####
FROM base AS server
LABEL maintainer="Narayan Bandodker <narayanband1356@gmail.com>"
# Install dumb-init and cURL
RUN apt-get install -y dumb-init curl
WORKDIR /app
# Copy build files from previous stage
COPY --from=builder /build .
# Copy entrypoint script
COPY ./docker-scripts/entrypoint.sh ./docker-scripts/dependencies.sh ./docker-scripts/requirements.txt ./
RUN chmod +x ./entrypoint.sh ./dependencies.sh
ENTRYPOINT ["./entrypoint.sh"]
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=20 CMD curl --include --request GET http://localhost:8000/health/healthcheck || exit 1