Skip to content

Commit

Permalink
feat: build api da pgconfigctl docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianwebber committed Sep 5, 2020
1 parent 3243bd8 commit b2b43ff
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.14

-
name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ builds:
goarch: 386
goarch:
- amd64
- id: api
binary: api
main: cmd/api/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ignore:
- goos: darwin
goarch: 386
goarch:
- amd64

nfpms:
- id: default
Expand Down Expand Up @@ -55,3 +69,23 @@ snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc

dockers:
-
dockerfile: cmd/pgconfigctl/Dockerfile
binaries:
- pgconfigctl
image_templates:
- "pgconfig/pgconfigctl:{{ .Tag }}"
- "pgconfig/pgconfigctl:v{{ .Major }}"
- "pgconfig/pgconfigctl:v{{ .Major }}.{{ .Minor }}"
- "pgconfig/pgconfigctl:latest"
-
dockerfile: cmd/api/Dockerfile
binaries:
- api
image_templates:
- "pgconfig/api:{{ .Tag }}"
- "pgconfig/api:v{{ .Major }}"
- "pgconfig/api:v{{ .Major }}.{{ .Minor }}"
- "pgconfig/api:latest"
6 changes: 6 additions & 0 deletions cmd/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gcr.io/distroless/base-debian10

EXPOSE 3000

COPY api /
CMD ["/api"]
10 changes: 9 additions & 1 deletion cmd/pgconfigapi/main.go → cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"log"

"github.com/gofiber/fiber"
Expand All @@ -9,6 +10,13 @@ import (

const APIVersion = "/api/v2"

var port int

func init() {
flag.IntVar(&port, "version", 3000, "Listen port")
flag.Parse()
}

// Next with CORS
func next(c *fiber.Ctx) {
c.Vary("Origin") // => Vary: Origin
Expand All @@ -25,7 +33,7 @@ func main() {
app := fiber.New()
v2 := app.Group(APIVersion, next)
api.SetupRoutesCompute(v2)
if err := app.Listen(3000); err != nil {
if err := app.Listen(port); err != nil {
log.Println("[ERR] not running API: ", err)
}
}
3 changes: 3 additions & 0 deletions cmd/pgconfigctl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY pgconfigctl /
CMD ["/pgconfigctl"]

0 comments on commit b2b43ff

Please sign in to comment.