Merge pull request #277643 from Sorixelle/zitadel-fixes

zitadel: 2.40.3 -> 2.42.10, build fixes and cleanup
This commit is contained in:
Domen Kožar 2024-02-02 16:38:05 +00:00 committed by GitHub
commit 0efa801784
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 89 additions and 16 deletions

View File

@ -0,0 +1,37 @@
{ stdenv, lib, buildBazelPackage, bazel_6, fetchFromGitHub, darwin }:
buildBazelPackage rec {
pname = "protoc-gen-js";
version = "3.21.2";
src = fetchFromGitHub {
owner = "protocolbuffers";
repo = "protobuf-javascript";
rev = "v${version}";
hash = "sha256-TmP6xftUVTD7yML7UEM/DB8bcsL5RFlKPyCpcboD86U=";
};
bazel = bazel_6;
bazelTargets = [ "generator:protoc-gen-js" ];
bazelBuildFlags = lib.optionals stdenv.cc.isClang [ "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" ];
removeRulesCC = false;
removeLocalConfigCC = false;
LIBTOOL = lib.optionalString stdenv.isDarwin "${darwin.cctools}/bin/libtool";
fetchAttrs.sha256 = "sha256-H0zTMCMFct09WdR/mzcs9FcC2OU/ZhGye7GAkx4tGa8=";
buildAttrs.installPhase = ''
mkdir -p $out/bin
install -Dm755 bazel-bin/generator/protoc-gen-js $out/bin/
'';
meta = with lib; {
description = "Protobuf plugin for generating JavaScript code";
homepage = "https://github.com/protocolbuffers/protobuf-javascript";
platforms = platforms.linux ++ platforms.darwin;
license = with licenses; [ asl20 bsd3 ];
sourceProvenance = [ sourceTypes.fromSource ];
maintainers = with maintainers; [ Sorixelle ];
};
}

View File

@ -0,0 +1,21 @@
diff --git a/console/buf.gen.yaml b/console/buf.gen.yaml
index 1737c2ded..d6affa8bc 100644
--- a/console/buf.gen.yaml
+++ b/console/buf.gen.yaml
@@ -3,12 +3,12 @@ version: v1
managed:
enabled: true
plugins:
- - plugin: buf.build/protocolbuffers/js
+ - plugin: js
out: src/app/proto/generated
opt: import_style=commonjs,binary
- - plugin: buf.build/grpc/web
+ - plugin: grpc-web
out: src/app/proto/generated
opt: import_style=typescript,mode=grpcweb
- - plugin: buf.build/grpc-ecosystem/openapiv2
+ - plugin: openapiv2
out: src/app/proto/generated
opt: allow_delete_body
\ No newline at end of file

View File

@ -6,15 +6,24 @@
{ mkYarnPackage { mkYarnPackage
, fetchYarnDeps , fetchYarnDeps
, lib , lib
, grpc-gateway
, protoc-gen-grpc-web
, protoc-gen-js
}: }:
let let
protobufGenerated = generateProtobufCode { protobufGenerated = generateProtobufCode {
pname = "zitadel-console"; pname = "zitadel-console";
nativeBuildInputs = [
grpc-gateway
protoc-gen-grpc-web
protoc-gen-js
];
workDir = "console"; workDir = "console";
bufArgs = "../proto --include-imports --include-wkt"; bufArgs = "../proto --include-imports --include-wkt";
outputPath = "src/app/proto"; outputPath = "src/app/proto";
hash = "sha256-NmlKjKWxmqatyR6OitlQ7bfl6U6PS6KWqTALwX42HS4="; hash = "sha256-h/5K6PvEFyjzS5p7SfuDIk91TkN1iPc+iXor8T/QSeE=";
}; };
in in
mkYarnPackage rec { mkYarnPackage rec {
@ -26,7 +35,7 @@ mkYarnPackage rec {
packageJSON = ./package.json; packageJSON = ./package.json;
offlineCache = fetchYarnDeps { offlineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock"; yarnLock = "${src}/yarn.lock";
hash = "sha256-rSKoIznYVDNgrBmut7YSxNhgPJnbIeO+/s0HnrYWPUc="; hash = "sha256-cfo2WLSbfU8tYADjF7j9zTLNsboVThF6MUBrb49MrII=";
}; };
postPatch = '' postPatch = ''

View File

@ -25,8 +25,11 @@
"@angular/router": "^16.2.5", "@angular/router": "^16.2.5",
"@angular/service-worker": "^16.2.5", "@angular/service-worker": "^16.2.5",
"@ctrl/ngx-codemirror": "^6.1.0", "@ctrl/ngx-codemirror": "^6.1.0",
"@fortawesome/angular-fontawesome": "^0.13.0",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@grpc/grpc-js": "^1.9.3", "@grpc/grpc-js": "^1.9.3",
"@ngx-translate/core": "^14.0.0", "@ngx-translate/core": "^15.0.0",
"angular-oauth2-oidc": "^15.0.1", "angular-oauth2-oidc": "^15.0.1",
"angularx-qrcode": "^16.0.0", "angularx-qrcode": "^16.0.0",
"buffer": "^6.0.3", "buffer": "^6.0.3",
@ -34,18 +37,18 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"flag-icons": "^6.7.0", "flag-icons": "^6.7.0",
"google-proto-files": "^3.0.3", "google-proto-files": "^4.0.0",
"google-protobuf": "^3.21.2", "google-protobuf": "^3.21.2",
"grpc-web": "^1.4.1", "grpc-web": "^1.4.1",
"i18n-iso-countries": "^7.6.0", "i18n-iso-countries": "^7.6.0",
"libphonenumber-js": "^1.10.30", "libphonenumber-js": "^1.10.49",
"material-design-icons-iconfont": "^6.1.1", "material-design-icons-iconfont": "^6.1.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"ngx-color": "^9.0.0", "ngx-color": "^9.0.0",
"opentype.js": "^1.3.4", "opentype.js": "^1.3.4",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"tinycolor2": "^1.6.0", "tinycolor2": "^1.6.0",
"tslib": "^2.4.1", "tslib": "^2.6.2",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zone.js": "~0.13.1" "zone.js": "~0.13.1"
}, },
@ -60,11 +63,11 @@
"@angular/compiler-cli": "^16.2.5", "@angular/compiler-cli": "^16.2.5",
"@angular/language-service": "^16.2.5", "@angular/language-service": "^16.2.5",
"@bufbuild/buf": "^1.23.1", "@bufbuild/buf": "^1.23.1",
"@types/file-saver": "^2.0.2", "@types/file-saver": "^2.0.7",
"@types/google-protobuf": "^3.15.3", "@types/google-protobuf": "^3.15.3",
"@types/jasmine": "~4.3.6", "@types/jasmine": "~4.3.6",
"@types/jasminewd2": "~2.0.10", "@types/jasminewd2": "~2.0.10",
"@types/jsonwebtoken": "^9.0.1", "@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.7.0", "@types/node": "^20.7.0",
"@types/opentype.js": "^1.3.4", "@types/opentype.js": "^1.3.4",
"@types/qrcode": "^1.5.2", "@types/qrcode": "^1.5.2",
@ -83,6 +86,6 @@
"prettier": "^3.0.3", "prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.2", "prettier-plugin-organize-imports": "^3.2.2",
"protractor": "~7.0.0", "protractor": "~7.0.0",
"typescript": "^4.9.5" "typescript": "^5.1.6"
} }
} }

