diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f8b83d0..2086240 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,13 +5,18 @@ name: app-server build on: push: branches: [ master ] + workflow_dispatch: + inputs: + release: + description: 'Whether this is a test build or official release' + required: true + default: false env: IMAGE_BASE_DIR: container - RELEASE: true jobs: - build-ubuntu: + build-ubuntu-amd64: runs-on: ubuntu-latest steps: @@ -20,10 +25,12 @@ jobs: - uses: zowe-actions/shared-actions/prepare-workflow@main - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} with: registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} - release: ${{ env.RELEASE }} + release: ${{ github.event.inputs.release }} base-directory: ${{ env.IMAGE_BASE_DIR }} image-name: app-server linux-distro: ubuntu @@ -34,7 +41,33 @@ jobs: build-arg-list: ZOWE_BASE_IMAGE=latest-ubuntu timeout-minutes: 5 - build-zlinux: + + build-ubi-amd64: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: zowe-actions/shared-actions/prepare-workflow@main + + - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} + with: + registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} + registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} + release: ${{ github.event.inputs.release }} + base-directory: ${{ env.IMAGE_BASE_DIR }} + image-name: app-server + linux-distro: ubi + cpu-arch: amd64 + + - uses: zowe-actions/shared-actions/docker-build-local@main + with: + build-arg-list: ZOWE_BASE_IMAGE=latest-ubi + timeout-minutes: 5 + + build-ubuntu-s390x: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -42,10 +75,12 @@ jobs: - uses: zowe-actions/shared-actions/prepare-workflow@main - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} with: registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} - release: ${{ env.RELEASE }} + release: ${{ github.event.inputs.release }} base-directory: ${{ env.IMAGE_BASE_DIR }} image-name: app-server linux-distro: ubuntu @@ -58,4 +93,91 @@ jobs: zlinux-ssh-key: ${{ secrets.ZLINUX_SSH_KEY }} zlinux-ssh-passphrase: ${{ secrets.ZLINUX_SSH_PASSPHRASE }} build-arg-list: ZOWE_BASE_IMAGE=latest-ubuntu - timeout-minutes: 10 \ No newline at end of file + timeout-minutes: 10 + + + build-ubi-s390x: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: zowe-actions/shared-actions/prepare-workflow@main + + - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} + with: + registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} + registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} + release: ${{ github.event.inputs.release }} + base-directory: ${{ env.IMAGE_BASE_DIR }} + image-name: app-server + linux-distro: ubi + cpu-arch: s390x + + - uses: zowe-actions/shared-actions/docker-build-zlinux@main + with: + zlinux-host: ${{ secrets.ZLINUX_HOST }} + zlinux-ssh-user: ${{ secrets.ZLINUX_SSH_USER }} + zlinux-ssh-key: ${{ secrets.ZLINUX_SSH_KEY }} + zlinux-ssh-passphrase: ${{ secrets.ZLINUX_SSH_PASSPHRASE }} + build-arg-list: ZOWE_BASE_IMAGE=latest-ubi + timeout-minutes: 10 + + + define-ubuntu-manifest: + needs: + - build-ubuntu-amd64 + - build-ubuntu-s390x + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: zowe-actions/shared-actions/prepare-workflow@main + + - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} + with: + registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} + registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} + release: ${{ github.event.inputs.release }} + base-directory: ${{ env.IMAGE_BASE_DIR }} + image-name: app-server + linux-distro: ubuntu + + - uses: zowe-actions/shared-actions/docker-manifest@main + with: + linux-distro: ubuntu + primary-linux-distro: ubuntu + cpu-arch-list: "amd64 s390x" + timeout-minutes: 2 + + define-ubi-manifest: + needs: + - build-ubi-amd64 + - build-ubi-s390x + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: zowe-actions/shared-actions/prepare-workflow@main + + - uses: zowe-actions/shared-actions/docker-prepare@main + env: + ZLUX_DOWNLOAD_API_TOKEN: ${{ secrets.ZLUX_API_TOKEN }} + with: + registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }} + registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }} + release: ${{ github.event.inputs.release }} + base-directory: ${{ env.IMAGE_BASE_DIR }} + image-name: app-server + linux-distro: ubi + + - uses: zowe-actions/shared-actions/docker-manifest@main + with: + linux-distro: ubi + primary-linux-distro: ubuntu + cpu-arch-list: "amd64 s390x" + timeout-minutes: 2 + diff --git a/container/Dockerfile.zlux b/container/Dockerfile.zlux index 60ee248..c782852 100644 --- a/container/Dockerfile.zlux +++ b/container/Dockerfile.zlux @@ -17,51 +17,47 @@ FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE} AS builde ################################## # labels LABEL name="App Server" \ - maintainer="jstruga@rocketsoftware.component" \ + maintainer="jstruga@rocketsoftware.com" \ vendor="Zowe" \ version="0.0.0" \ release="0" \ - description="This Zowe UI component can display jobs running on z/OS" + summary="Zowe App Server, Desktop, and builtin plugins" \ + description="A core Zowe component that powers the Desktop and Desktop Apps" + +EXPOSE 8544/tcp -#ENV VARS -ENV INSTALL_DIR=/component -ENV ROOT_DIR=${INSTALL_DIR}/install +ENV ZWED_INSTALL_DIR=/component +ENV ROOT_DIR=/home/zowe/runtime ENV ZOWE_ROOT_DIR=${ROOT_DIR} -ENV INSTANCE_DIR=${INSTALL_DIR}/instance +ENV INSTANCE_DIR=/home/zowe/instance ENV WORKSPACE_DIR=${INSTANCE_DIR}/workspace -# COPY zlux-core to /home/zowe/install/components/app-server/share -ADD files/zlux-core.tar ${ROOT_DIR}/components/app-server/share/ -# copy all packages & scripts to install -ADD files ${INSTALL_DIR}/files +# Testing parameters +# ENV ZOWE_EXPLORER_HOST='localhost' +# ENV ZWED_node_allowInvalidTLSProxy=true +# ENV ZWE_EXTERNAL_HOST='localhost' -RUN cd ${ROOT_DIR}/components/app-server/share/zlux-app-server/bin && \ -chmod +x *.sh && \ -./install-container.sh +# authorization needs to point to zss endpoint +# ENV APIML_SECURITY_AUTHORIZATION_PROVIDER=endpoint +# ENV APIML_SECURITY_AUTHORIZATION_ENDPOINT_ENABLED=true -EXPOSE 8544/tcp -ENV ZOWE_EXPLORER_HOST='localhost' -ENV ZOWE_IP_ADDRESS=0.0.0.0 +# zlux minus plugins +ADD --chown=zowe:zowe files/zlux-core.tar ${ZWED_INSTALL_DIR}/share/ +# copy config and plugins +ADD --chown=zowe:zowe files ${ZWED_INSTALL_DIR}/files -ENV ZOWE_ZOSMF_PORT='443' -ENV ZWED_agent_https_port='8542' +RUN chown -R zowe:zowe ${ZWED_INSTALL_DIR} +USER zowe -ENV ZWED_node_allowInvalidTLSProxy=true -ENV ZOWE_ZLUX_TELNET_PORT=23 -ENV ZOWE_ZLUX_SECURITY_TYPE=telnet -ENV ZWE_EXTERNAL_HOST='localhost' -ENV ZWE_REFERRER_HOSTS='localhost,gateway-service,zlux-app-server' +RUN if [ ! -d ${ZWED_INSTALL_DIR}/share/zlux-app-server ]; then cd ${ZWED_INSTALL_DIR}/share && tar -xf zlux-core.tar; fi -# authorization needs to point to zss endpoint -# ENV APIML_SECURITY_AUTHORIZATION_PROVIDER=endpoint -# ENV APIML_SECURITY_AUTHORIZATION_ENDPOINT_ENABLED=true -# ENV LAUNCH_COMPONENT_GROUPS=DESKTOP,GATEWAY -# COPY --chown=zowe:zowe --from=builder /home/zowe /home/zowe -# RUN chmod a+x /home/zowe/*.sh /home/zowe/.run_inner.sh +RUN cd ${ZWED_INSTALL_DIR}/share/zlux-app-server/bin && \ +chmod +x *.sh && \ +./install-container.sh -WORKDIR ${ROOT_DIR}/components/app-server/bin +WORKDIR ${ZWED_INSTALL_DIR}/bin CMD ["./start-container.sh"] \ No newline at end of file diff --git a/container/build.sh b/container/build.sh index 107bb36..efecf0f 100755 --- a/container/build.sh +++ b/container/build.sh @@ -13,5 +13,6 @@ ######################################################################################### mkdir -p logs -docker pull zowe-docker-release.jfrog.io/ompzowe/base-node:latest-ubuntu -docker build --pull -f Dockerfile.zlux --no-cache --progress=plain -t zowe-docker-snapshot.jfrog.io/ompzowe/app-server:testing . 2>&1 | tee logs/docker-build.log \ No newline at end of file +docker pull zowe-docker-release.jfrog.io/ompzowe/base-node:$ZOWE_BASE_IMAGE +docker build --pull -f Dockerfile.zlux --no-cache --progress=plain --build-arg ZOWE_BASE_IMAGE=$ZOWE_BASE_IMAGE -t zowe-docker-snapshot.jfrog.io/ompzowe/app-server:testing . 2>&1 | tee logs/docker-build.log + diff --git a/container/getPackagePaths.js b/container/getPackagePaths.js index 0cead8d..ebb62cd 100644 --- a/container/getPackagePaths.js +++ b/container/getPackagePaths.js @@ -12,25 +12,86 @@ ######################################################################################### */ +if (!process.env.ZLUX_DOWNLOAD_API_TOKEN) { + console.log('*** WARNING: This will not download patterned URLs without environment variable ZLUX_DOWNLOAD_API_TOKEN. Set with for example export ZLUX_DOWNLOAD_API_TOKEN=... ***'); +} + + const { binaryDependencies: zowePackages } = require('./files/manifest.json'); const baseUrl = process.env.ZOWE_REPOSITORY || 'https://zowe.jfrog.io/artifactory'; -function getPackageUrls() { +async function getPackageUrls() { let zluxPrefix = 'org.zowe.zlux'; let urls = [] - let packages = [] + let packages = [] for (const [key, value] of Object.entries(zowePackages)) { - if (key.startsWith(zluxPrefix)) { - let packageName = key.replace(zluxPrefix + '.', ''); - packages.push(packageName) - let { repository, version, artifact } = value; - urls.push(`${baseUrl}/${repository}/org/zowe/zlux/${packageName}/${version}/${artifact.replace('.pax', '.tar')}`); + let { repository, version, artifact } = value; + if (key.startsWith(zluxPrefix)) { + let { repository, version, artifact } = value; + if (repository == 'libs-snapshot-local'){ + let packageName = key.replace(zluxPrefix + '.', ''); + packages.push(packageName) + urls.push(`${baseUrl}/${repository}/org/zowe/zlux/${packageName}/${version}/${artifact.replace('.pax', '.tar')}`); + }else{ + let packageName = key.replace(zluxPrefix + '.', ''); + let versionName = value['version'].replace('~', ''); + let artifactName = value['artifact'].replace('.pax', '.tar') + let result = await artifactory(packageName, versionName, artifactName); + packages.push(packageName) + urls.push(`${baseUrl}/${result}`); + + } } } - //console.log(urls); + //console.log(urls); return `${packages.toString()};${urls.toString()}`; } -console.log(getPackageUrls()) +getPackageUrls().then(res => console.log(res)); + +function findArtifact(name, version, artifact){ + return new Promise(resolve => { + const https = require('https') + const data = `items.find({"repo": "libs-snapshot-local", "path": {"$match": "org/zowe/zlux/${name}/*${version}"}, "name": {"$match": "${artifact}"}})` + const options ={ + hostname: 'zowe.jfrog.io', + path: '/zowe/api/search/aql', + method: 'POST', + headers: { + 'X-JFrog-Art-Api':process.env.ZLUX_DOWNLOAD_API_TOKEN ? process.env.ZLUX_DOWNLOAD_API_TOKEN : '*' + } + } + var ret = ''; + const req = https.request(options, (res) => { + //console.log(`statusCode: ${res.statusCode}`) + res.on('data', (d) => { + ret += d; + }) + res.on('error', (err) => { + }) + res.on('end', () => { + resolve(JSON.parse(ret)); + }) + }); + req.write(data) + req.end(); + }) +} + +function sortArtifacts(names){ + return names['results'].sort(function(a,b){ + return b.updated.localeCompare(a.updated, undefined, { + numeric: true, + sensitivity: 'base' + }); + }); + +} +async function artifactory(name, version, artifact){ + data = await findArtifact(name, version, artifact); + sortArtifacts(data) + let results = data['results'][0]['repo'] + '/' + data['results'][0]['path'] + '/' + data['results'][0]['name'] + return results +} diff --git a/container/prepare.sh b/container/prepare.sh index bcdd2e1..999ab56 100644 --- a/container/prepare.sh +++ b/container/prepare.sh @@ -72,6 +72,11 @@ if [ ! -f download-zlux.sh ]; then exit 4 fi ./pull-zowe-install-artifacts.sh + +if [ -z "${ZLUX_DOWNLOAD_API_TOKEN}" ]; then + echo "*** WARNING: This will not download patterned URLs without environment variable ZLUX_DOWNLOAD_API_TOKEN. Set with for example export ZLUX_DOWNLOAD_API_TOKEN=... ***" +fi + ./download-zlux.sh ############################### @@ -140,4 +145,4 @@ cp -r "${BASE_DIR}/${WORK_DIR}/." "${BASE_DIR}/${linux_distro}/${cpu_arch}" ############################### # done -echo ">>>>> all done" \ No newline at end of file +echo ">>>>> all done" diff --git a/container/pull-zowe-install-artifacts.sh b/container/pull-zowe-install-artifacts.sh index 4b8d096..92b0fe5 100755 --- a/container/pull-zowe-install-artifacts.sh +++ b/container/pull-zowe-install-artifacts.sh @@ -20,7 +20,7 @@ rm -rf files/zowe-install-packaging 2>/dev/null mkdir -p files/zlux # clone zowe-install-packaging - copy manifest, files/zlux/config -git clone --branch rc https://github.com/zowe/zowe-install-packaging files/zowe-install-packaging +git clone --branch staging https://github.com/zowe/zowe-install-packaging files/zowe-install-packaging # copy manifest to files mv files/zowe-install-packaging/manifest.json.template files/manifest.json @@ -28,4 +28,4 @@ mv files/zowe-install-packaging/manifest.json.template files/manifest.json #cp files/zowe-install-packaging/manifest.json.template files/manifest.json mv files/zowe-install-packaging/files/zlux/config files/zlux/config # clear zowe-install-packaging -rm -rf files/zowe-install-packaging \ No newline at end of file +rm -rf files/zowe-install-packaging diff --git a/container/readme.md b/container/readme.md index bf7405b..9b3efb0 100644 --- a/container/readme.md +++ b/container/readme.md @@ -11,6 +11,7 @@ # TODO: - container script `app-install-container.sh` copied from `server-bundle` is not used as of now +- if using custom manifest.json, please export `ZLUX_DOWNLOAD_API_TOKEN` with a proper value for `X-JFrog-Art-Api` # Container Scripts - `install-container.sh` -> layout binaries, and scripts diff --git a/container/run.sh b/container/run.sh index aab9478..1285614 100755 --- a/container/run.sh +++ b/container/run.sh @@ -14,7 +14,11 @@ set -e +if [ -z "${ZLUX_DOWNLOAD_API_TOKEN}" ]; then + echo "*** WARNING: This will not download patterned URLs without environment variable ZLUX_DOWNLOAD_API_TOKEN. Set with for example export ZLUX_DOWNLOAD_API_TOKEN=... ***" +fi + ./pull-zowe-install-artifacts.sh ./download-zlux.sh ./build.sh -./start.sh \ No newline at end of file +./start.sh