fix(zitadel-image): refactor dockerfiles and gh action (#2027)

* early prototyp

* fix some errors

* remove docker image cache

* add comment

* add false

* typo

* test cache speed

* upload artifact

* remove tag

* seperate after build step

* debug

* debug

* debug

* debug

* debug

* test gh

* test

* test

* test

* test

* test golang

* test go

* test with release image

* fix

* use scratch to export

* test

* fix path

* ref

* typo

* debug

* test

* debug

* speed up docker

* test

* debug

* debug

* try scope

* test cache

* restore cache

* reenable operator build

* fix duplicate

* fix buildpush version

* test cache

* improve caching

* test release IF

* only run console and zitadel without dispatch

* test with reworked operator

* testing without release step

* lint yaml

* fix if

* improve wording

* enable release step & only notify sentry on main

* console from file system

* update docker file paths

* remove migration line

* add statik for operator

* console files using go 1.15

* fix console default path

* improve code QL

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Florian Forster 2021-07-27 14:34:56 +02:00 committed by GitHub
parent e546988d2f
commit 8d96f1a895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 459 additions and 604 deletions

View File

@ -1,13 +1,14 @@
.git
/.git/
.codecov
.github
/.github/
.gitignore
.dockerignore
k8s
docs
console/node_modules
console/src/app/proto/generated
console/tmp
**/Dockerfile
/k8s/
/docs/
/console/node_modules/
/console/src/app/proto/generated/
/console/tmp/
.releaserc.js
changelog.config.js
CONTRIBUTING.md

View File

@ -2,57 +2,40 @@ name: "Code scanning - action"
on:
push:
branches: [main, ]
branches:
- 'main'
paths-ignore:
- 'docs/**'
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
branches:
- 'main'
paths-ignore:
- 'docs/**'
schedule:
- cron: '0 12 * * 2'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with:
languages: go, javascript
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@ -1,233 +0,0 @@
name: ZITADEL PR
on:
pull_request:
branches:
- '**'
env:
REGISTRY: ghcr.io
NODE_VERSION: '12'
GO_VERSION: '1.15'
OPERATOR_IMAGE_NAME: ${{ github.repository }}-operator
CRDB_IMAGE_NAME: ${{ github.repository }}-crbackup
ARTIFACTS_FOLDER: './artifacts'
jobs:
refs:
name: Prepare CI Vars
runs-on: ubuntu-18.04
outputs:
sha_short: ${{ steps.refs.outputs.sha_short }}
short_ref: ${{ steps.refs.outputs.short_ref }}
version: ${{ steps.refs.outputs.version }}
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v2
with:
dry_run: true
semantic_version: 17.0.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set outputs
id: refs
run: |
export BRANCH=${GITHUB_REF#refs/*/}
echo "branch: ${BRANCH}"
export BRANCHTRANSLATED=$(echo ${BRANCH} | tr '/' '_')
echo "short_ref: ${BRANCHTRANSLATED}"
export VERSION=""
if ${{ steps.semantic.outputs.new_release_published == 'true' }}; then
export VERSION=${{ steps.semantic.outputs.new_release_version }}
else
export VERSION=${BRANCHTRANSLATED}
fi
echo "New semantic release: ${{ steps.semantic.outputs.new_release_published }}"
echo "version: ${VERSION}"
echo "::set-output name=short_ref::${BRANCHTRANSLATED}"
echo "::set-output name=sha_short::SHA-$(git rev-parse --short=12 HEAD)"
echo "::set-output name=version::${VERSION}"
zitadel-image:
name: Build ZITADEL
needs: refs
runs-on: ubuntu-18.04
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-zitadel-${{ hashFiles('**/go.sum', 'console/package-lock.json', 'build/dockerfile') }}
restore-keys: |
${{ runner.os }}-zitadel-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- run: ls -la
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ github.repository }}:${{ needs.refs.outputs.short_ref }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:coverage
push: false
cache-from: type=local,src=/tmp/.buildx-cache-new
target: go-codecov
outputs: type=local,dest=/tmp/zitadel
- uses: codecov/codecov-action@v1
with:
files: /tmp/zitadel/profile.cov
name: codecov-go
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
operator-image:
needs: refs
runs-on: ubuntu-18.04
name: Build ZITADEL Operator ${{ matrix.goos }}-${{ matrix.goarch }}
strategy:
matrix:
goos: [ 'linux', 'darwin', 'windows' ]
goarch: [ 'amd64' ]
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ matrix.goos }}-${{ matrix.goarch }}-operator-image-${{ hashFiles('**/go.sum', 'build/operator/Dockerfile') }}
restore-keys: |
${{ matrix.goos }}-${{ matrix.goarch }}-operator-image-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- uses: docker/build-push-action@v2
name: onlybuild
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
outputs: type=local,dest=/tmp/operator
build-args: |
OS=${{ matrix.goos }}
ARCH=${{ matrix.goarch }}
VERSION=${{ needs.refs.outputs.version }}
GITHUBOAUTHCLIENTID=${{ secrets.GITHUBOAUTHCLIENTID }}
GITHUBOAUTHCLIENTSECRET=${{ secrets.GITHUBOAUTHCLIENTSECRET }}
- shell: bash
run: |
mv /tmp/operator/zitadelctl /tmp/operator/zitadelctl-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: actions/upload-artifact@v2
with:
name: zitadelctl-${{ matrix.goos }}-${{ matrix.goarch }}
path: /tmp/operator/zitadelctl-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: docker/build-push-action@v2
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
name: buildandpush
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache-new
build-args: |
OS=${{ matrix.goos }}
ARCH=${{ matrix.goarch }}
VERSION=${{ needs.refs.outputs.version }}
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:coverage
push: false
cache-from: type=local,src=/tmp/.buildx-cache-new
target: go-codecov
outputs: type=local,dest=/tmp/operator
- uses: codecov/codecov-action@v1
with:
files: /tmp/operator/profile.cov
name: codecov-go
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
crdb-image:
name: Build CockroachDB Image
needs: refs
runs-on: ubuntu-18.04
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-crdb-image-${{ hashFiles('build/cr-backup/Dockerfile') }}
restore-keys: |
${{ runner.os }}-crdb-image-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- uses: docker/build-push-action@v2
name: buildandpush
with:
context: .
file: ./build/cr-backup/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.CRDB_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.CRDB_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache

