Last active
October 31, 2023 11:15
-
-
Save rgolangh/ec8f87b7ed952c4767d29e16c8bf434f to your computer and use it in GitHub Desktop.
Create Janus backstage-showcase image with orchestrator plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -xe | |
| pushd $(mktemp -d -p .) | |
| cleanup() { | |
| popd | |
| } | |
| trap cleanup EXIT SIGINT SIGTERM | |
| VERDACCIO_CONF=$(mktemp -p . XXX-verdaccio.conf) | |
| BACKSTAGE_PLUGINS_DOCKERFILE=$(mktemp -p . XXX-backstage-plugins.Dockerfile) | |
| BACKSTAGE_PLUGINS_REPO=https://github.com/caponetto/backstage-plugins | |
| BACKSTAGE_PLUGINS_REPO_REF=KOGITO-9778 | |
| BACKSTAGE_SHOWCASE_REPO=https://github.com/caponetto/backstage-showcase | |
| BACKSTAGE_SHOWCASE_REPO_REF=changes-needed | |
| BACKSTAGE_UNPUBLISHED_PLUGINS="\ | |
| orchestrator-common \ | |
| orchestrator-backend \ | |
| orchestrator" | |
| cat <<EOF > ${VERDACCIO_CONF} | |
| storage: /verdaccio/storage | |
| auth: | |
| htpasswd: | |
| file: ./htpasswd | |
| uplinks: | |
| npmjs: | |
| url: https://registry.npmjs.org/ | |
| packages: | |
| '@*/*': | |
| access: \$anonymous | |
| publish: \$anonymous | |
| proxy: npmjs | |
| '**': | |
| proxy: npmjs | |
| access: \$anonymous | |
| publish: \$anonymous | |
| log: { type: stdout, format: pretty, level: http } | |
| EOF | |
| cat <<EOF > ${BACKSTAGE_PLUGINS_DOCKERFILE} | |
| FROM registry.access.redhat.com/ubi9/nodejs-18:1-70 AS skeleton | |
| USER 0 | |
| RUN /bin/bash -c 'dnf install -y -q --allowerasing --nobest nodejs-devel nodejs-libs \ | |
| openssl openssl-devel ca-certificates make cmake cpp gcc gcc-c++ zlib zlib-devel brotli brotli-devel python3 nodejs-packaging && \ | |
| dnf update -y && dnf clean all' | |
| RUN git clone --depth 1 -b ${BACKSTAGE_PLUGINS_REPO_REF} ${BACKSTAGE_PLUGINS_REPO} | |
| WORKDIR backstage-plugins | |
| RUN npm install --global yarn@1.22.19 | |
| RUN npm set registry http://localhost:4873/ | |
| RUN echo -e "_auth = 123\nemail = a.a.com\n" > ~/.npmrc | |
| WORKDIR /opt/app-root/src/backstage-plugins/plugins | |
| CMD /bin/bash -c 'for i in ${BACKSTAGE_UNPUBLISHED_PLUGINS};do \ | |
| pushd \${i} ;\ | |
| yarn install; \ | |
| yarn publish --registry http://localhost:4873 --force --non-interactive; \ | |
| popd ;\ | |
| done' | |
| EOF | |
| if ! $(podman container exists verdaccio ) ; then podman run --rm -it -d --user=verdaccio --name verdaccio -v ${PWD}/${VERDACCIO_CONF}:/verdaccio/conf/config.yaml:Z \ | |
| -p 4873:4873 docker.io/verdaccio/verdaccio ;fi | |
| podman build . -f ${BACKSTAGE_PLUGINS_DOCKERFILE} -t backstage-plugins --network host | |
| podman run --rm -it --network host --name backstage-plugins backstage-plugins | |
| git clone --depth 1 -b ${BACKSTAGE_SHOWCASE_REPO_REF} ${BACKSTAGE_SHOWCASE_REPO} && cd backstage-showcase | |
| sed -i '/YARN install/ i RUN \$YARN cache clean --pattern orchestrator' docker/Dockerfile | |
| sed -i 's/YARN install/YARN install --update-checksums/' docker/Dockerfile | |
| podman build . -f docker/Dockerfile --network host -t quay.io/rgolangh/orchestrator | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm going to add a yarn cache cleanup, because it fails if you want to make a change