feat: ci #2
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
- name: Check
|
||||||
|
run: make check
|
||||||
+3
-1
@@ -24,6 +24,8 @@ ENV DATA_DIR=/app/data \
|
|||||||
PORT=8080
|
PORT=8080
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
USER nonroot:nonroot
|
# Numeric UID/GID: the kubelet cannot verify named users for runAsNonRoot.
|
||||||
|
# 65532 is the distroless "nonroot" user.
|
||||||
|
USER 65532:65532
|
||||||
|
|
||||||
ENTRYPOINT ["/app/api"]
|
ENTRYPOINT ["/app/api"]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
GO ?= go
|
||||||
|
|
||||||
|
.PHONY: check vet test build
|
||||||
|
|
||||||
|
# Local equivalent of the Gitea Actions CI job.
|
||||||
|
check: vet test build
|
||||||
|
|
||||||
|
vet:
|
||||||
|
$(GO) vet ./...
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(GO) test -count=1 ./...
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(GO) build ./...
|
||||||
@@ -1,3 +1,31 @@
|
|||||||
# api-go
|
# api-go
|
||||||
|
|
||||||
Golang API that is the backbone for daily usage, while python works in batches and is heavy in compute while Golang handles concurrent usage cheap
|
Golang API that is the backbone for daily usage, while python works in batches and is heavy in compute while Golang handles concurrent usage cheap
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make check
|
||||||
|
```
|
||||||
|
|
||||||
|
Runs `go vet ./...`, `go test -count=1 ./...`, and `go build ./...`. The same
|
||||||
|
target runs in Gitea Actions on every push and pull request
|
||||||
|
(`.gitea/workflows/ci.yml`).
|
||||||
|
|
||||||
|
## Container
|
||||||
|
|
||||||
|
The image is a multi-stage build. The runtime is
|
||||||
|
`gcr.io/distroless/static-debian12:nonroot` and runs as numeric
|
||||||
|
**UID/GID `65532:65532`** (`USER 65532:65532` in the `Dockerfile`).
|
||||||
|
|
||||||
|
Use the same numbers in Kubernetes:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 65532
|
||||||
|
runAsGroup: 65532
|
||||||
|
runAsNonRoot: true
|
||||||
|
```
|
||||||
|
|
||||||
|
Do not use named users such as `nonroot` in a `securityContext`: the kubelet
|
||||||
|
cannot verify a non-numeric image user.
|
||||||
Reference in new issue
Block a user