Skip to content

Commit

Permalink
add and build docker image
Browse files Browse the repository at this point in the history
Signed-off-by: Augustin Husson <[email protected]>
  • Loading branch information
Nexucis committed Oct 23, 2024
1 parent 2afa818 commit a228ef8
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ jobs:
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
- # Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ github.event_name == 'push' && (startsWith(github.ref_name, 'v') || github.ref_name == 'main') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: install goreleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine AS build-env
RUN apk add --update --no-cache mailcap

FROM gcr.io/distroless/static-debian11

LABEL maintainer="The Perses Authors <[email protected]>"

USER nobody

COPY --chown=nobody:nobody metric-usage /bin/metric-usage
COPY --chown=nobody:nobody LICENSE /LICENSE
COPY --from=build-env --chown=nobody:nobody /etc/mime.types /etc/mime.types

WORKDIR /perses

EXPOSE 8080
ENTRYPOINT [ "/bin/metric-usage" ]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ update-go-deps:
$(GO) get -d $$m; \
done

.PHONY: generate-goreleaser
generate-goreleaser:
$(GO) run ./scripts/generate-goreleaser/generate-goreleaser.go

## Cross build binaries for all platforms (Use "make build" in development)
.PHONY: cross-build
cross-build: ## Cross build binaries for all platforms (Use "make build" in development)
cross-build: generate-goreleaser ## Cross build binaries for all platforms (Use "make build" in development)
goreleaser release --snapshot --clean

.PHONY: cross-release
cross-release:
cross-release: generate-goreleaser
goreleaser release --clean
18 changes: 18 additions & 0 deletions distroless-debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine AS build-env
RUN apk add --update --no-cache mailcap
RUN mkdir /perses

FROM gcr.io/distroless/static-debian11:debug

LABEL maintainer="The Perses Authors <[email protected]>"

USER nobody

COPY --chown=nobody:nobody metric-usage /bin/metric-usage
COPY --chown=nobody:nobody LICENSE /LICENSE
COPY --from=build-env --chown=nobody:nobody /etc/mime.types /etc/mime.types

WORKDIR /perses

EXPOSE 8080
ENTRYPOINT [ "/bin/metric-usage" ]
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.1
require (
github.com/labstack/echo/v4 v4.12.0
github.com/perses/common v0.26.0
github.com/perses/perses v0.48.0
github.com/perses/perses v0.48.1-0.20241023144629-e60322151b7e
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.60.0
github.com/prometheus/prometheus v0.54.1
Expand Down Expand Up @@ -42,18 +42,18 @@ require (
github.com/robfig/cron v1.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/zitadel/oidc/v3 v3.30.0 // indirect
github.com/zitadel/oidc/v3 v3.30.1 // indirect
github.com/zitadel/schema v1.3.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ github.com/perses/common v0.26.0 h1:szF3GFTUgsCts3VYU3QY9OfgnYerjzHl9bo9pk4ZGyM=
github.com/perses/common v0.26.0/go.mod h1:5vlqNPN6i73VJprx7XA7EulzcbKmnV63jrqnyT27B+E=
github.com/perses/perses v0.48.0 h1:RLr8DkNF1Mr1wj2bLcbOO7aeFH+E1nauUwDA6Tkyfkw=
github.com/perses/perses v0.48.0/go.mod h1:JtKrnxVfWU8RjhI6OnPDigi3deRLzckuTTuRly6ukTw=
github.com/perses/perses v0.48.1-0.20241023144629-e60322151b7e h1:ZniyQI4uX/MR08Qp6of5kx7zQXn2mAzlQwYxONHHfRQ=
github.com/perses/perses v0.48.1-0.20241023144629-e60322151b7e/go.mod h1:ibQ2xZ8ZC9oQGDrnn23U4CearJuv6vF2y0wi8RZVnyk=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -124,6 +126,7 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/zitadel/oidc/v3 v3.30.0 h1:1IuZlK+X+JLExEA2PYgRlVvWHBhz/cMwT7VL/YrQabw=
github.com/zitadel/oidc/v3 v3.30.0/go.mod h1:+I5BgvGO5C2ZJrQRjV34EjkyA7P3GXyYGZgXI8Sdw18=
github.com/zitadel/oidc/v3 v3.30.1/go.mod h1:N5p02vx+mLUwf+WFNpDsNp+8DS8+jlgFBwpz7NIQjrg=
github.com/zitadel/schema v1.3.0 h1:kQ9W9tvIwZICCKWcMvCEweXET1OcOyGEuFbHs4o5kg0=
github.com/zitadel/schema v1.3.0/go.mod h1:NptN6mkBDFvERUCvZHlvWmmME+gmZ44xzwRXwhzsbtc=
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
Expand All @@ -140,6 +143,7 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
Expand All @@ -153,8 +157,10 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions scripts/generate-goreleaser/generate-goreleaser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024 The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
_ "embed"

goreleasergenerate "github.com/perses/perses/scripts/generate-docker-goreleaser-config"
)

//go:embed .goreleaser.base.yaml
var baseConfig []byte

func main() {
goreleasergenerate.GenerateGoreleaserConfig(baseConfig, "metric-usage", []string{
"LICENSE",
})
}

0 comments on commit a228ef8

Please sign in to comment.