-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
GOCMD = go | ||
GOBUILD = $(GOCMD) build | ||
GOGET = $(GOCMD) get -v | ||
GOCLEAN = $(GOCMD) clean | ||
GOINSTALL = $(GOCMD) install | ||
GOTEST = $(GOCMD) test | ||
|
||
.PHONY: all | ||
|
||
all: test | ||
|
||
.PHONY: test | ||
test: | ||
$(GOTEST) -v -covermode=count -coverprofile=coverage.out ./... | ||
|
||
.PHONY: build | ||
build: test | ||
$(GOBUILD) | ||
|
||
.PHONY: install | ||
install: test | ||
$(GOINSTALL) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
ARG BUILDER_IMAGE=golang:buster | ||
ARG DISTROLESS_IMAGE=gcr.io/distroless/base | ||
############################ | ||
# STEP 1 build executable binary | ||
############################ | ||
|
||
# syntax = docker/dockerfile:1-experimental | ||
|
||
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS base | ||
WORKDIR /src | ||
ENV CGO_ENABLED=0 | ||
COPY go.* . | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
FROM base AS build | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
# Ensure ca-certficates are up to date | ||
RUN update-ca-certificates | ||
WORKDIR /src | ||
COPY . . | ||
RUN --mount=target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -a -installsuffix cgo -o /go/bin/meteocat/example/influxdb . | ||
|
||
|
||
############################ | ||
# STEP 2 build a small image | ||
############################ | ||
# using base nonroot image | ||
# user:group is nobody:nobody, uid:gid = 65534:65534 | ||
FROM ${DISTROLESS_IMAGE} | ||
|
||
# Copy our config file and static executable | ||
COPY config.yml $GOPATH/src/meteocat/example/influxdb/ | ||
COPY --from=build /go/bin/meteocat/example/influxdb /go/bin/meteocat/example/influxdb | ||
WORKDIR $GOPATH/src/meteocat/example/influxdb/ | ||
ENV LOG_DEBUG=true | ||
# Run main | ||
ENTRYPOINT ["/go/bin/meteocat/example/influxdb"] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module influxdb | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/deepmap/oapi-codegen v1.5.1 // indirect | ||
github.com/fatih/color v1.10.0 // indirect | ||
github.com/ilyakaznacheev/cleanenv v1.2.5 | ||
github.com/influxdata/influxdb-client-go/v2 v2.2.2 | ||
github.com/influxdata/line-protocol v0.0.0-20210219174132-3da7e03c5204 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/magefile/mage v1.11.0 // indirect | ||
github.com/oscaromeu/meteocat v0.0.0-20210221173235-349edc505962 | ||
github.com/sirupsen/logrus v1.8.0 | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect | ||
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 // indirect | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect | ||
) |