chore(console): buf stub build (#5215)

* buf gen yaml

* dep, buildcmd

* deps

* buf yml

* buf work

* gen yml

* buf

* buf mod update

* path

* chore: fix buf

* npm package

* build as prodbuild

* trigger

* temp rm basepath

* base href

* generate as prelint

* proto proto

* rm unused gitignore

---------

Co-authored-by: Florian Forster <florian@zitadel.com>
Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Max Peintner 2023-02-17 15:09:11 +01:00 committed by GitHub
parent 0ca5760557
commit 40ad36f5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 212 additions and 76 deletions

View File

@ -19,7 +19,6 @@ before:
- docker build -f build/zitadel/Dockerfile . -t zitadel-go-test --target go-codecov -o .artifacts/codecov
- docker build -f build/zitadel/Dockerfile . -t zitadel-go-base --target go-copy -o .artifacts/grpc/go-client
- sh -c "cp -r .artifacts/grpc/go-client/* ."
- docker build -f build/console/Dockerfile . -t zitadel-npm-base --target npm-copy -o .artifacts/grpc/js-client
- docker build -f build/console/Dockerfile . -t zitadel-npm-console --target angular-export -o .artifacts/console
- sh -c "cp -r .artifacts/console/* internal/api/ui/console/static/"
@ -33,8 +32,7 @@ builds:
goarch:
- amd64
- arm64
ldflags:
-s -w -X github.com/zitadel/zitadel/cmd/build.version={{.Version}} -X github.com/zitadel/zitadel/cmd/build.commit={{.Commit}} -X github.com/zitadel/zitadel/cmd/build.date={{.Date}}
ldflags: -s -w -X github.com/zitadel/zitadel/cmd/build.version={{.Version}} -X github.com/zitadel/zitadel/cmd/build.commit={{.Commit}} -X github.com/zitadel/zitadel/cmd/build.date={{.Date}}
dist: .artifacts/goreleaser
@ -70,9 +68,8 @@ docker_manifests:
- ghcr.io/zitadel/zitadel:{{ .Tag }}-amd64
- ghcr.io/zitadel/zitadel:{{ .Tag }}-arm64
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
replacements:
darwin: Darwin
linux: Linux
@ -90,14 +87,14 @@ gomod:
proxy: false
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
brews:
- tap:
@ -125,4 +122,4 @@ brews:
announce:
discord:
enabled: true
message_template: 'ZITADEL {{ .Tag }} is ready! Check the notes: https://github.com/zitadel/zitadel/releases/tag/{{ .Tag }}'
message_template: "ZITADEL {{ .Tag }} is ready! Check the notes: https://github.com/zitadel/zitadel/releases/tag/{{ .Tag }}"

3
buf.work.yaml Normal file
View File

@ -0,0 +1,3 @@
version: v1
directories:
- proto

View File

@ -14,24 +14,14 @@ RUN npm ci
# Sources
COPY console .
COPY --from=zitadel-base:local /proto /proto
COPY --from=zitadel-base:local /usr/local/bin /usr/local/bin/.
COPY build/console build/console/
RUN build/console/generate-grpc.sh
#######################
## copy for local dev
#######################
FROM scratch as npm-copy
COPY --from=npm-base /console/src/app/proto/generated /console/src/app/proto/generated
COPY proto/ /proto/
#######################
## angular lint workspace and prod build
#######################
FROM npm-base as angular-build
RUN npm run lint
RUN npm run prodbuild
RUN npm run build
#######################
## Only Copy Assets

View File

@ -1,17 +0,0 @@
#!/bin/sh
set -eux
GEN_PATH=src/app/proto/generated
echo "Create folders"
mkdir -p $GEN_PATH
echo "Generate grpc"
protoc \
-I=/proto/include \
-I=node_modules/google-proto-files \
--js_out=import_style=commonjs,binary:$GEN_PATH \
--grpc-web_out=import_style=typescript,mode=grpcweb:$GEN_PATH \
$(find /proto/include -iname "*.proto")

1
console/.gitignore vendored
View File

@ -48,3 +48,4 @@ Thumbs.db
# Proto generated js files
src/app/proto

14
console/buf.gen.yaml Normal file
View File

@ -0,0 +1,14 @@
# buf.gen.yaml
version: v1
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/js
out: src/app/proto/generated
opt: import_style=commonjs,binary
- plugin: buf.build/grpc/web
out: src/app/proto/generated
opt: import_style=typescript,mode=grpcweb
- plugin: buf.build/grpc-ecosystem/openapiv2
out: src/app/proto/generated
opt: allow_delete_body

View File

@ -57,6 +57,7 @@
"@angular/cli": "^15.0.2",
"@angular/compiler-cli": "^15.0.2",
"@angular/language-service": "^15.0.4",
"@bufbuild/buf": "^1.14.0",
"@types/jasmine": "~4.3.0",
"@types/jasminewd2": "~2.0.10",
"@types/jsonwebtoken": "^9.0.0",
@ -2473,6 +2474,125 @@
"node": ">=6.9.0"
}
},
"node_modules/@bufbuild/buf": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf/-/buf-1.14.0.tgz",
"integrity": "sha512-hW6wua/V+goxF99TSoQ/ps/gLdLkyuMjUs6zm15rpNvYOqB5UNg3t4N29SOWqfGhwVU5eeAC2XubT24eVOCcRQ==",
"dev": true,
"hasInstallScript": true,
"bin": {
"buf": "bin/buf",
"protoc-gen-buf-breaking": "bin/protoc-gen-buf-breaking",
"protoc-gen-buf-lint": "bin/protoc-gen-buf-lint"
},
"engines": {
"node": ">=12"
},
"optionalDependencies": {
"@bufbuild/buf-darwin-arm64": "1.14.0",
"@bufbuild/buf-darwin-x64": "1.14.0",
"@bufbuild/buf-linux-aarch64": "1.14.0",
"@bufbuild/buf-linux-x64": "1.14.0",
"@bufbuild/buf-win32-arm64": "1.14.0",
"@bufbuild/buf-win32-x64": "1.14.0"
}
},
"node_modules/@bufbuild/buf-darwin-arm64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-darwin-arm64/-/buf-darwin-arm64-1.14.0.tgz",
"integrity": "sha512-V6WonyHSLtrCd+xl5XAqzpDXUMLhJF3seVD6ap4yJW6nigHw49+Oz38oE0DgwOlkIOoNgS8TWsRZFUyBXfV9vQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@bufbuild/buf-darwin-x64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-darwin-x64/-/buf-darwin-x64-1.14.0.tgz",
"integrity": "sha512-ZhPc0mN7K8E8IJGWzdCxb5CHqwmv3HSB25IgEjqTkwCDIUV7cPIUfb/56G6ir0shWCcVRoGPv2KbSG5rL0AYIw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@bufbuild/buf-linux-aarch64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-linux-aarch64/-/buf-linux-aarch64-1.14.0.tgz",
"integrity": "sha512-M7La4zzSXGgIwhKclZFgh5OXvKkx5/1fsGKTJWfDL25xPMYrvZI7y1i44iOK5H8ciKe24fatITZHE0ZQVRohoQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@bufbuild/buf-linux-x64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-linux-x64/-/buf-linux-x64-1.14.0.tgz",
"integrity": "sha512-/fqaKAUpFNbP6A2ROU/r35R2Fxig55MtseYtHNSLcQI6k9ubhdVsI3cM0MlOZ1VawclDYFiTpCd1urUL7spvsw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@bufbuild/buf-win32-arm64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-win32-arm64/-/buf-win32-arm64-1.14.0.tgz",
"integrity": "sha512-t7cd8MfqJ2ew6uXUYVbgq97OzN/ybnJ5Q5yKbEGexkyOBHQZsEhv0FkJWkAn1DN93j5iqHO6xlDkHpGMjAW1sg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@bufbuild/buf-win32-x64": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@bufbuild/buf-win32-x64/-/buf-win32-x64-1.14.0.tgz",
"integrity": "sha512-KD0T1rkX7yfykKZodnAj2WxhIZfkA/sox6VAY20F6X6ckLP96/3TSVWvDPfDN2DNkTcmokygNtA2/ir0KejDfQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@colors/colors": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",

