Skip to content

Commit

Permalink
Build docker image for zlinux (#68)
Browse files Browse the repository at this point in the history
* docker node version upgrade

Signed-off-by: James Struga <[email protected]>

* node change

Signed-off-by: James Struga <[email protected]>

* node change

Signed-off-by: James Struga <[email protected]>

* node change

Signed-off-by: James Struga <[email protected]>

* missing tag

Signed-off-by: James Struga <[email protected]>

* added zlinux steps

Signed-off-by: James Struga <[email protected]>

* remove line

Signed-off-by: James Struga <[email protected]>

* add prepapre

Signed-off-by: James Struga <[email protected]>

* add prepapre

Signed-off-by: James Struga <[email protected]>

* added manifest

Signed-off-by: James Struga <[email protected]>

* missing line

Signed-off-by: James Struga <[email protected]>

* add prepapre.sh

Signed-off-by: James Struga <[email protected]>

* added package.json

Signed-off-by: James Struga <[email protected]>

* removed comma

Signed-off-by: James Struga <[email protected]>

* rename dockerfile

Signed-off-by: James Struga <[email protected]>

* removed missing files

Signed-off-by: James Struga <[email protected]>

* added debugging

Signed-off-by: James Struga <[email protected]>

* added label to dockerfile

Signed-off-by: James Struga <[email protected]>

* changed node

Signed-off-by: James Struga <[email protected]>

* added more scripts to prepare

Signed-off-by: James Struga <[email protected]>

* fixed logic

Signed-off-by: James Struga <[email protected]>

* fixed logic

Signed-off-by: James Struga <[email protected]>

* fixed logic

Signed-off-by: James Struga <[email protected]>

* fixed logic

Signed-off-by: James Struga <[email protected]>

* prepare script

* fix folder

* no component dir

* only content of tmp dir

* remove manifest and package

Signed-off-by: James Struga <[email protected]>

* missing env

Signed-off-by: James Struga <[email protected]>

* debug

Signed-off-by: James Struga <[email protected]>

* debug

Signed-off-by: James Struga <[email protected]>

* change way to pick up version

Signed-off-by: James Struga <[email protected]>

* switched linux build

Signed-off-by: James Struga <[email protected]>

* syntax error

Signed-off-by: James Struga <[email protected]>

* remove on pull request

Signed-off-by: James Struga <[email protected]>

Co-authored-by: Jack (T.) Jia <[email protected]>
  • Loading branch information
struga0258 and jackjia-ibm authored Aug 30, 2021
1 parent 387780a commit 45e6b62
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 38 deletions.
78 changes: 45 additions & 33 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: app-server build


# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the staging branch
push:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
IMAGE_BASE_DIR: container
RELEASE: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
build-ubuntu:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2


- name: Login Jfrog
uses: docker/login-action@v1
- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry: zowe-docker-snapshot.jfrog.io
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }}
release: ${{ env.RELEASE }}
base-directory: ${{ env.IMAGE_BASE_DIR }}
image-name: app-server
linux-distro: ubuntu
cpu-arch: amd64

- uses: zowe-actions/shared-actions/docker-build-local@main
with:
build-arg-list: ZOWE_BASE_IMAGE=latest-ubuntu
timeout-minutes: 5

build-zlinux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: build and push image
run: |
cd container
chmod +x *.sh
./pull-zowe-install-artifacts.sh
./download-zlux.sh
cd files
IMAGE_VERSION=$(grep -Po '"version": *\K"[^"]*"' manifest.json | head -n1)
IMAGE_VERSION=`echo $IMAGE_VERSION | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/'`
cd ..
./build.sh
docker tag zowe-docker-snapshot.jfrog.io/ompzowe/app-server:testing zowe-docker-snapshot.jfrog.io/ompzowe/app-server:$IMAGE_VERSION
docker push zowe-docker-snapshot.jfrog.io/ompzowe/app-server:$IMAGE_VERSION
- uses: zowe-actions/shared-actions/prepare-workflow@main

- uses: zowe-actions/shared-actions/docker-prepare@main
with:
registry-user: ${{ secrets.ARTIFACTORY_X_USERNAME }}
registry-password: ${{ secrets.ARTIFACTORY_X_PASSWORD }}
release: ${{ env.RELEASE }}
base-directory: ${{ env.IMAGE_BASE_DIR }}
image-name: app-server
linux-distro: ubuntu
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-ubuntu
timeout-minutes: 10
8 changes: 6 additions & 2 deletions container/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
*.tar
files/zlux
files/
tmp/
# manifest.json
logs
logs
# Dockerfile
ubuntu/
ubi/
17 changes: 15 additions & 2 deletions container/Dockerfile.zlux
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@
# Copyright IBM Corporation 2021 #
# #
#########################################################################################
FROM node:12
# base image tag
ARG ZOWE_BASE_IMAGE=latest-ubuntu

FROM zowe-docker-release.jfrog.io/ompzowe/base-node:${ZOWE_BASE_IMAGE} AS builder

##################################
# labels
LABEL name="App Server" \
maintainer="[email protected]" \
vendor="Zowe" \
version="0.0.0" \
release="0" \
description="This Zowe UI component can display jobs running on z/OS"


#ENV VARS
ENV INSTALL_DIR=/home/zowe
ENV INSTALL_DIR=/component
ENV ROOT_DIR=${INSTALL_DIR}/install
ENV ZOWE_ROOT_DIR=${ROOT_DIR}
ENV INSTANCE_DIR=${INSTALL_DIR}/instance
Expand Down
2 changes: 1 addition & 1 deletion container/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#########################################################################################

