-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
75 lines (58 loc) · 2.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -----------------------------------------------------------------------------
# This stage builds the build container.
# -----------------------------------------------------------------------------
FROM python:3.13.1-alpine3.20 AS build
# Install compiler toolchain and libraries.
RUN apk add --no-cache build-base libffi-dev libressl-dev
# Install Rust for cryptography
RUN apk add --no-cache python3-dev rust cargo
# Paths
ARG IMS_SOURCE_DIR="/src/ims"
ARG IMS_INSTALL_DIR="/opt/ims"
# Copy the source code over
WORKDIR "${IMS_SOURCE_DIR}"
COPY ./COPYRIGHT.txt ./
COPY ./LICENSE.txt ./
COPY ./MANIFEST.in ./
COPY ./pyproject.toml ./
COPY ./README.rst ./
COPY ./src/ ./src/
COPY ./uv.lock ./
# Install the application
WORKDIR /tmp
RUN install -o daemon -g daemon -d "${IMS_INSTALL_DIR}"
RUN pip install --no-cache-dir --upgrade pip uv
RUN uv venv "${IMS_INSTALL_DIR}"
RUN uv pip --no-progress install \
--python="${IMS_INSTALL_DIR}/bin/python" \
--no-cache --exact --compile-bytecode \
"${IMS_SOURCE_DIR}"
# -----------------------------------------------------------------------------
# This stage builds the application container.
# -----------------------------------------------------------------------------
FROM python:3.13.1-alpine3.20 AS application
# Paths
ARG IMS_INSTALL_DIR="/opt/ims"
ARG IMS_SERVER_ROOT="/srv/ims"
# Docker-specific default configuration
ENV IMS_HOSTNAME="0.0.0.0"
ENV IMS_CONFIG_ROOT="${IMS_INSTALL_DIR}/conf"
ENV IMS_SERVER_ROOT="${IMS_SERVER_ROOT}"
ENV IMS_DATA_STORE="MySQL"
ENV IMS_DIRECTORY="ClubhouseDB"
# Install libraries.
RUN apk add --no-cache libressl
# Allow Python to bind to privileged port numbers
RUN apk add --no-cache libcap
RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/python3.13
# Create server root and make that our working directory
RUN install -o daemon -g daemon -d "${IMS_SERVER_ROOT}"
# Copy build result
COPY --from=build "${IMS_INSTALL_DIR}" "${IMS_INSTALL_DIR}"
# Set user and default working directory
USER daemon:daemon
WORKDIR "${IMS_SERVER_ROOT}"
# Expose service port
EXPOSE 80
# Default command
CMD [ "/opt/ims/bin/ims", "--log-file", "-", "server" ]