View File

@ -15,14 +15,14 @@
}: }:
let let
version = "2.40.3"; version = "2.42.10";
zitadelRepo = fetchFromGitHub { zitadelRepo = fetchFromGitHub {
owner = "zitadel"; owner = "zitadel";
repo = "zitadel"; repo = "zitadel";
rev = "v${version}"; rev = "v${version}";
hash = "sha256-WqsK6DAYkLs5wBNvkVGarLMm/unBLtipFkl07pR90HI="; hash = "sha256-Uv0iEIFkTdBAi0WDBQHf0ATs4L2FOU4NmiE9p1MHSa0=";
}; };
goModulesHash = "sha256-IVf1YVnhyEYgZqM31Cv3aBFnPG7v5WW6fCEvlN+sTIE="; goModulesHash = "sha256-PQch046YjYhAmVlNNdgDLWIqFvEpXRgXAYFMwSZmk4w=";
buildZitadelProtocGen = name: buildZitadelProtocGen = name:
buildGoModule { buildGoModule {
@ -62,6 +62,7 @@ let
name = "${pname}-buf-generated"; name = "${pname}-buf-generated";
src = zitadelRepo; src = zitadelRepo;
patches = [ ./console-use-local-protobuf-plugins.patch ];
nativeBuildInputs = nativeBuildInputs ++ [ buf ]; nativeBuildInputs = nativeBuildInputs ++ [ buf ];
@ -91,7 +92,7 @@ let
protoc-gen-zitadel protoc-gen-zitadel
]; ];
outputPath = ".artifacts"; outputPath = ".artifacts";
hash = "sha256-xrEF1B4pMoCZs1WO9F6IoqHnSyt5BhPVTIABMWK/q2E="; hash = "sha256-3qDVY2CvtY8lZDr+p5i0vV6zZ5KyTtxBLyV7Os9KuIw=";
}; };
in in
buildGoModule rec { buildGoModule rec {
@ -104,10 +105,11 @@ buildGoModule rec {
proxyVendor = true; proxyVendor = true;
vendorHash = goModulesHash; vendorHash = goModulesHash;
ldflags = [ "-X 'github.com/zitadel/zitadel/cmd/build.version=${version}'" ];
# Adapted from Makefile in repo, with dependency fetching and protobuf codegen # Adapted from Makefile in repo, with dependency fetching and protobuf codegen
# bits removed # bits removed
buildPhase = '' preBuild = ''
mkdir -p pkg/grpc mkdir -p pkg/grpc
cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc
mkdir -p openapi/v2/zitadel mkdir -p openapi/v2/zitadel
@ -122,12 +124,13 @@ buildGoModule rec {
go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md
cp -r ${passthru.console}/* internal/api/ui/console/static cp -r ${passthru.console}/* internal/api/ui/console/static
CGO_ENABLED=0 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.version=${version}'"
''; '';
doCheck = false;
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -Dm755 zitadel $out/bin/ install -Dm755 $GOPATH/bin/zitadel $out/bin/
''; '';
passthru = { passthru = {