Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
chore: repo scaffolding
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
  • Loading branch information
shanduur committed May 11, 2024
0 parents commit e5c4cd1
Show file tree
Hide file tree
Showing 40 changed files with 3,595 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Binaries for programs and plugins
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib

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

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

# Go workspace file
go.work

# Documentation files
docs/

# GitHub configs
.github/
32 changes: 32 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: image

on:
push:
tags:
- 'v*'

permissions:
contents: read
packages: write

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v3
- id: buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.event.repository.owner.name }}/lke-operator:${{ github.ref_name }}
35 changes: 35 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: linters

on:
pull_request:
branches: [ '*' ]
push:
branches:
- "main"

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
with:
configFile: .commitlintrc.mjs
token: ${{ secrets.GITHUB_TOKEN }}

shell-linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@master

hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
recursive: true
23 changes: 23 additions & 0 deletions .github/workflows/semantic-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: semantic-pr

on:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
pr-title:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: true
subjectPattern: ^(?![A-Z]).+$
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/*
Dockerfile.cross

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

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

# Go workspace file
go.work

# Kubernetes Generated files - skip generated files, except for vendored files
!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~

# generated files
dist/
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
run:
timeout: 5m
allow-parallel-runners: true

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- path: "api/*"
linters:
- lll
- path: "internal/*"
linters:
- dupl
- lll
linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
71 changes: 71 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#########################################################################################
# Build
#########################################################################################

# First stage: building the driver executable.
FROM --platform=${TARGETPLATFORM} docker.io/library/golang:1.22.3 AS builder
ARG TARGETOS
ARG TARGETARCH

# Set the working directory.
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

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/

# Arg for setting version.
ARG VERSION=canary

# Build.
ENV CGO_ENABLED=0
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
RUN go build \
-trimpath \
-ldflags="-X github.com/anza-labs/lke-operator/internal/version.Version=${VERSION} -s -w -extldflags '-static'" \
-o=./bin/manager \
./cmd/main.go

#########################################################################################
# Runtime
#########################################################################################

# Second stage: building final environment for running the executable.
FROM gcr.io/distroless/static:latest AS runtime

Check failure on line 44 in Dockerfile

View workflow job for this annotation

GitHub Actions / hadolint

DL3007 warning: Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag

# Copy the executable.
COPY --from=builder --chown=65532:65532 /workspace/bin/manager /manager

# Set the final UID:GID to non-root user.
USER 65532:65532

# Disable healthcheck.
HEALTHCHECK NONE

# Add labels.
ARG VERSION=canary

## Standard opencontainers labels.
LABEL org.opencontainers.image.title="lke-operator"
LABEL org.opencontainers.image.description="Kubernetes operator for managing LKE (Linode Kubernetes Engine) instances."
LABEL org.opencontainers.image.authors="anza-labs contributors"
LABEL org.opencontainers.image.vendor="anza-labs"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.license="Apache-2.0"
LABEL org.opencontainers.image.source="https://github.com/anza-labs/lke-operator"
LABEL org.opencontainers.image.documentation="http://anza-labs.github.io/lke-operator"
LABEL org.opencontainers.image.base.name="gcr.io/distroless/static:latest"

# Set the entrypoint.
ENTRYPOINT [ "/manager" ]
CMD []
Loading

0 comments on commit e5c4cd1

Please sign in to comment.