mkdir -p logs
docker pull node:12
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
Empty file modified container/download-zlux.sh
100644 → 100755
Empty file.
143 changes: 143 additions & 0 deletions container/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

################################################################################
# This program and the accompanying materials are made available under the terms of the
# Eclipse Public License v2.0 which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
################################################################################

################################################################################
# prepare docker build context
#
# This script will be executed with 2 parameters:
# - linux-distro
# - cpu-arch

################################################################################
# This script prepares all required files we plan to put into zowe-launch-scripts
# image.
#
# Prereqs:
# - must run with Github Actions (with GITHUB_RUN_NUMBER and GITHUB_SHA)
# - must provide $GITHUB_PR_ID is it's pull request
# - jq

# exit if there are errors
set -e

###############################
# check parameters
linux_distro=$1
cpu_arch=$2
if [ -z "${linux_distro}" ]; then
echo "Error: linux-distro parameter is missing."
exit 1
fi
if [ -z "${cpu_arch}" ]; then
echo "Error: cpu-arch parameter is missing."
exit 1
fi

################################################################################
# CONSTANTS
# this should be containers/zowe-launch-scripts
BASE_DIR=$(cd $(dirname $0);pwd)
REPO_ROOT_DIR=$(cd $(dirname $0)/../;pwd)
WORK_DIR=tmp
UNTAR_DIR=untar
JFROG_REPO_SNAPSHOT=libs-snapshot-local
JFROG_REPO_RELEASE=libs-release-local
JFROG_URL=https://zowe.jfrog.io/zowe/

###############################
echo ">>>>> clean up folder"
rm -fr "${BASE_DIR}/${WORK_DIR}"
mkdir -p "${BASE_DIR}/${WORK_DIR}"

###############################
# Download zlux
echo ">>>> prepare zlux"
cd "${BASE_DIR}"
chmod +x *.sh
if [ ! -f pull-zowe-install-artifacts.sh ]; then
echo "Error: pull-zowe-install-artifacts script is missing."
exit 3
fi
if [ ! -f download-zlux.sh ]; then
echo "Error: download-zlux script is missing."
exit 4
fi
./pull-zowe-install-artifacts.sh
./download-zlux.sh

###############################
# untar zlux-core and copy package.json,manifest.yaml
echo ">>>>> create tmp folder to extract tar"
rm -fr "${BASE_DIR}/${UNTAR_DIR}"
mkdir -p "${BASE_DIR}/${UNTAR_DIR}"
cd "${BASE_DIR}/${UNTAR_DIR}"
tar -xvf ../files/zlux-core.tar
cp zlux-app-server/manifest.yaml "${REPO_ROOT_DIR}"
cp zlux-app-server/package.json "${REPO_ROOT_DIR}"
rm -fr "${BASE_DIR}/${UNTAR_DIR}"

###############################
echo ">>>>> prepare basic files"
cd "${BASE_DIR}/files"
package_version=$(jq -r '.version' manifest.json)
package_release=$(echo "${package_version}" | awk -F. '{print $1;}')

###############################
# copy Dockerfile
echo ">>>>> copy Dockerfile to ${linux_distro}/${cpu_arch}/Dockerfile"
cd "${BASE_DIR}"
mkdir -p "${linux_distro}/${cpu_arch}"
if [ ! -f Dockerfile.zlux ]; then
echo "Error: Dockerfile file is missing."
exit 2
fi
cat Dockerfile.zlux | sed -e "s#version=\"0\.0\.0\"#version=\"${package_version}\"#" -e "s#release=\"0\"#release=\"${package_release}\"#" > "${linux_distro}/${cpu_arch}/Dockerfile"


###############################
echo ">>>>> prepare basic files"
cd "${REPO_ROOT_DIR}"
cp README.md "${BASE_DIR}/${WORK_DIR}"
cp LICENSE "${BASE_DIR}/${WORK_DIR}"
cp package.json "${BASE_DIR}/${WORK_DIR}"
mv "${BASE_DIR}/files" "${BASE_DIR}/${WORK_DIR}"
cd "${BASE_DIR}/${WORK_DIR}"
find .

###############################
echo ">>>>> prepare manifest.json"
cd "${REPO_ROOT_DIR}"
if [ -n "${GITHUB_PR_ID}" ]; then
GITHUB_BRANCH=PR-${GITHUB_PR_ID}
else
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
fi
echo " - branch: ${GITHUB_BRANCH}"
echo " - build number: ${GITHUB_RUN_NUMBER}"
echo " - commit hash: ${GITHUB_SHA}"
# assume to run in Github Actions
cat manifest.yaml | \
sed -e "s#{{build\.branch}}#${GITHUB_BRANCH}#" \
-e "s#{{build\.number}}#${GITHUB_RUN_NUMBER}#" \
-e "s#{{build\.commitHash}}#${GITHUB_SHA}#" \
-e "s#{{build\.timestamp}}#$(date +%s)#" \
> "${BASE_DIR}/${WORK_DIR}/manifest.yaml"


###############################
# copy to target context
echo ">>>>> copy to target build context"
cp -r "${BASE_DIR}/${WORK_DIR}/." "${BASE_DIR}/${linux_distro}/${cpu_arch}"

###############################
# done
echo ">>>>> all done"
Empty file modified container/pull-zowe-install-artifacts.sh
100644 → 100755
Empty file.
Empty file modified container/run.sh
100644 → 100755
Empty file.
Empty file modified container/start.sh
100644 → 100755
Empty file.

0 comments on commit 45e6b62

Please sign in to comment.