From 586f9ca0772a6f2d9374d943a82ba83262f73657 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 1 Apr 2023 16:15:11 +0200 Subject: [PATCH] Remove all mentions of --external-assets --- .github/workflows/ci.yaml | 56 ++++++++++++--------------------------- Dockerfile.ci | 21 --------------- README.md | 21 ++++----------- package.json | 2 +- public/index.html | 5 +--- yarn.lock | 8 +++--- 6 files changed, 28 insertions(+), 85 deletions(-) delete mode 100644 Dockerfile.ci diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 164a60c..547930d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,37 +9,20 @@ on: jobs: - build: + test: runs-on: ubuntu-latest - if: github.event.head_commit.author.name != 'actions' steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2.1.3 - with: - node-version: '16' + - uses: actions/setup-node@v2 - uses: bahmutov/npm-install@v1 - run: yarn build - - run: echo $(node -e 'console.log(require("url").parse(require("./package.json").homepage).host)') > build/CNAME - 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: name: Check if version upgrade if: github.event_name == 'push' runs-on: ubuntu-latest - needs: build + needs: test outputs: from_version: ${{ steps.step1.outputs.from_version }} to_version: ${{ steps.step1.outputs.to_version }} @@ -53,29 +36,23 @@ jobs: create_github_release: runs-on: ubuntu-latest - needs: - - check_if_version_upgraded + needs: check_if_version_upgraded # 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' steps: - - uses: actions/download-artifact@v2 - with: - name: keycloak_theme - - run: mkdir jars - - run: mv *keycloak-theme*.jar jars/keycloak-theme.jar - - uses: actions/download-artifact@v2 - with: - name: standalone_keycloak_theme - - run: mv *keycloak-theme*.jar jars/standalone-keycloak-theme.jar + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + - uses: bahmutov/npm-install@v1 + - run: yarn build + - run: npx keycloakify + - run: mv build_keycloak/target/*keycloak-theme*.jar keycloak-theme.jar - uses: softprops/action-gh-release@v1 with: name: Release 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 }} generate_release_notes: true - files: | - jars/keycloak-theme.jar - jars/standalone-keycloak-theme.jar + files: keycloak-theme.jar draft: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -114,16 +91,17 @@ jobs: tags: ${{ steps.step1.outputs.docker_tags }} file: Dockerfile.ci - github_pages_app: + github_pages: runs-on: ubuntu-latest needs: - create_github_release steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 - with: - name: build - path: build + - uses: actions/setup-node@v2 + - uses: bahmutov/npm-install@v1 + - run: yarn 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 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile.ci b/Dockerfile.ci deleted file mode 100644 index 4749264..0000000 --- a/Dockerfile.ci +++ /dev/null @@ -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;' \ No newline at end of file diff --git a/README.md b/README.md index 6b0711e..2c30915 100644 --- a/README.md +++ b/README.md @@ -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). -# Standalone vs `--external-assets` +# Docker -The CI creates two jars -- `keycloak-theme.jar`: Generated with `npx keycloakify --external-assets`, the assets, located `static/**/*`, like for example - `static/js/main..js` will be downloaded from `https://starter.keycloakify.dev/static/js/main..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..js` will be downloaded from an url like `http:///resources/xxxx/login/keycloakify-starter/build/static/js/main..js`. - -More info on the `--external-assets` build option [here](https://docs.keycloakify.dev/v/v6/build-options#external-assets). - -# Docker +Instructions for building and running the react app (`src/App`) that is collocated with our Keycloak theme. ```bash -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 +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 diff --git a/package.json b/package.json index 159a3ae..7fa7cd1 100755 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "evt": "^2.4.15", "jwt-decode": "^3.1.2", "keycloak-js": "^21.0.1", - "keycloakify": "^7.4.0", + "keycloakify": "^7.5.0", "powerhooks": "^0.26.7", "react": "18.1.0", "react-dom": "18.1.0", diff --git a/public/index.html b/public/index.html index 4dace33..0bcab1a 100644 --- a/public/index.html +++ b/public/index.html @@ -20,10 +20,7 @@ - +