From aefba5ec1e10eb82e4d8bbb0c47d443fad5b33ed Mon Sep 17 00:00:00 2001 From: "Ciro S. Costa" Date: Tue, 3 Aug 2021 17:50:12 -0400 Subject: [PATCH] add container image when running monero in a kubernetes cluster, it's quite useful to be able to quickly bring up via a job or any other runner `monero demon *` commands. Signed-off-by: Ciro S. Costa --- .images.lock.yaml | 7 +++++++ .images.yaml | 13 +++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ Makefile | 4 ++++ 4 files changed, 53 insertions(+) create mode 100644 .images.lock.yaml create mode 100644 .images.yaml create mode 100644 Dockerfile diff --git a/.images.lock.yaml b/.images.lock.yaml new file mode 100644 index 0000000..e49a29d --- /dev/null +++ b/.images.lock.yaml @@ -0,0 +1,7 @@ +apiVersion: kbld.k14s.io/v1alpha1 +kind: Config +minimumRequiredVersion: 0.30.0 +overrides: +- image: go-monero + newImage: index.docker.io/utxobr/go-monero@sha256:195b49c96e8484a2381c069385d8340710454ad060c25c9c3976d79bed33750c + preresolved: true diff --git a/.images.yaml b/.images.yaml new file mode 100644 index 0000000..8df1373 --- /dev/null +++ b/.images.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kbld.k14s.io/v1alpha1 +kind: Config +sources: + - image: go-monero + path: ./ +destinations: + - image: go-monero + newImage: docker.io/utxobr/go-monero + +--- +images: + - image: go-monero diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9d9cbcb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +ARG BUILDER_IMAGE=golang@sha256:4544ae57fc735d7e415603d194d9fb09589b8ad7acd4d66e928eabfb1ed85ff1 +ARG RUNTIME_IMAGE=gcr.io/distroless/static@sha256:c9f9b040044cc23e1088772814532d90adadfa1b86dcba17d07cb567db18dc4e + + +FROM $BUILDER_IMAGE as builder + + WORKDIR /workspace + + COPY .git .git + COPY go.mod go.mod + COPY go.sum go.sum + COPY pkg/ pkg/ + COPY cmd/ cmd/ + + RUN set -x && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on \ + go build -a -v \ + -trimpath \ + -tags osusergo,netgo,static_build \ + -o monero \ + ./cmd/monero + + +FROM $RUNTIME_IMAGE + + WORKDIR / + COPY --chown=nonroot:nonroot --from=builder /workspace/monero . + USER nonroot:nonroot + + ENTRYPOINT ["/monero"] diff --git a/Makefile b/Makefile index 9a47748..2872af6 100644 --- a/Makefile +++ b/Makefile @@ -9,3 +9,7 @@ test: lint: go run github.com/golangci/golangci-lint/cmd/golangci-lint run --config=.golangci.yaml + +.images.lock.yaml: .images.yaml + kbld -f $< --lock-output $@ +.PHONY: .images.lock.yaml