View File

@ -4,11 +4,11 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"prodbuild": "ng build --configuration production --base-href=/ui/console/",
"build": "ng build --configuration production --base-href=/ui/console/",
"prelint": "npm run generate",
"lint": "ng lint && prettier --check src",
"lint:fix": "prettier --write src",
"generate": "DOCKER_BUILDKIT=1 docker build -f ../build/grpc/Dockerfile -t zitadel-base:local .. && DOCKER_BUILDKIT=1 docker build -f ../build/console/Dockerfile .. --target npm-copy -o .."
"generate": "buf generate ../proto --include-imports --include-wkt"
},
"private": true,
"dependencies": {
@ -61,6 +61,7 @@
"@angular/cli": "^15.0.2",
"@angular/compiler-cli": "^15.0.2",
"@angular/language-service": "^15.0.4",
"@bufbuild/buf": "^1.14.0",
"@types/jasmine": "~4.3.0",
"@types/jasminewd2": "~2.0.10",
"@types/jsonwebtoken": "^9.0.0",

15
proto/buf.lock Normal file
View File

@ -0,0 +1,15 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 6607b10f00ed4a3d98f906807131c44a
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 75b4300737fb4efca0831636be94e517
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: a1ecdc58eccd49aa8bea2a7a9022dc27

12
proto/buf.yaml Normal file
View File

@ -0,0 +1,12 @@
version: v1
name: buf.build/zitadel/zitadel
deps:
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
lint:
use:
- MINIMAL