Newer
Older
ARG BASE_IMAGE=docker.io/library/alpine:3.21.3
FROM docker.io/library/golang:1.24-alpine AS builder
WORKDIR /app
# Copy the Go source code
COPY src/auto-define-backend /app/
# Build the Go binary with static linking
RUN go build -o gitlab-tofu-auto-define-backend .
FROM $BASE_IMAGE
RUN apk add --no-cache \
curl \
Lukas Grossar
committed
wget \
gcompat \
git \
idn2-utils \
jq \
cosign
# Install OpenTofu using the installer script in standalone mode
# see https://opentofu.org/docs/intro/install/standalone
# We may want to switch to installing manually from GitHub and verifying signature
RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
chmod +x install-opentofu.sh && \
./install-opentofu.sh --install-method standalone --opentofu-version "${OPENTOFU_VERSION}" && \
rm ./install-opentofu.sh && \
tofu --version
WORKDIR /
COPY --chmod=755 src/gitlab-tofu.sh /usr/bin/gitlab-tofu
COPY --from=builder --chmod=755 /app/gitlab-tofu-auto-define-backend /usr/bin/
# Override ENTRYPOINT
ENTRYPOINT []