Created
October 3, 2023 06:14
-
-
Save shvargon/fc00a1e219a7ff0432b6577c371779f0 to your computer and use it in GitHub Desktop.
opentofu creating docker image and compiling linux binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARG GO_VERSION=1.20 | |
| FROM golang:${GO_VERSION}-bookworm as builder | |
| WORKDIR /app | |
| RUN git clone --depth 1 https://github.com/opentofu/opentofu.git . | |
| RUN go mod download && go mod verify | |
| RUN CGO_ENABLED=0 GOOS=linux go build -v -o bin/ ./cmd/tofu | |
| FROM scratch AS export-stage | |
| COPY --from=builder /app/bin/tofu / | |
| FROM ubuntu:jammy as release | |
| WORKDIR /usr/local/bin | |
| COPY --from=builder /app/bin/tofu ./ | |
| CMD [ "tofu" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BUILD_CMD ?= docker build | |
| DESTDIR ?= ./bin | |
| NAME ?= shvargon/opentofu | |
| all: build binary | |
| .PHONY: build | |
| build: | |
| $(BUILD_CMD) -t "$(NAME)" . | |
| .PHONY: binary | |
| binary: | |
| $(BUILD_CMD) -o "$(DESTDIR)" . --target=export-stage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment