Faster build

This commit is contained in:
jandre 2023-02-08 17:58:54 +01:00
parent 8d75e1450c
commit 53369058b9
3 changed files with 14 additions and 7 deletions

View File

@ -1,8 +1,6 @@
# Build a small image
FROM golang:alpine3.17 AS builder
ARG TARGETARCH
RUN echo "I'm building for $TARGETARCH"
WORKDIR /go/src
COPY . .
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o bin/formolcli main.go

8
Dockerfile.amd64 Normal file
View File

@ -0,0 +1,8 @@
# Build a small image
FROM alpine:3.17
RUN apk add --no-cache su-exec restic postgresql-client
COPY ./bin/formolcli /usr/local/bin
# Command to run
ENTRYPOINT ["/usr/local/bin/formolcli"]
CMD ["--help"]

View File

@ -1,9 +1,10 @@
GOARCH ?= amd64
GOOS ?= linux
IMG ?= desmo999r/formolcli:latest
IMG ?= docker.io/desmo999r/formolcli:latest
BINDIR = ./bin
$(BINDIR)/formolcli: fmt vet
.PHONY: formolcli
formolcli: fmt vet
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BINDIR)/formolcli main.go
.PHONY: fmt
@ -15,12 +16,12 @@ vet:
go vet ./...
.PHONY: docker-build
docker-build: $(BINDIR)/formolcli
buildah build --disable-compression --format=docker --platform $(GOOS)/$(GOARCH) -t $(IMG) .
docker-build: formolcli
buildah bud --disable-compression --format=docker --platform $(GOOS)/$(GOARCH) --manifest $(IMG) Dockerfile.$(GOARCH)
.PHONY: docker-push
docker-push: docker-build
buildah push $(IMG)
.PHONY: all
all: $(BINDIR)/formolcli docker-build
all: formolcli docker-build