-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (44 loc) · 1.34 KB
/
Dockerfile
File metadata and controls
59 lines (44 loc) · 1.34 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
56
57
58
59
# base image
FROM python:3.10-slim-bookworm AS base
WORKDIR /apps/app
# set env variables
ENV PYTHONUNBUFFERED=1 \
# set pip to disable version check
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# Poetry config
POETRY_VERSION=1.6.1 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_VIRTUALENVS_CREATE=true
# install poetry
RUN pip install --no-cache-dir poetry==${POETRY_VERSION}
# builder image
FROM base AS builder
# install system dependencies
RUN apt-get update && \
apt-get install -y apt-transport-https gnupg ca-certificates build-essential git nano curl
COPY pyproject.toml poetry.lock ./
# install dependencies
RUN --mount=type=cache,target=/root/.cache \
poetry install --no-root --only main
# production image
FROM base AS production
# expose port
EXPOSE 8000
# set timezone to UTC
ENV TZ=UTC
# set work directory
WORKDIR /app
# copy code to work dir
COPY . /app/websocket-chatroom
# Copy Python environment and packages
ENV VIRTUAL_ENV=/apps/app/.venv
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
# copy entrypoint.sh
COPY docker/entrypoint.sh /entrypoint.sh
# add execute permission to entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
# run entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]