mirror_frr/docker/alpine/Dockerfile
Donatas Abraitis 3f7cc3b7f5 docker: Do not use pip Python package manager
Alpine Linux gets this with 3.19:

This is already installed with `pytest` via apk package manager.

```
15 78.20 error: externally-managed-environment
15 78.20
15 78.20 × This environment is externally managed
15 78.20 ╰─>
15 78.20     The system-wide python installation should be maintained using the system
15 78.20     package manager (apk) only.
15 78.20
15 78.20     If the package in question is not packaged already (and hence installable via
15 78.20     "apk add py3-somepackage"), please consider installing it inside a virtual
15 78.20     environment, e.g.:
15 78.20
15 78.20     python3 -m venv /path/to/venv
15 78.20     . /path/to/venv/bin/activate
15 78.20     pip install mypackage
15 78.20
15 78.20     To exit the virtual environment, run:
15 78.20
15 78.20     deactivate
15 78.20
15 78.20     The virtual environment is not deleted, and can be re-entered by re-sourcing
15 78.20     the activate file.
15 78.20
15 78.20     To automatically manage virtual environments, consider using pipx (from the
15 78.20     pipx package).
15 78.20
15 78.20 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-09 09:33:40 +02:00

82 lines
2.2 KiB
Docker

# syntax=docker/dockerfile:1
# Create a basic stage set up to build APKs
FROM alpine:3.19 as alpine-builder
RUN apk add \
--update-cache \
abuild \
alpine-conf \
alpine-sdk \
&& setup-apkcache /var/cache/apk \
&& mkdir -p /pkgs/apk \
&& echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN adduser -D -G abuild builder && su builder -c 'abuild-keygen -a -n'
# This stage builds an APK for libyang
FROM alpine-builder as alpine-apk-builder-libyang
RUN mkdir -p /src/libyang
COPY docker/alpine/libyang/APKBUILD /src/libyang
RUN chown -R builder /pkgs /src
USER builder
RUN cd /src/libyang \
&& abuild checksum \
&& git init \
&& abuild -r -P /pkgs/apk
# This stage builds a dist tarball from the source
FROM alpine:3.19 as source-builder
RUN mkdir -p /src/alpine /pkgs/apk
COPY alpine/APKBUILD.in /src/alpine
COPY --from=alpine-apk-builder-libyang /pkgs/apk/src /pkgs/apk
RUN cd /pkgs/apk && apk add --allow-untrusted */*.apk
RUN source /src/alpine/APKBUILD.in \
&& apk add \
--no-cache \
--update-cache \
$makedepends
COPY . /src
ARG PKGVER
RUN cd /src \
&& ./bootstrap.sh \
&& ./configure \
--enable-numeric-version \
--with-pkg-extra-version="_git$PKGVER" \
&& make dist
# This stage builds an APK from the dist tarball
FROM alpine-builder as alpine-apk-builder
COPY --from=source-builder /src/frr-*.tar.gz /src/alpine/* /dist/
COPY --from=alpine-apk-builder-libyang /pkgs/apk/src /pkgs/apk
RUN cd /pkgs/apk && apk add --allow-untrusted */*.apk
RUN find /pkgs/apk -type f -name APKINDEX.tar.gz -delete
RUN chown -R builder /dist /pkgs
USER builder
RUN cd /dist \
&& abuild checksum \
&& git init \
&& abuild -r -P /pkgs/apk
# This stage installs frr from the apk
FROM alpine:3.19
RUN mkdir -p /pkgs/apk
COPY --from=alpine-apk-builder /pkgs/apk/ /pkgs/apk/
RUN apk add \
--no-cache \
--update-cache \
tini \
&& apk add \
--no-cache \
--allow-untrusted /pkgs/apk/*/*.apk \
&& rm -rf /pkgs
# Own the config / PID files
RUN mkdir -p /var/run/frr
RUN chown -R frr:frr /etc/frr /var/run/frr
# Simple init manager for reaping processes and forwarding signals
ENTRYPOINT ["/sbin/tini", "--"]
# Default CMD starts watchfrr
COPY docker/alpine/docker-start /usr/lib/frr/docker-start
CMD ["/usr/lib/frr/docker-start"]