|
1 | | -# No specific reason for this image. Should probably change it at some point |
2 | | -# Same CVEs as debian because they don't do patches |
3 | | - |
4 | | -FROM bitnami/minideb:bookworm |
5 | | -ARG APP_UID=1000 \ |
6 | | - APP_GID=1000 |
7 | | - |
8 | | -USER root |
9 | | - |
10 | | -# Copied from https://ooni.org/install/cli/ubuntu-debian/ |
11 | | - |
12 | | -RUN set -ex; \ |
13 | | - apt update && apt install -y ca-certificates curl \ |
14 | | - && install -m 0755 -d /etc/apt/keyrings \ |
15 | | - && curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xb5a08f01796e7f521861b449372d1ff271f2dd50" -o /etc/apt/keyrings/ooni-apt-keyring.asc \ |
16 | | - && chmod a+r /etc/apt/keyrings/ooni-apt-keyring.asc \ |
17 | | - && echo "deb [signed-by=/etc/apt/keyrings/ooni-apt-keyring.asc] https://deb.ooni.org/ unstable main" | tee /etc/apt/sources.list.d/ooniprobe.list \ |
18 | | - && apt update \ |
19 | | - && apt install -y ooniprobe-cli \ |
20 | | - && apt clean \ |
21 | | - && rm -rf /var/lib/apt/lists/* |
22 | | - |
23 | | -# Something about openshift not liking fixed UIDs, idk |
24 | | -USER ${APP_UID}:${APP_GID} |
25 | | -ENTRYPOINT [ "/usr/bin/ooniprobe", "run", "unattended" ] |
| 1 | +# ╔═════════════════════════════════════════════════════╗ |
| 2 | +# ║ SETUP ║ |
| 3 | +# ╚═════════════════════════════════════════════════════╝ |
| 4 | + # GLOBAL |
| 5 | + ARG APP_UID=1000 \ |
| 6 | + APP_GID=1000 |
| 7 | + |
| 8 | + # FOREIGN IMAGES |
| 9 | + FROM 11notes/distroless AS distroless |
| 10 | +# FROM 11notes/distroless:dnslookup AS distroless-dnslookup |
| 11 | + FROM 11notes/util:bin AS util-bin |
| 12 | + |
| 13 | +# ╔═════════════════════════════════════════════════════╗ |
| 14 | +# ║ BUILD ║ |
| 15 | +# ╚═════════════════════════════════════════════════════╝ |
| 16 | + |
| 17 | + FROM golang:1.23.7-alpine AS build |
| 18 | + COPY --from=util-bin / / |
| 19 | + ARG APP_VERSION=3.26 \ |
| 20 | + BUILD_ROOT \ |
| 21 | + BUILD_BIN \ |
| 22 | + TARGETARCH=amd64 \ |
| 23 | + TARGETPLATFORM \ |
| 24 | + TARGETVARIANT \ |
| 25 | + BUILD_DIR=/go/probe-cli \ |
| 26 | + CGO_ENABLED=0 |
| 27 | + |
| 28 | + ENV BUILD_BIN=${BUILD_DIR}/probe-cli/CLI/ooniprobe-linux-${TARGETARCH} |
| 29 | + |
| 30 | + |
| 31 | + RUN set -ex; \ |
| 32 | + apk --update --no-cache add \ |
| 33 | + curl \ |
| 34 | + wget \ |
| 35 | + unzip \ |
| 36 | + build-base \ |
| 37 | + linux-headers \ |
| 38 | + make \ |
| 39 | + cmake \ |
| 40 | + g++ \ |
| 41 | + git \ |
| 42 | + npm \ |
| 43 | + gpg \ |
| 44 | + zip \ |
| 45 | + tar \ |
| 46 | + yarn; |
| 47 | + |
| 48 | + RUN set -ex; \ |
| 49 | + mkdir ${BUILD_DIR}; \ |
| 50 | + cd ${BUILD_DIR}; \ |
| 51 | + git clone https://github.com/ooni/probe-cli.git -b release/${APP_VERSION}; \ |
| 52 | + cd probe-cli; \ |
| 53 | + go run ./internal/cmd/buildtool linux static |
| 54 | + |
| 55 | + RUN set -ex; \ |
| 56 | + eleven distroless ${BUILD_BIN}; |
| 57 | + # compress and copy. https://github.com/11notes/docker-util/blob/master/rootfs/usr/local/bin/.eleven/distroless |
| 58 | + |
| 59 | +# :: FILE SYSTEM |
| 60 | + FROM alpine AS file-system |
| 61 | + ARG APP_ROOT |
| 62 | + USER root |
| 63 | + |
| 64 | + RUN set -ex; \ |
| 65 | + mkdir -p /distroless${APP_ROOT}/etc; \ |
| 66 | + mkdir -p /distroless${APP_ROOT}/var; \ |
| 67 | + mkdir -p /distroless${APP_ROOT}/run; \ |
| 68 | + mkdir -p /distroless${APP_ROOT}/tmp; \ |
| 69 | + mkdir -p /distroless/.ooniprobe |
| 70 | +# ooniprobe will exit it doesn't have tmp permissions, permissions set later |
| 71 | + |
| 72 | + RUN set -ex; \ |
| 73 | + echo '{ \ |
| 74 | + "_version": 1, \ |
| 75 | + "_informed_consent": true, \ |
| 76 | + "sharing": { \ |
| 77 | + "upload_results": true \ |
| 78 | + }, \ |
| 79 | + "nettests": { \ |
| 80 | + "websites_max_runtime": 0 \ |
| 81 | + }, \ |
| 82 | + "advanced": {} \ |
| 83 | +}' >> /distroless/.ooniprobe/config.json |
| 84 | + |
| 85 | +# This is an awful way to do this, should use ENV variables on the compose. |
| 86 | +# The point is setting "_informed_consent" to "true" so it can start without editing a file. |
| 87 | +# Not editing a file is for running without bind mounts, and just named volumes. |
| 88 | +# At some point I might try do it from the compose, but for now, nope. |
| 89 | + |
| 90 | + |
| 91 | +# ╔═════════════════════════════════════════════════════╗ |
| 92 | +# ║ IMAGE ║ |
| 93 | +# ╚═════════════════════════════════════════════════════╝ |
| 94 | + # :: HEADER |
| 95 | + FROM scratch |
| 96 | + |
| 97 | + # :: default arguments |
| 98 | + ARG TARGETPLATFORM \ |
| 99 | + TARGETOS \ |
| 100 | + TARGETARCH \ |
| 101 | + TARGETVARIANT \ |
| 102 | + APP_IMAGE \ |
| 103 | + APP_NAME \ |
| 104 | + APP_VERSION \ |
| 105 | + APP_ROOT \ |
| 106 | + APP_UID \ |
| 107 | + APP_GID \ |
| 108 | + APP_NO_CACHE |
| 109 | + |
| 110 | + # :: default environment |
| 111 | + ENV APP_IMAGE=${APP_IMAGE} \ |
| 112 | + APP_NAME=${APP_NAME} \ |
| 113 | + APP_VERSION=${APP_VERSION} \ |
| 114 | + APP_ROOT=${APP_ROOT} |
| 115 | + |
| 116 | + # :: multi-stage |
| 117 | + COPY --from=distroless / / |
| 118 | +# COPY --from=distroless-dnslookup / / |
| 119 | + COPY --from=build /distroless/ / |
| 120 | + COPY --from=file-system --chown=${APP_UID}:${APP_GID} /distroless/ / |
| 121 | + |
| 122 | + |
| 123 | +# :: EXECUTE |
| 124 | + USER ${APP_UID}:${APP_GID} |
| 125 | +ENTRYPOINT [ "/usr/local/bin/ooniprobe-linux-amd64", "run", "unattended" ] |
0 commit comments