OXYGENHUB
# e2189ffef8ff oxygenflow / images / tofu / Dockerfile
1.8 KiB · last changed tofu image: curl, jq, xz, sfdisk and debugfs for baking VM images 20 days ago source blame history raw
1
# The OxygenFlow OpenTofu image (oxygenflow#56): OpenTofu and the providers
2
# the deploy pipelines use, mirrored inside, so `tofu init` needs no
3
# registry. A job reaches a cloud's API only through allow-listed egress
4
# (#55); formatting and validation need no network at all.
5
6
# Download and check OpenTofu, and mirror the providers, with the tools
7
# only this stage needs.
8
FROM debian:bookworm-slim AS fetch
9
ARG TOFU_VERSION
10
ARG TOFU_SHA256
11
RUN apt-get update \
12
 && apt-get install -y --no-install-recommends ca-certificates curl unzip \
13
 && rm -rf /var/lib/apt/lists/*
14
RUN curl -fsSL -o /tmp/tofu.zip \
15
      "https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_linux_amd64.zip" \
16
 && echo "${TOFU_SHA256}  /tmp/tofu.zip" | sha256sum -c - \
17
 && unzip -q /tmp/tofu.zip tofu -d /usr/local/bin \
18
 && rm /tmp/tofu.zip
19
# The exact provider versions of the pipelines' lock files; `tofu
20
# providers mirror` checks each package against the registry's signed
21
# checksums as it downloads it.
22
COPY mirror.tf /tmp/mirror/
23
RUN cd /tmp/mirror && tofu providers mirror -platform=linux_amd64 /opt/tofu/mirror
24
25
FROM debian:bookworm-slim
26
# curl, jq, xz, sfdisk and e2fsprogs' debugfs: oxygenhub-gcp's bake job
27
# builds the hub's VM image by writing files into Debian's cloud disk image,
28
# no root needed, and publishes it through Google's APIs (oxygenhub-gcp #7).
29
RUN apt-get update \
30
 && apt-get install -y --no-install-recommends ca-certificates curl jq xz-utils fdisk e2fsprogs \
31
 && rm -rf /var/lib/apt/lists/*
32
COPY --from=fetch /usr/local/bin/tofu /usr/local/bin/tofu
33
COPY --from=fetch /opt/tofu/mirror /opt/tofu/mirror
34
# Providers come only from the mirror: a job never reaches a registry.
35
COPY cli.tfrc /etc/tofu/cli.tfrc
36
ENV TF_CLI_CONFIG_FILE=/etc/tofu/cli.tfrc