Skip to content

Commit 8350490

Browse files
committed
Initial commit
0 parents  commit 8350490

File tree

272 files changed

+99118
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

272 files changed

+99118
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Create release
2+
on:
3+
pull_request_target:
4+
branches:
5+
- main
6+
types:
7+
- closed
8+
jobs:
9+
release:
10+
if: github.event.pull_request.merged == true && !contains(github.event.pull_request.title, 'skip-release')
11+
uses: libops/actions/.github/workflows/bump-release.yaml@main
12+
with:
13+
workflow_file: goreleaser.yml
14+
prefix: v
15+
permissions:
16+
contents: write
17+
actions: write
18+
secrets: inherit

.github/workflows/goreleaser.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: goreleaser
2+
on:
3+
workflow_dispatch:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
22+
with:
23+
go-version: ">=1.25.3"
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: build-push
2+
on:
3+
push:
4+
workflow_dispatch:
5+
6+
jobs:
7+
lint-test:
8+
runs-on: ubuntu-24.04
9+
steps:
10+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
11+
12+
- name: Set up Go
13+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
14+
with:
15+
go-version: ">=1.25.3"
16+
17+
- name: Cache Go tools
18+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
19+
with:
20+
path: |
21+
~/go/pkg/mod
22+
~/go/bin
23+
key: ${{ runner.os }}-golang-${{ hashFiles('go.sum', 'Makefile') }}
24+
restore-keys: |
25+
${{ runner.os }}-golang-
26+
27+
- name: golangci-lint
28+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
29+
with:
30+
version: latest
31+
install-only: true
32+
33+
- name: setup
34+
run: make install-tools
35+
36+
- name: lint
37+
run: make lint
38+
39+
- name: test
40+
run: make test
41+
42+
#- name: check contract
43+
# run: make proto-breaking
44+
45+
push:
46+
needs: [lint-test]
47+
uses: libops/.github/.github/workflows/build-push-ghcr.yaml@main
48+
permissions:
49+
contents: read
50+
packages: write
51+
secrets: inherit
52+
53+
codecov:
54+
needs: [lint-test]
55+
runs-on: ubuntu-24.04
56+
steps:
57+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
58+
59+
- name: Set up Go
60+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
61+
with:
62+
go-version: ">=1.25.3"
63+
64+
- name: coverage
65+
run: go test -v -coverprofile=coverage.out -covermode=atomic ./internal/...
66+
67+
- name: upload coverage to codecov
68+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
69+
with:
70+
files: ./coverage.out
71+
fail_ci_if_error: true
72+
env:
73+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
74+
75+
integration-test:
76+
needs: [lint-test]
77+
runs-on: ubuntu-24.04
78+
steps:
79+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
80+
81+
- run: make integration-test
82+
83+
- name: Display test logs on failure
84+
if: failure()
85+
run: |
86+
cd ci
87+
echo "=== API Logs ==="
88+
docker compose logs api
89+
echo ""
90+
echo "=== Vault Logs ==="
91+
docker compose logs vault
92+
echo ""
93+
echo "=== MariaDB Logs ==="
94+
docker compose logs mariadb

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<<<<<<< HEAD
2+
api
3+
secrets
4+
=======
5+
# Build artifacts
6+
/api
7+
8+
# Secrets and sensitive files
9+
*.key
10+
*.pem
11+
.env
12+
.env.*
13+
!.env.example
14+
secrets/
15+
16+
# Dependencies
17+
>>>>>>> 3b6a1a7 (Initial commit)
18+
web/node_modules

.golangci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "2"
2+
linters:
3+
exclusions:
4+
generated: lax
5+
presets:
6+
- comments
7+
- common-false-positives
8+
- legacy
9+
- std-error-handling
10+
paths:
11+
- ../../go
12+
- ../../../../opt
13+
- ./vendor
14+
- third_party$
15+
- builtin$
16+
- examples$
17+
formatters:
18+
enable:
19+
- gofmt
20+
exclusions:
21+
generated: lax
22+
paths:
23+
- ../../go
24+
- ../../../../opt
25+
- ./vendor
26+
- third_party$
27+
- builtin$
28+
- examples$

.goreleaser.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- binary: api
6+
env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- windows
11+
- darwin
12+
13+
archives:
14+
- format: tar.gz
15+
# this name template makes the OS and Arch compatible with the results of uname.
16+
name_template: >-
17+
{{ .ProjectName }}_
18+
{{- title .Os }}_
19+
{{- if eq .Arch "amd64" }}x86_64
20+
{{- else if eq .Arch "386" }}i386
21+
{{- else }}{{ .Arch }}{{ end }}
22+
{{- if .Arm }}v{{ .Arm }}{{ end }}
23+
# use zip for windows archives
24+
format_overrides:
25+
- goos: windows
26+
format: zip
27+
checksum:
28+
name_template: "checksums.txt"
29+
snapshot:
30+
name_template: "{{ incpatch .Version }}-next"
31+
changelog:
32+
sort: asc
33+
filters:
34+
exclude:
35+
- "^docs:"
36+
- "^test:"

Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f AS builder
2+
3+
SHELL ["/bin/ash", "-o", "pipefail", "-ex", "-c"]
4+
5+
WORKDIR /app
6+
7+
COPY go.mod go.sum ./
8+
COPY proto/ ./proto/
9+
RUN --mount=type=cache,target=/go/pkg/mod \
10+
go mod download
11+
12+
COPY *.go ./
13+
COPY internal/ ./internal/
14+
COPY db/ ./db/
15+
16+
RUN --mount=type=cache,target=/root/.cache/go-build \
17+
CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/binary .
18+
19+
FROM node:22-alpine AS frontend
20+
21+
WORKDIR /app
22+
23+
# Copy package files and install dependencies
24+
COPY web/package.json web/package-lock.json ./
25+
RUN npm ci
26+
27+
# Copy source files and build configuration
28+
COPY web/src/ ./src/
29+
COPY web/tsconfig.json web/vite.config.ts web/vite-plugin-proto-resolver.ts ./
30+
31+
# Build the frontend bundle
32+
RUN npm run build
33+
34+
FROM ubuntu:24.04 AS tailwind
35+
36+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
37+
38+
WORKDIR /app
39+
40+
RUN apt-get update && apt-get install curl --yes && \
41+
curl -sL \
42+
https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.18/tailwindcss-linux-x64 \
43+
-o /app/tailwindcss && \
44+
chmod +x /app/tailwindcss
45+
46+
COPY web/ ./web/
47+
# Copy the bundled JavaScript from frontend stage
48+
COPY --from=frontend /app/static/js/main.bundle.js ./web/static/js/main.bundle.js
49+
50+
RUN /app/tailwindcss \
51+
-i ./web/static/css/input.css \
52+
-o ./web/static/css/output.css \
53+
--content './web/templates/**/*.html,./web/src/**/*.ts' \
54+
--minify
55+
56+
57+
FROM ghcr.io/libops/go1.25:main@sha256:f43c9b34f888d2ac53e87c8e061554f826b8eb580863d7b21fd787b6f0378f8f
58+
59+
WORKDIR /app
60+
COPY --from=builder /app/binary /app/binary
61+
COPY web/ ./web/
62+
COPY --from=tailwind /app/web/static/css/output.css ./web/static/css/output.css
63+
COPY --from=frontend /app/static/js/main.bundle.js ./web/static/js/main.bundle.js
64+
65+
COPY openapi/ ./openapi/
66+
67+
EXPOSE 8080
68+
69+
HEALTHCHECK CMD /bin/bash -c 'curl -sf http://localhost:8080/health'

0 commit comments

Comments
 (0)