Added Docker file

This commit is contained in:
Jean-Marc ANDRE 2023-02-08 12:49:05 +01:00
parent 120b24b9aa
commit 8d75e1450c
5 changed files with 35 additions and 5 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "formol"]
path = formol
url = ../formol

16
Dockerfile Normal file
View File

@ -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"]

View File

@ -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

1
formol Submodule

@ -0,0 +1 @@
Subproject commit 06999eb5537620aba484ea47875c3aef80389ca2

2
go.mod
View File

@ -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