OXYGENHUB
# e0053e047704 oxygenflow / images / tofu / Dockerfile
1.5 KiB · last changed The OpenTofu image for deploy jobs 21 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
RUN apt-get update \
27
 && apt-get install -y --no-install-recommends ca-certificates \
28
 && rm -rf /var/lib/apt/lists/*
29
COPY --from=fetch /usr/local/bin/tofu /usr/local/bin/tofu
30
COPY --from=fetch /opt/tofu/mirror /opt/tofu/mirror
31
# Providers come only from the mirror: a job never reaches a registry.
32
COPY cli.tfrc /etc/tofu/cli.tfrc
33
ENV TF_CLI_CONFIG_FILE=/etc/tofu/cli.tfrc