View File

@ -2,15 +2,13 @@ name: ZITADEL Release
on:
push:
branches:
- 'main'
- '**'
tags-ignore:
- '**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
NODE_VERSION: '12'
GO_VERSION: '1.15'
OPERATOR_IMAGE_NAME: ${{ github.repository }}-operator
CRDB_IMAGE_NAME: ${{ github.repository }}-crbackup
ARTIFACTS_FOLDER: './artifacts'
@ -56,65 +54,130 @@ jobs:
echo "::set-output name=sha_short::SHA-$(git rev-parse --short=12 HEAD)"
echo "::set-output name=version::${VERSION}"
zitadel-image:
zitadel:
name: Build ZITADEL
needs: refs
runs-on: ubuntu-18.04
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-zitadel-${{ hashFiles('**/go.sum', 'console/package-lock.json', 'build/dockerfile') }}
restore-keys: |
${{ runner.os }}-zitadel-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/zitadel/Dockerfile
platforms: linux/amd64
cache-from: type=gha,scope=zitadel
cache-to: type=gha,mode=max,scope=zitadel
outputs: type=local,dest=/tmp/zitadel
- uses: actions/upload-artifact@v2
with:
name: zitadel
path: /tmp/zitadel/
zitadel-codecov:
name: Upload ZITADEL Codecov
needs: [refs, zitadel]
runs-on: ubuntu-18.04
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/zitadel/Dockerfile
platforms: linux/amd64
target: go-codecov
cache-from: type=gha,scope=zitadel
outputs: type=local,dest=/tmp/zitadel
- uses: codecov/codecov-action@v1
with:
name: zitadel-codecov
files: /tmp/zitadel/profile.cov
zitadel-console:
name: Build ZITADEL Console
needs: refs
runs-on: ubuntu-18.04
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/console/Dockerfile
platforms: linux/amd64
cache-from: type=gha,scope=zitadel-console
cache-to: type=gha,mode=max,scope=zitadel-console
outputs: type=local,dest=/tmp/zitadel-console
- uses: actions/upload-artifact@v2
with:
name: zitadel-console
path: /tmp/zitadel-console/
zitadel-image:
name: Package ZITADEL Image
needs: [refs, zitadel, zitadel-console]
runs-on: ubuntu-18.04
if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
steps:
- name: Source checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: zitadel
path: .download/zitadel
- uses: actions/download-artifact@v2
with:
name: zitadel-console
path: .download/zitadel/console
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- run: ls -la
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfile
file: ./build/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ github.repository }}:${{ needs.refs.outputs.short_ref }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:coverage
push: false
cache-from: type=local,src=/tmp/.buildx-cache-new
target: go-codecov
outputs: type=local,dest=/tmp/zitadel
- uses: codecov/codecov-action@v1
with:
files: /tmp/zitadel/profile.cov
name: codecov-go
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
cache-from: type=gha,scope=zitadel-image
cache-to: type=gha,mode=max,scope=zitadel-image
operator-image:
zitadel-operator:
name: Build ZITADEL Operator ${{ matrix.goos }}-${{ matrix.goarch }}
needs: refs
runs-on: ubuntu-18.04
name: Build ZITADEL Operator ${{ matrix.goos }}-${{ matrix.goarch }}
strategy:
matrix:
goos: [ 'linux', 'darwin', 'windows' ]
@ -122,33 +185,22 @@ jobs:
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ matrix.goos }}-${{ matrix.goarch }}-operator-image-${{ hashFiles('**/go.sum', 'build/operator/Dockerfile') }}
restore-keys: |
${{ matrix.goos }}-${{ matrix.goarch }}-operator-image-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- uses: docker/build-push-action@v2
name: onlybuild
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-from: type=gha,scope=${{ matrix.goos }}-${{ matrix.goarch }}
cache-to: type=gha,mode=max,scope=${{ matrix.goos }}-${{ matrix.goarch }}
outputs: type=local,dest=/tmp/operator
build-args: |
OS=${{ matrix.goos }}
@ -163,61 +215,97 @@ jobs:
with:
name: zitadelctl-${{ matrix.goos }}-${{ matrix.goarch }}
path: /tmp/operator/zitadelctl-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: docker/build-push-action@v2
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
name: buildandpush
zitadel-operator-codecov:
name: Upload ZITADEL Operator Codecov ${{ matrix.goos }}-${{ matrix.goarch }}
needs: [refs, zitadel-operator]
runs-on: ubuntu-18.04
strategy:
matrix:
goos: [ 'linux' ]
goarch: [ 'amd64' ]
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache-new
build-args: |
OS=${{ matrix.goos }}
ARCH=${{ matrix.goarch }}
VERSION=${{ needs.refs.outputs.version }}
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ github.repository }}:coverage
push: false
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-from: type=gha,scope=${{ matrix.goos }}-${{ matrix.goarch }}
target: go-codecov
outputs: type=local,dest=/tmp/operator
- uses: codecov/codecov-action@v1
with:
files: /tmp/operator/profile.cov
name: codecov-go
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
crdb-image:
name: Build CockroachDB Image
needs: refs
zitadel-operator-image:
name: Package ZITADEL Operator Image ${{ matrix.goos }}-${{ matrix.goarch }}
needs: [refs, zitadel-operator]
runs-on: ubuntu-18.04
if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
strategy:
matrix:
goos: [ 'linux' ]
goarch: [ 'amd64' ]
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-crdb-image-${{ hashFiles('build/cr-backup/Dockerfile') }}
restore-keys: |
${{ runner.os }}-crdb-image-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
- uses: docker/build-push-action@v2
with:
context: .
file: ./build/operator/Dockerfile
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.OPERATOR_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: true
cache-from: type=gha,scope=${{ matrix.goos }}-${{ matrix.goarch }}
build-args: |
OS=${{ matrix.goos }}
ARCH=${{ matrix.goarch }}
VERSION=${{ needs.refs.outputs.version }}
crdb-image:
name: Package ZITADEL CockroachDB Image
needs: refs
runs-on: ubuntu-18.04
if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
steps:
- name: Source checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
## Workaround until https://github.com/docker/build-push-action/issues/252#issuecomment-804898823 is merged
version: v0.6.0-rc1
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- name: Login to DockerHub
uses: docker/login-action@v1
with:
@ -232,13 +320,14 @@ jobs:
platforms: linux/amd64
tags: ${{ env.REGISTRY }}/${{ env.CRDB_IMAGE_NAME }}:${{ needs.refs.outputs.sha_short }},${{ env.REGISTRY }}/${{ env.CRDB_IMAGE_NAME }}:${{ needs.refs.outputs.short_ref }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
cache-from: type=gha,scope=zitadel-cockroachdb
cache-to: type=gha,mode=max,scope=zitadel-cockroachdb
release:
name: Semantic Release Images and Artifacts
runs-on: ubuntu-18.04
needs: [ refs, zitadel-image, operator-image, crdb-image ]
needs: [ refs, zitadel-image, zitadel-operator-image, crdb-image ]
if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' }}
env:
DOCKER_USERNAME: ${{ github.repository_owner }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
@ -335,8 +424,8 @@ jobs:
prerelease: true
draft: false
allowUpdates: true
- uses: actions/checkout@v2
- name: Create Sentry release
if: ${{ github.ref == 'refs/heads/main' }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

View File

@ -97,7 +97,6 @@ Delegate the right to assign roles to another organization
Customize login and console with your design
![private_labeling](https://user-images.githubusercontent.com/1366906/123089110-d148ff80-d426-11eb-9598-32b506f6d4fd.gif)
## How To Contribute
Details about how to contribute you can find in the [Contribution Guide](CONTRIBUTING.md)

86
build/console/Dockerfile Normal file
View File

@ -0,0 +1,86 @@
ARG NODE_VERSION=14
#######################
## These steps set platform / arch type specific variables
#######################
FROM alpine:3 AS arm64-base
ENV PROTOC_ARCH aarch_64
FROM alpine:3 AS amd64-base
ENV PROTOC_ARCH x86_64
#######################
## This step sets up the folder structure,
## initalices go mods,
## downloads the protofiles,
## protoc and protoc-gen-grpc-web for later use
#######################
FROM ${BUILDARCH}-base AS base
ARG PROTOC_VERSION=3.13.0
ARG PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip
ARG GRPC_WEB_VERSION=1.2.1
# no arm specific version available and x86 works fine at the moment:
ARG GRPC_WEB=protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64
RUN apk add tar curl
WORKDIR /proto
#protoc
RUN apk add tar curl \
&& curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /proto include/* \
&& rm -f $PROTOC_ZIP \
&& curl -OL https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/${GRPC_WEB} \
&& mv ${GRPC_WEB} /usr/local/bin/protoc-gen-grpc-web \
&& chmod +x /usr/local/bin/protoc-gen-grpc-web \
&& curl https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/v0.4.1/validate/validate.proto --create-dirs -o include/validate/validate.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/annotations.proto --create-dirs -o include/protoc-gen-openapiv2/options/annotations.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/openapiv2.proto --create-dirs -o include/protoc-gen-openapiv2/options/openapiv2.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto --create-dirs -o include/google/api/annotations.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto --create-dirs -o include/google/api/http.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/field_behavior.proto --create-dirs -o include/google/api/field_behavior.proto
#zitadel protos
COPY proto/ include/.
#######################
## With this step we prepare all node_modules, this helps caching the build
## Speed up this step by mounting your local node_modules directory
#######################
FROM node:${NODE_VERSION} as npm-base
WORKDIR /console
COPY console/package.json console/package-lock.json ./
RUN npm install
COPY console .
COPY --from=base /proto /proto
COPY --from=base /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
#######################
## angular dev build
#######################
FROM npm-base as dev-angular-build
RUN npm install -g @angular/cli
#######################
## angular lint workspace and prod build
#######################
FROM npm-base as prod-angular-build
RUN npm run lint
RUN npm run prodbuild
#######################
## Only Copy Assets
#######################
FROM scratch as prod-angular-export
COPY --from=prod-angular-build /console/dist/console .

View File

@ -1,3 +0,0 @@
{
"lockfileVersion": 1
}

View File

@ -1,226 +1,13 @@
ARG GO_VERSION=1.15.8
ARG NODE_VERSION=14.17.0
ARG ENV=prod
#######################
## These steps set platform / arch type specific variables
#######################
FROM alpine AS arm64-base
ENV PROTOC_ARCH aarch_64
FROM alpine AS amd64-base
ENV PROTOC_ARCH x86_64
#######################
## This step sets up the folder structure,
## initalices go mods,
## downloads the protofiles,
## protoc and protoc-gen-grpc-web for later use
#######################
FROM ${BUILDARCH}-base AS base
ARG PROTOC_VERSION=3.13.0
ARG PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip
ARG GRPC_WEB_VERSION=1.2.1
# no arm specific version available and x86 works fine at the moment:
ARG GRPC_WEB=protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64
RUN apk add tar curl
WORKDIR /proto
#protoc
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /proto include/* \
&& rm -f $PROTOC_ZIP
#grpc web
RUN curl -OL https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/${GRPC_WEB} \
&& mv ${GRPC_WEB} /usr/local/bin/protoc-gen-grpc-web \
&& chmod +x /usr/local/bin/protoc-gen-grpc-web
#proto dependencies
RUN curl https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/v0.4.1/validate/validate.proto --create-dirs -o include/validate/validate.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/annotations.proto --create-dirs -o include/protoc-gen-openapiv2/options/annotations.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/openapiv2.proto --create-dirs -o include/protoc-gen-openapiv2/options/openapiv2.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto --create-dirs -o include/google/api/annotations.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto --create-dirs -o include/google/api/http.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/field_behavior.proto --create-dirs -o include/google/api/field_behavior.proto
#zitadel protos
COPY proto/ include/.
#######################
## With this step we prepare all node_modules, this helps caching the build
## Speed up this step by mounting your local node_modules directory
#######################
FROM node:${NODE_VERSION} as npm-base
WORKDIR /console
COPY console/package.json console/package-lock.json ./
RUN npm install
COPY console .
COPY --from=base /proto /proto
COPY --from=base /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
#######################
## angular dev build
#######################
FROM npm-base as dev-angular-build
RUN npm install -g @angular/cli
#######################
## angular lint workspace and prod build
#######################
FROM npm-base as prod-angular-build
RUN npm run lint
RUN npm run prodbuild
#######################
## Go dependencies
## Speed up this step by mounting your local go mod pkg directory
#######################
FROM golang:${GO_VERSION} as go-dep
RUN mkdir -p src/github.com/caos/zitadel
WORKDIR /go/src/github.com/caos/zitadel
#download modules
COPY ./go.* .
RUN go mod download
# install tools
COPY tools ./tools
RUN ./tools/install.sh
#######################
## generates static files
#######################
FROM go-dep AS go-static
COPY internal/ui/login/static internal/ui/login/static
COPY internal/ui/login/statik internal/ui/login/statik
COPY internal/notification/static internal/notification/static
COPY internal/notification/statik internal/notification/statik
COPY internal/static internal/static
COPY internal/statik internal/statik
RUN go generate internal/ui/login/statik/generate.go \
&& go generate internal/ui/login/static/generate.go \
&& go generate internal/notification/statik/generate.go \
&& go generate internal/statik/generate.go
#######################
## generates grpc stub
#######################
FROM go-static AS go-stub
COPY --from=base /proto /proto
COPY --from=base /usr/local/bin /usr/local/bin/.
COPY build/zitadel/generate-grpc.sh build/zitadel/generate-grpc.sh
COPY internal/protoc internal/protoc
COPY openapi/statik openapi/statik
COPY internal/api/assets/generator internal/api/assets/generator
COPY internal/config internal/config
COPY internal/errors internal/errors
RUN build/zitadel/generate-grpc.sh \
&& go generate openapi/statik/generate.go \
&& mkdir -p docs/apis/assets/ \
&& go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md
#######################
## Go base build
#######################
FROM go-stub as go-base
# copy remaining zitadel files
COPY . .
#######################
## copy for local dev
#######################
FROM scratch as go-copy
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/ui/login/statik/statik.go internal/ui/login/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/notification/statik/statik.go internal/notification/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/statik/statik.go internal/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/statik/statik.go openapi/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/pkg/grpc pkg/grpc
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/v2/zitadel openapi/v2/zitadel
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/statik/statik.go openapi/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption/templates.gen.go internal/protoc/protoc-gen-authoption/templates.gen.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption/authoption/options.pb.go internal/protoc/protoc-gen-authoption/authoption/options.pb.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/docs/apis/proto docs/docs/apis/proto
COPY --from=go-stub /go/src/github.com/caos/zitadel/docs/apis/assets docs/docs/apis/assets
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/api/assets/authz.go ./internal/api/assets/authz.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/api/assets/router.go ./internal/api/assets/router.go
#######################
## Go test
#######################
FROM go-base as go-test
# Migrations for cockroach-secure
RUN go install github.com/rakyll/statik
RUN ./build/operator/prebuild.sh ./migrations
RUN go test -race -v -coverprofile=profile.cov $(go list ./... | grep -v /operator/)
#######################
## Go test results
#######################
FROM scratch as go-codecov
COPY --from=go-test /go/src/github.com/caos/zitadel/profile.cov profile.cov
#######################
## Go prod build
#######################
FROM go-test as prod-go-build
ARG BUILDARCH
#generate statik code for console
COPY --from=prod-angular-build console/dist/console console/dist/console/
RUN go generate internal/ui/console/statik/generate.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${BUILDARCH} go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o zitadel-linux-${BUILDARCH} cmd/zitadel/main.go
#######################
## Go dev build
#######################
FROM go-base as dev-go-build
ENTRYPOINT [ "go", "run", "cmd/zitadel/main.go" ]
#######################
## Final Production Image
#######################
FROM alpine:latest as artifact
FROM alpine:3 as artifact
ARG BUILDARCH
RUN adduser -D zitadel
COPY cmd/zitadel/*.yaml /app/
COPY --from=prod-go-build /go/src/github.com/caos/zitadel/zitadel-linux-${BUILDARCH} /app/zitadel
COPY .download/zitadel/zitadel-linux-${BUILDARCH} /app/zitadel
COPY .download/zitadel/console /app/console/
RUN chmod a+x /app/zitadel
RUN ls -la /
#######################
## Scratch Image

View File

@ -103,7 +103,7 @@ services:
- minio
build:
context: ../..
dockerfile: build/dockerfile
dockerfile: build/zitadel/Dockerfile
target: dev-go-build
args:
ENV: dev
@ -164,7 +164,7 @@ services:
- grpc-web-gateway
build:
context: ../..
dockerfile: build/dockerfile
dockerfile: build/console/Dockerfile
target: dev-angular-build
args:
ENV: dev

View File

@ -58,7 +58,7 @@ ZITADEL_CONSOLE_RESPONSE_TYPE=CODE
ZITADEL_CONSOLE_GRANT_TYPE=AUTHORIZATION_CODE
ZITADEL_CONSOLE_DEV_MODE=true
ZITADEL_CONSOLE_ENV_DIR=console/src/assets/
ZITADEL_CONSOLE_DIR=console/src/assets/
#minio configuration
ZITADEL_ASSET_STORAGE_ACCESS_KEY_ID=access_key

153
build/zitadel/Dockerfile Normal file
View File

@ -0,0 +1,153 @@
ARG GO_VERSION=1.15
#######################
## These steps set platform / arch type specific variables
#######################
FROM alpine:3 AS arm64-base
ENV PROTOC_ARCH aarch_64
FROM alpine:3 AS amd64-base
ENV PROTOC_ARCH x86_64
#######################
## This step sets up the folder structure,
## initalices go mods,
## downloads the protofiles,
## protoc and protoc-gen-grpc-web for later use
#######################
FROM ${BUILDARCH}-base AS base
ARG PROTOC_VERSION=3.13.0
ARG PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip
ARG GRPC_WEB_VERSION=1.2.1
# no arm specific version available and x86 works fine at the moment:
ARG GRPC_WEB=protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64
RUN apk add tar curl
WORKDIR /proto
#protoc
RUN apk add tar curl \
&& curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /proto include/* \
&& rm -f $PROTOC_ZIP \
&& curl -OL https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/${GRPC_WEB} \
&& mv ${GRPC_WEB} /usr/local/bin/protoc-gen-grpc-web \
&& chmod +x /usr/local/bin/protoc-gen-grpc-web \
&& curl https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/v0.4.1/validate/validate.proto --create-dirs -o include/validate/validate.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/annotations.proto --create-dirs -o include/protoc-gen-openapiv2/options/annotations.proto \
&& curl https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v2.2.0/protoc-gen-openapiv2/options/openapiv2.proto --create-dirs -o include/protoc-gen-openapiv2/options/openapiv2.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto --create-dirs -o include/google/api/annotations.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto --create-dirs -o include/google/api/http.proto \
&& curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/field_behavior.proto --create-dirs -o include/google/api/field_behavior.proto
#zitadel protos
COPY proto/ include/.
#######################
## Go dependencies
## Speed up this step by mounting your local go mod pkg directory
#######################
FROM golang:${GO_VERSION} as go-dep
RUN mkdir -p src/github.com/caos/zitadel
WORKDIR /go/src/github.com/caos/zitadel
#download modules
COPY ./go.* .
RUN go mod download
# install tools
COPY tools ./tools
RUN ./tools/install.sh
#######################
## generates static files
#######################
FROM go-dep AS go-static
COPY internal/ui/login/static internal/ui/login/static
COPY internal/ui/login/statik internal/ui/login/statik
COPY internal/notification/static internal/notification/static
COPY internal/notification/statik internal/notification/statik
COPY internal/static internal/static
COPY internal/statik internal/statik
RUN go generate internal/ui/login/statik/generate.go \
&& go generate internal/ui/login/static/generate.go \
&& go generate internal/notification/statik/generate.go \
&& go generate internal/statik/generate.go
#######################
## generates grpc stub
#######################
FROM go-static AS go-stub
COPY --from=base /proto /proto
COPY --from=base /usr/local/bin /usr/local/bin/.
COPY build/zitadel/generate-grpc.sh build/zitadel/generate-grpc.sh
COPY internal/protoc internal/protoc
COPY openapi/statik openapi/statik
COPY internal/api/assets/generator internal/api/assets/generator
COPY internal/config internal/config
COPY internal/errors internal/errors
RUN build/zitadel/generate-grpc.sh \
&& go generate openapi/statik/generate.go \
&& mkdir -p docs/apis/assets/ \
&& go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md
#######################
## Go base build
#######################
FROM go-stub as go-base
# copy remaining zitadel files
COPY . .
#######################
## copy for local dev
#######################
FROM scratch as go-copy
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/ui/login/statik/statik.go internal/ui/login/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/notification/statik/statik.go internal/notification/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/statik/statik.go internal/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/statik/statik.go openapi/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/pkg/grpc pkg/grpc
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/v2/zitadel openapi/v2/zitadel
COPY --from=go-stub /go/src/github.com/caos/zitadel/openapi/statik/statik.go openapi/statik/statik.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption/templates.gen.go internal/protoc/protoc-gen-authoption/templates.gen.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/protoc/protoc-gen-authoption/authoption/options.pb.go internal/protoc/protoc-gen-authoption/authoption/options.pb.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/docs/apis/proto docs/docs/apis/proto
COPY --from=go-stub /go/src/github.com/caos/zitadel/docs/apis/assets docs/docs/apis/assets
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/api/assets/authz.go ./internal/api/assets/authz.go
COPY --from=go-stub /go/src/github.com/caos/zitadel/internal/api/assets/router.go ./internal/api/assets/router.go
#######################
## Go test
#######################
FROM go-base as go-test
# Migrations for cockroach-secure
RUN go install github.com/rakyll/statik \
&& go test -race -v -coverprofile=profile.cov $(go list ./... | grep -v /operator/)
#######################
## Go test results
#######################
FROM scratch as go-codecov
COPY --from=go-test /go/src/github.com/caos/zitadel/profile.cov profile.cov
#######################
## Go prod build
#######################
FROM go-test as prod-go-build
ARG BUILDARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${BUILDARCH} go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o zitadel-linux-${BUILDARCH} cmd/zitadel/main.go
#######################
## Only Copy Assets
#######################
FROM scratch as prod-go-export
ARG BUILDARCH
COPY --from=prod-go-build /go/src/github.com/caos/zitadel/zitadel-linux-${BUILDARCH} .

View File

@ -289,7 +289,7 @@ UI:
Config:
MaxCacheSizeInByte: 52428800 #50MB
Console:
EnvOverwriteDir: $ZITADEL_CONSOLE_ENV_DIR
ConsoleOverwriteDir: $ZITADEL_CONSOLE_DIR
ShortCache:
MaxAge: $ZITADEL_SHORT_CACHE_MAXAGE
SharedMaxAge: $ZITADEL_SHORT_CACHE_SHARED_MAXAGE

View File

@ -19,7 +19,7 @@ This part is relevant if you start the backend or console without docker compose
This command generates the grpc stub for console into the folder console/src/app/proto/generated for local development.
```bash
DOCKER_BUILDKIT=1 docker build -f build/dockerfile . -t zitadel:gen-fe --target npm-copy -o .
DOCKER_BUILDKIT=1 docker build -f build/console/Dockerfile . -t zitadel:gen-fe --target npm-copy -o .
```
### Backend
@ -28,7 +28,7 @@ With this command you can generate the stub for the backend.
```bash
# generates grpc stub
DOCKER_BUILDKIT=1 docker build -f build/dockerfile . -t zitadel:gen-be --target go-copy -o .
DOCKER_BUILDKIT=1 docker build -f build/zitadel/Dockerfile . -t zitadel:gen-be --target go-copy -o .
# generates keys for cryptography
DOCKER_BUILDKIT=1 docker build --target copy-keys -f build/local/Dockerfile.keys . -o .keys
```

View File

@ -7,18 +7,15 @@ import (
"strings"
"time"
"github.com/rakyll/statik/fs"
"github.com/caos/zitadel/internal/api/http/middleware"
_ "github.com/caos/zitadel/internal/ui/console/statik"
)
type Config struct {
Port string
EnvOverwriteDir string
ShortCache middleware.CacheConfig
LongCache middleware.CacheConfig
CSPDomain string
Port string
ConsoleOverwriteDir string
ShortCache middleware.CacheConfig
LongCache middleware.CacheConfig
CSPDomain string
}
type spaHandler struct {
@ -26,9 +23,9 @@ type spaHandler struct {
}
const (
envRequestPath = "/assets/environment.json"
envDefaultDir = "/console/"
handlerPrefix = "/console"
envRequestPath = "/assets/environment.json"
consoleDefaultDir = "./console/"
handlerPrefix = "/console"
)
var (
@ -53,14 +50,11 @@ func (i *spaHandler) Open(name string) (http.File, error) {
}
func Start(config Config) (http.Handler, string, error) {
statikFS, err := fs.NewWithNamespace("console")
if err != nil {
return nil, "", err
}
envDir := envDefaultDir
if config.EnvOverwriteDir != "" {
envDir = config.EnvOverwriteDir
consoleDir := consoleDefaultDir
if config.ConsoleOverwriteDir != "" {
consoleDir = config.ConsoleOverwriteDir
}
consoleHTTPDir := http.Dir(consoleDir)
cache := AssetsCacheInterceptorIgnoreManifest(
config.ShortCache.MaxAge.Duration,
config.ShortCache.SharedMaxAge.Duration,
@ -69,8 +63,8 @@ func Start(config Config) (http.Handler, string, error) {
)
security := middleware.SecurityHeaders(csp(config.CSPDomain), nil)
handler := &http.ServeMux{}
handler.Handle("/", cache(security(http.FileServer(&spaHandler{statikFS}))))
handler.Handle(envRequestPath, cache(security(http.StripPrefix("/assets", http.FileServer(http.Dir(envDir))))))
handler.Handle("/", cache(security(http.FileServer(&spaHandler{consoleHTTPDir}))))
handler.Handle(envRequestPath, cache(security(http.StripPrefix("/assets", http.FileServer(consoleHTTPDir)))))
return handler, handlerPrefix, nil
}

View File

@ -1,3 +0,0 @@
package statik
//go:generate statik -src=../../../../console/dist/console -dest=.. -ns=console

2
statik/doc.go Normal file
View File

@ -0,0 +1,2 @@
//Package statik is needed for building migration files into binary
package statik