Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttehrani committed Oct 23, 2023
0 parents commit 23a2b98
Show file tree
Hide file tree
Showing 47 changed files with 3,427 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Container Image

on:
push:
tags:
- 'v*'

jobs:
docker:
name: docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: amd64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
- uses: docker/build-push-action@v5
with:
file: "Dockerfile"
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 21 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Request

on: [pull_request]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ^1.21
- run: go mod download
- name: build
run: make build
- name: lint
run: make lint
- name: test
run: make check
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.vscode

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
39 changes: 39 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 10m

linters:
enable:
- bodyclose
- gocognit
- goconst
- gocyclo
- godot
- gofmt
- goimports
- golint
- goprintffuncname
- gosec
- govet
- lll
- misspell
- nakedret
- staticcheck
- unconvert
- unparam
- whitespace
- wsl

linters-settings:
misspell:
locale: US
gofmt:
simplify: true
unparam:
check-exported: false
govet:
exclude:

issues:
exclude:
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked

50 changes: 50 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
project_name: contour-auth-multi-tenant
before:
hooks:
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goarch:
- amd64
- arm64
goos:
- linux
- darwin
ldflags:
- -s
- -w
- -X github.com/snapp-incubator/contour-auth-multi-tenant/pkg/version.Progname={{ .ProjectName }}
- -X github.com/snapp-incubator/contour-auth-multi-tenant/pkg/version.Version={{ .Env.VERSION }}
- -X github.com/snapp-incubator/contour-auth-multi-tenant/pkg/version.Sha={{ .Env.SHA }}
- -X github.com/snapp-incubator/contour-auth-multi-tenant/pkg/version.BuildDate={{ .Date }}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
dockers:
- goarch: amd64
goos: linux
dockerfile: hack/Dockerfile.release
skip_push: true
image_templates:
- "ghcr.io/projectcontour/{{ .ProjectName }}:{{ .Env.VERSION }}"
- "ghcr.io/projectcontour/{{ .ProjectName }}:latest"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Env.VERSION}}"
- "--label=org.opencontainers.image.url=https://projectcontour.io/"
- "--label=org.opencontainers.image.documentation=https://projectcontour.io/"
- "--label=org.opencontainers.image.vendor=Project Contour"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
- "--label=org.opencontainers.image.title=Contour Authserver"
- "--label=org.opencontainers.image.description=Contour Authorization Server"
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Build the contour-auth-multi-tenant binary.
#
# Note that this is not used for releasing, since goreleaser handles that.

FROM golang:1.21 as base

ENV GO111MODULE=on

WORKDIR /workspace

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

FROM base as builder

# Copy the go source
COPY . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on make build

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/bin/contour-auth-multi-tenant .
USER nonroot:nonroot

ENTRYPOINT ["/contour-auth-multi-tenant"]
Loading

0 comments on commit 23a2b98

Please sign in to comment.