-
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathdockerfile
More file actions
77 lines (62 loc) · 2.1 KB
/
dockerfile
File metadata and controls
77 lines (62 loc) · 2.1 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM python:3.12-slim-bookworm
ARG PACKAGE_VERSION=1.0.5
ARG USER=repeater
ARG GROUP=repeater
ARG PUID=15888
ARG PGID=15888
ARG TARGETARCH
ARG YQ_VERSION=v4.40.5
ENV INSTALL_DIR=/opt/pymc_repeater \
CONFIG_DIR=/etc/pymc_repeater \
DATA_DIR=/var/lib/pymc_repeater \
HOME_DIR=/home/${USER} \
PATH=/home/${USER}/.local/bin:${PATH} \
PYTHONUNBUFFERED=1 \
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYMC_REPEATER=${PACKAGE_VERSION} \
PUID=${PUID} \
PGID=${PGID}
# Install runtime dependencies only
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
libffi-dev \
python3-rrdtool \
jq \
wget \
libusb-1.0-0 \
swig \
git \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN arch="${TARGETARCH:-}" \
&& if [ -z "${arch}" ]; then arch="$(uname -m)"; fi \
&& case "${arch}" in \
amd64|x86_64) YQ_BINARY="yq_linux_amd64" ;; \
arm64|aarch64) YQ_BINARY="yq_linux_arm64" ;; \
arm|armv7|armv7l) YQ_BINARY="yq_linux_arm" ;; \
*) echo "Unsupported architecture for yq: ${arch}" >&2; exit 1 ;; \
esac \
&& wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}" \
&& chmod +x /usr/local/bin/yq
# Create the group and user in order to run without root privileges
RUN groupadd --gid "$PGID" "$GROUP" \
&& useradd --uid "$PUID" --gid "$PGID" --home-dir "$HOME_DIR" --create-home --shell /usr/bin/bash "$USER"
# Create runtime directories
RUN mkdir -p ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} \
&& chown -R "$USER":"$GROUP" ${INSTALL_DIR} ${CONFIG_DIR} ${DATA_DIR} ${HOME_DIR}
WORKDIR ${INSTALL_DIR}
# Copy source
COPY repeater ./repeater
COPY pyproject.toml .
COPY config.yaml.example .
COPY radio-presets.json .
COPY radio-settings.json .
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Switch to the unprivileged runtime user
USER ${USER}
# Install package
RUN pip install --no-cache-dir .
USER root
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
USER ${USER}
EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]