diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dd965f7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "formol"] + path = formol + url = ../formol diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27b86a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# 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 + +FROM alpine:3.17 +RUN apk add --no-cache su-exec restic postgresql-client +COPY --from=builder /go/src/bin/formolcli /usr/local/bin + +# Command to run +ENTRYPOINT ["/usr/local/bin/formolcli"] +CMD ["--help"] diff --git a/Makefile b/Makefile index 8fd2f7c..3a8beca 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ GOARCH ?= amd64 +GOOS ?= linux +IMG ?= desmo999r/formolcli:latest +BINDIR = ./bin -.PHONY: formolcli -formolcli: fmt vet - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -o bin/formolcli main.go +$(BINDIR)/formolcli: fmt vet + GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BINDIR)/formolcli main.go .PHONY: fmt fmt: @@ -12,5 +14,13 @@ fmt: vet: go vet ./... +.PHONY: docker-build +docker-build: $(BINDIR)/formolcli + buildah build --disable-compression --format=docker --platform $(GOOS)/$(GOARCH) -t $(IMG) . + +.PHONY: docker-push +docker-push: docker-build + buildah push $(IMG) + .PHONY: all -all: formolcli +all: $(BINDIR)/formolcli docker-build diff --git a/formol b/formol new file mode 160000 index 0000000..06999eb --- /dev/null +++ b/formol @@ -0,0 +1 @@ +Subproject commit 06999eb5537620aba484ea47875c3aef80389ca2 diff --git a/go.mod b/go.mod index 0a4d79d..3a950b6 100644 --- a/go.mod +++ b/go.mod @@ -70,4 +70,4 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) -replace github.com/desmo999r/formol => ../formol +replace github.com/desmo999r/formol => ./formol