|
1 | | -FROM docker.io/library/python:3.13-slim |
| 1 | +ARG FDB_VERSION=7.1.67 |
| 2 | +ARG FDB_WEBSITE=https://github.com/apple/foundationdb/releases/download |
2 | 3 |
|
| 4 | +# Build the manager binary |
| 5 | +FROM golang:1.24.9-bookworm AS builder |
| 6 | + |
| 7 | +ARG FDB_VERSION |
| 8 | +ARG FDB_WEBSITE |
| 9 | +ARG TARGETARCH |
| 10 | +ARG TAG="latest" |
| 11 | + |
| 12 | +RUN set -eux && \ |
| 13 | + if [ "$TARGETARCH" = "amd64" ]; then \ |
| 14 | + FDB_ARCH=amd64; \ |
| 15 | + elif [ "$TARGETARCH" = "arm64" ]; then \ |
| 16 | + FDB_ARCH=aarch64; \ |
| 17 | + if [ "${FDB_VERSION%.*}" = "7.1" ]; then \ |
| 18 | + FDB_VERSION="7.3.71"; \ |
| 19 | + fi; \ |
| 20 | + else \ |
| 21 | + echo "ERROR: unsupported architecture $TARGETARCH" 1>&2; \ |
| 22 | + exit 1; \ |
| 23 | + fi; \ |
| 24 | + curl --fail -L "${FDB_WEBSITE}/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb" -o foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb && \ |
| 25 | + curl --fail -L "${FDB_WEBSITE}/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb.sha256" -o foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb.sha256 && \ |
| 26 | + sha256sum -c foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb.sha256 && \ |
| 27 | + dpkg -i foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb && \ |
| 28 | + rm foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb foundationdb-clients_${FDB_VERSION}-1_${FDB_ARCH}.deb.sha256 |
| 29 | + |
| 30 | +WORKDIR /workspace |
| 31 | +# Copy the Go Modules manifests |
| 32 | +COPY go.mod go.mod |
| 33 | +COPY go.sum go.sum |
| 34 | +# cache deps before building and copying source so that we don't need to re-download as much |
| 35 | +# and so that source changes don't invalidate our downloaded layer |
| 36 | +RUN go mod download -x |
| 37 | + |
| 38 | +# Copy the go source |
| 39 | +COPY main.go main.go |
| 40 | + |
| 41 | +# Build |
| 42 | +RUN CGO_ENABLED=1 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -o /workspace/bin/data-loader main.go |
| 43 | + |
| 44 | +FROM rockylinux/rockylinux:9.6-minimal |
| 45 | + |
| 46 | +ARG FDB_VERSION |
| 47 | +ARG FDB_WEBSITE |
3 | 48 | ARG TARGETARCH |
4 | 49 |
|
5 | | -COPY app.py /usr/local/bin |
| 50 | +VOLUME /usr/lib/fdb |
| 51 | + |
| 52 | +WORKDIR / |
| 53 | + |
| 54 | +RUN set -eux && \ |
| 55 | + if [ "$TARGETARCH" = "amd64" ]; then \ |
| 56 | + FDB_ARCH=x86_64; \ |
| 57 | + elif [ "$TARGETARCH" = "arm64" ]; then \ |
| 58 | + FDB_ARCH=aarch64; \ |
| 59 | + if [ "${FDB_VERSION%.*}" = "7.1" ]; then \ |
| 60 | + FDB_VERSION="7.3.71"; \ |
| 61 | + fi; \ |
| 62 | + else \ |
| 63 | + echo "ERROR: unsupported architecture $TARGETARCH" 1>&2; \ |
| 64 | + exit 1; \ |
| 65 | + fi; \ |
| 66 | + if [ "${FDB_VERSION%.*}" = "7.1" ]; then \ |
| 67 | + # FDB 7.1 published the client packages for el7, 7.3 and newer uses el9. |
| 68 | + FDB_OS=el7; \ |
| 69 | + else \ |
| 70 | + FDB_OS=el9; \ |
| 71 | + fi; \ |
| 72 | + curl --fail -L "${FDB_WEBSITE}/${FDB_VERSION}/foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm" -o foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm && \ |
| 73 | + curl --fail -L "${FDB_WEBSITE}/${FDB_VERSION}/foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm.sha256" -o foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm.sha256 && \ |
| 74 | + microdnf install -y glibc pkg-config && \ |
| 75 | + microdnf clean all && \ |
| 76 | + sha256sum -c foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm.sha256 && \ |
| 77 | + rpm -i foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm --excludepath=/usr/bin --excludepath=/usr/lib/foundationdb/backup_agent && \ |
| 78 | + rm foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm foundationdb-clients-${FDB_VERSION}-1.${FDB_OS}.${FDB_ARCH}.rpm.sha256 |
6 | 79 |
|
7 | | -RUN pip install foundationdb==7.1.67 |
8 | 80 | RUN groupadd --gid 4059 fdb && \ |
9 | | - useradd --gid 4059 --uid 4059 --shell /usr/sbin/nologin fdb |
| 81 | + useradd --gid 4059 --uid 4059 --shell /usr/sbin/nologin fdb && \ |
| 82 | + mkdir -p /var/log/fdb && \ |
| 83 | + touch /var/log/fdb/.keep |
10 | 84 |
|
11 | | -RUN apt-get update && \ |
12 | | - apt-get install -y --no-install-recommends curl && \ |
13 | | - curl -L https://github.com/krallin/tini/releases/download/v0.19.0/tini-${TARGETARCH} -o tini-${TARGETARCH} && \ |
14 | | - echo "93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c tini-amd64\n07952557df20bfd2a95f9bef198b445e006171969499a1d361bd9e6f8e5e0e81 tini-arm64" > tini-sha.txt && \ |
15 | | - sha256sum --quiet --ignore-missing -c tini-sha.txt && \ |
16 | | - chmod +x tini-${TARGETARCH} && \ |
17 | | - mv tini-${TARGETARCH} /usr/bin/tini && \ |
18 | | - rm -rf /tmp/* |
| 85 | +COPY --chown=fdb:fdb --from=builder /workspace/bin/data-loader /usr/local/bin/data-loader |
19 | 86 |
|
20 | 87 | # Set to the numeric UID of fdb user to satisfy PodSecurityPolices which enforce runAsNonRoot |
21 | 88 | USER 4059 |
22 | 89 |
|
23 | | -ENTRYPOINT [ "/usr/bin/tini", "-g", "--", "python", "/usr/local/bin/app.py" ] |
| 90 | +ENTRYPOINT ["/usr/local/bin/data-loader"] |
0 commit comments