stagex/packages/tofu/Containerfile

38 lines
979 B
Text
Raw Normal View History

2024-02-09 07:30:28 +00:00
FROM scratch as base
2023-12-23 01:58:45 +00:00
ENV VERSION=1.6.0-beta4
ENV SRC_HASH=b14f151839d90d06f95ba4257be159857606daf522d99e9285ddb248f814393f
2024-02-09 07:30:28 +00:00
ENV SRC_FILE=v${VERSION}.tar.gz
2024-02-14 22:56:29 +00:00
ENV SRC_SITE=https://github.com/opentofu/opentofu/archive/refs/tags/${SRC_FILE}
2023-12-23 01:58:45 +00:00
FROM base as fetch
2024-02-09 07:30:28 +00:00
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
2023-12-23 01:58:45 +00:00
FROM fetch as build
2024-02-09 07:30:28 +00:00
COPY --from=busybox . /
COPY --from=go . /
COPY --from=ca-certificates . /
2023-12-23 01:58:45 +00:00
RUN tar -xvf v${VERSION}.tar.gz
WORKDIR opentofu-${VERSION}
ENV PWD=/home/user/opentofu-${VERSION}
ENV GOPATH=${PWD}/cache/go
ENV GOCACHE=${PWD}/cache/
ENV GOWORK=off
ENV GOPROXY=https://proxy.golang.org,direct
ENV GOSUMDB=sum.golang.org
ENV CGO_ENABLED=0
ENV GOHOSTOS=linux
ENV GOHOSTARCH=amd64
ENV GOFLAGS=-trimpath
2023-12-23 01:58:45 +00:00
RUN mkdir -p ${GOPATH}
RUN go build -o bin/tofu ./cmd/tofu
from build as install
2024-02-09 07:30:28 +00:00
RUN <<-EOF
mkdir -p /rootfs/usr/bin/
cp bin/tofu /rootfs/usr/bin/
EOF
RUN find /rootfs -exec touch -hcd "@0" "{}" +
2023-12-23 01:58:45 +00:00
FROM scratch as package
COPY --from=install /rootfs/ /