Skip to content

Commit bdb468f

Browse files
committed
CI: Fix OCI image builds for mqttwarn-full
1 parent fe2a90d commit bdb468f

File tree

2 files changed

+57
-18
lines changed

2 files changed

+57
-18
lines changed

Dockerfile

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
# Docker build file for mqttwarn.
2-
# Based on https://github.com/pfichtner/docker-mqttwarn.
1+
# Docker build file for `mqttwarn-standard`.
32
#
43
# Invoke like:
54
#
6-
# docker build --tag=mqttwarn-local .
5+
# docker build --tag=local/mqttwarn-standard --file=Dockerfile .
76
#
87
FROM python:3.11-slim-bullseye
98

10-
# Install additional requirements
11-
RUN apt-get update && apt-get install --yes git
9+
10+
# =====
11+
# Build
12+
# =====
13+
14+
# Install build prerequisites.
15+
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
16+
RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt --mount=type=cache,id=apt-lib,target=/var/lib/apt \
17+
true \
18+
&& apt-get update \
19+
&& apt-get install --no-install-recommends --no-install-suggests --yes git build-essential librrd-dev
1220

1321
# Create /etc/mqttwarn
1422
RUN mkdir -p /etc/mqttwarn
@@ -18,10 +26,23 @@ WORKDIR /etc/mqttwarn
1826
RUN groupadd -r mqttwarn && useradd -r -g mqttwarn mqttwarn
1927
RUN chown -R mqttwarn:mqttwarn /etc/mqttwarn
2028

21-
# Install mqttwarn
29+
# Install package.
2230
COPY . /src
23-
RUN pip install versioningit wheel
24-
RUN pip install /src
31+
RUN --mount=type=cache,id=pip,target=/root/.cache/pip \
32+
true \
33+
&& pip install --prefer-binary versioningit wheel \
34+
&& pip install --use-pep517 --prefer-binary '/src'
35+
36+
# Uninstall build prerequisites again.
37+
RUN apt-get --yes remove --purge git && apt-get --yes autoremove
38+
39+
# Purge /src and /tmp directories.
40+
RUN rm -rf /src /tmp/*
41+
42+
43+
# =======
44+
# Runtime
45+
# =======
2546

2647
# Make process run as "mqttwarn" user
2748
USER mqttwarn

Dockerfile.full

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
# Docker build file for mqttwarn.
2-
# Based on https://github.com/pfichtner/docker-mqttwarn.
1+
# Docker build file for `mqttwarn-full`.
32
#
43
# Invoke like:
54
#
6-
# docker build --tag=mqttwarn-local-full --file=Dockerfile.full .
5+
# docker build --tag=local/mqttwarn-full --file=Dockerfile.full .
76
#
87
FROM python:3.11-slim-bullseye
98

10-
# Install additional requirements
11-
RUN apt-get update && apt-get install --yes git
129

13-
# FIXME: Skip all packages needing compilation
14-
#RUN apt-get update && apt-get install --yes librrd-dev
10+
# =====
11+
# Build
12+
# =====
13+
14+
# Install build prerequisites.
15+
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
16+
RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt --mount=type=cache,id=apt-lib,target=/var/lib/apt \
17+
true \
18+
&& apt-get update \
19+
&& apt-get install --no-install-recommends --no-install-suggests --yes git build-essential librrd-dev
1520

1621
# Create /etc/mqttwarn
1722
RUN mkdir -p /etc/mqttwarn
@@ -21,10 +26,23 @@ WORKDIR /etc/mqttwarn
2126
RUN groupadd -r mqttwarn && useradd -r -g mqttwarn mqttwarn
2227
RUN chown -R mqttwarn:mqttwarn /etc/mqttwarn
2328

24-
# Install mqttwarn
29+
# Install package.
2530
COPY . /src
26-
RUN pip install versioningit wheel
27-
RUN pip install /src[all]
31+
RUN --mount=type=cache,id=pip,target=/root/.cache/pip \
32+
true \
33+
&& pip install --prefer-binary versioningit wheel \
34+
&& pip install --use-pep517 --prefer-binary '/src[all]'
35+
36+
# Uninstall build prerequisites again.
37+
RUN apt-get --yes remove --purge git build-essential && apt-get --yes autoremove
38+
39+
# Purge /src and /tmp directories.
40+
RUN rm -rf /src /tmp/*
41+
42+
43+
# =======
44+
# Runtime
45+
# =======
2846

2947
# Make process run as "mqttwarn" user
3048
USER mqttwarn

0 commit comments

Comments
 (0)