Remove all mentions of --external-assets

This commit is contained in:
garronej 2023-04-01 16:15:11 +02:00
parent 6787fb1838
commit 586f9ca077
6 changed files with 28 additions and 85 deletions

View file

@ -9,37 +9,20 @@ on:
jobs: jobs:
build: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event.head_commit.author.name != 'actions'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.3 - uses: actions/setup-node@v2
with:
node-version: '16'
- uses: bahmutov/npm-install@v1 - uses: bahmutov/npm-install@v1
- run: yarn build - run: yarn build
- run: echo $(node -e 'console.log(require("url").parse(require("./package.json").homepage).host)') > build/CNAME
- run: npx keycloakify - run: npx keycloakify
- uses: actions/upload-artifact@v2
with:
name: standalone_keycloak_theme
path: build_keycloak/target/*keycloak-theme*.jar
- run: npx keycloakify --external-assets
- uses: actions/upload-artifact@v2
with:
name: keycloak_theme
path: build_keycloak/target/*keycloak-theme*.jar
- uses: actions/upload-artifact@v2
with:
name: build
path: build
check_if_version_upgraded: check_if_version_upgraded:
name: Check if version upgrade name: Check if version upgrade
if: github.event_name == 'push' if: github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: test
outputs: outputs:
from_version: ${{ steps.step1.outputs.from_version }} from_version: ${{ steps.step1.outputs.from_version }}
to_version: ${{ steps.step1.outputs.to_version }} to_version: ${{ steps.step1.outputs.to_version }}
@ -53,29 +36,23 @@ jobs:
create_github_release: create_github_release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs: check_if_version_upgraded
- check_if_version_upgraded
# We create a release only if the version have been upgraded and we are on a default branch # We create a release only if the version have been upgraded and we are on a default branch
if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && github.event_name == 'push' if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && github.event_name == 'push'
steps: steps:
- uses: actions/download-artifact@v2 - uses: actions/checkout@v2
with: - uses: actions/setup-node@v2
name: keycloak_theme - uses: bahmutov/npm-install@v1
- run: mkdir jars - run: yarn build
- run: mv *keycloak-theme*.jar jars/keycloak-theme.jar - run: npx keycloakify
- uses: actions/download-artifact@v2 - run: mv build_keycloak/target/*keycloak-theme*.jar keycloak-theme.jar
with:
name: standalone_keycloak_theme
- run: mv *keycloak-theme*.jar jars/standalone-keycloak-theme.jar
- uses: softprops/action-gh-release@v1 - uses: softprops/action-gh-release@v1
with: with:
name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }}
tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }}
target_commitish: ${{ github.head_ref || github.ref }} target_commitish: ${{ github.head_ref || github.ref }}
generate_release_notes: true generate_release_notes: true
files: | files: keycloak-theme.jar
jars/keycloak-theme.jar
jars/standalone-keycloak-theme.jar
draft: false draft: false
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -114,16 +91,17 @@ jobs:
tags: ${{ steps.step1.outputs.docker_tags }} tags: ${{ steps.step1.outputs.docker_tags }}
file: Dockerfile.ci file: Dockerfile.ci
github_pages_app: github_pages:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:
- create_github_release - create_github_release
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/setup-node@v2
with: - uses: bahmutov/npm-install@v1
name: build - run: yarn build
path: build # We tell GitHub pages that our package.json["homepage"] field is our domain name.
- run: echo $(node -e 'console.log(require("url").parse(require("./package.json").homepage).host)') > build/CNAME
- run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git - run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,21 +0,0 @@
# This is an alternative Dockerfile
# that aims to be used in the CI pipeline.
# In this version we assume that the app have been build (yarn build that generate ./build/)
# prior and archived into a build.tar file present in the context.
# We do do that because
# 1) We want to avoid building the app twice, one for the docker image and one for the theme .tar
# 2) If we use keycloakify --external-assets we have to generate the theme from the build/ directory
# that is going to be in production. (CRA generates hashes, every build is different, even if the code is the same)
# build environment
FROM alpine as build
WORKDIR /app
#We use ADD instead of COPY because build/ is in .dockerignore
ADD build.tar .
COPY nginx.conf .
# production environment (copy pasted from ./Dockerfile)
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
CMD nginx -g 'daemon off;'

View file

@ -65,25 +65,14 @@ npx download-builtin-keycloak-theme
If you want an example of an app that put that setup in production checkout onyxia-ui: [the repo](https://github.com/InseeFrLab/onyxia-ui), [the login](https://auth.lab.sspcloud.fr/auth/realms/sspcloud/protocol/openid-connect/auth?client_id=onyxia&redirect_uri=https%3A%2F%2Fonyxia.lab.sspcloud.fr), [the app](https://datalab.sspcloud.fr). If you want an example of an app that put that setup in production checkout onyxia-ui: [the repo](https://github.com/InseeFrLab/onyxia-ui), [the login](https://auth.lab.sspcloud.fr/auth/realms/sspcloud/protocol/openid-connect/auth?client_id=onyxia&redirect_uri=https%3A%2F%2Fonyxia.lab.sspcloud.fr), [the app](https://datalab.sspcloud.fr).
# Standalone vs `--external-assets`
The CI creates two jars
- `keycloak-theme.jar`: Generated with `npx keycloakify --external-assets`, the assets, located `static/**/*`, like for example
`static/js/main.<hash>.js` will be downloaded from `https://starter.keycloakify.dev/static/js/main.<hash>.js` (`starter.keycloakify.dev` is
specified in the `package.json`.
- `standalone-keycloak-theme.jar`: Generated with `npx keycloakify`, this theme is fully standalone, all assets will be served by the
Keycloak server, for example `static/js/main.<hash>.js` will be downloaded from an url like `http://<your keycloak url>/resources/xxxx/login/keycloakify-starter/build/static/js/main.<hash>.js`.
More info on the `--external-assets` build option [here](https://docs.keycloakify.dev/v/v6/build-options#external-assets).
# Docker # Docker
```bash Instructions for building and running the react app (`src/App`) that is collocated with our Keycloak theme.
docker build -f Dockerfile -t codegouvfr/keycloakify-starter:test .
#OR (to reproduce how the image is built in the ci workflow):
yarn && yarn build && tar -cvf build.tar ./build && docker build -f Dockerfile.ci -t codegouvfr/keycloakify-starter:test . && rm build.tar
docker run -it -dp 8083:80 codegouvfr/keycloakify-starter:test ```bash
docker build -f Dockerfile -t keycloakify/keycloakify-starter:main .
docker run -it -dp 8083:80 keycloakify/keycloakify-starter:main
# You can access the app at http://localhost:8083
``` ```
# Standalone keycloak theme # Standalone keycloak theme

View file

@ -37,7 +37,7 @@
"evt": "^2.4.15", "evt": "^2.4.15",
"jwt-decode": "^3.1.2", "jwt-decode": "^3.1.2",
"keycloak-js": "^21.0.1", "keycloak-js": "^21.0.1",
"keycloakify": "^7.4.0", "keycloakify": "^7.5.0",
"powerhooks": "^0.26.7", "powerhooks": "^0.26.7",
"react": "18.1.0", "react": "18.1.0",
"react-dom": "18.1.0", "react-dom": "18.1.0",

View file

@ -20,10 +20,7 @@
<link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-medium-webfont.woff2" as="font" crossorigin="anonymous"> <link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-medium-webfont.woff2" as="font" crossorigin="anonymous">
<link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-regular-webfont.woff2" as="font" crossorigin="anonymous"> <link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-regular-webfont.woff2" as="font" crossorigin="anonymous">
<link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-semibold-webfont.woff2" as="font" crossorigin="anonymous"> <link rel="preload" href="%PUBLIC_URL%/fonts/WorkSans/worksans-semibold-webfont.woff2" as="font" crossorigin="anonymous">
<!-- <!-- SEE: https://docs.keycloakify.dev/limitations#self-hosted-fonts -->
We need to put it plain in the html because of Keycloakify, in case we decide to remove --external-assets
SEE: https://github.com/InseeFrLab/keycloakify#font-face-importing-fonts-from-thesrc-dir
-->
<style> <style>
/* latin */ /* latin */
@font-face { @font-face {

View file

@ -6155,10 +6155,10 @@ keycloak-js@^21.0.1:
base64-js "^1.5.1" base64-js "^1.5.1"
js-sha256 "^0.9.0" js-sha256 "^0.9.0"
keycloakify@^7.4.0: keycloakify@^7.5.0:
version "7.4.0" version "7.5.0"
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.4.0.tgz#a661bb4d3b6a04ef80dcb7c40fd48213843c2ad7" resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.5.0.tgz#d4ee0d07e6ac0a7fafa1a3e585eda2480d1e04d9"
integrity sha512-wptXEj/TzTVa3p3GqEaYg0HS1IgNl1ZodoHIkq/Cfc06U6f8uthq8pxialXYPgdbNBZLyBrv8I4FMkcWq7xHPA== integrity sha512-cYcoyfprauGUGTtSmuVNNYilguVjm3WDPCLLiVIuZnUyGfJvHiPi8l/10L1CyVBhRl74HFr+4MvQc1yiEQ1a3Q==
dependencies: dependencies:
"@octokit/rest" "^18.12.0" "@octokit/rest" "^18.12.0"
cheerio "^1.0.0-rc.5" cheerio "^1.0.0-rc.5"