Skip to content

Instantly share code, notes, and snippets.

@Zooloo2014
Last active February 7, 2019 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zooloo2014/63f5e9a0de22face4349b85fdc241c43 to your computer and use it in GitHub Desktop.
Save Zooloo2014/63f5e9a0de22face4349b85fdc241c43 to your computer and use it in GitHub Desktop.
echo "Update packages: "
docker exec -it $containerName sh -c "yum -y update"

echo "Add epel repos"
docker exec -it $containerName sh -c "yum -y install epel-release"

echo "Install needed packages: "
docker exec -it $containerName sh -c "yum install -y git rpm-build redhat-rpm-config gcc-c++ make nodejs"

echo "Install nvm"
docker exec -it $containerName sh -c "curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash"

echo "Show nvm version"
docker exec -ite NVM_DIR="/root/.nvm" $containerName sh -c "\. \$NVM_DIR/nvm.sh && nvm --version"

echo "Install node v10.15.0"
docker exec -ite NVM_DIR="/root/.nvm" $containerName sh -c "\. \$NVM_DIR/nvm.sh && nvm install 10.15.0"

echo "Fetch release version from Github"
docker exec -it $containerName sh -c "mkdir /openhim-core-js && curl -sL 'https://github.com/jembi/openhim-core-js/archive/v$RELEASE_VERSION.tar.gz' | tar --strip-components=1 -zxv -C /openhim-core-js"

echo "npm install && npm install speculate && npm run build"
docker exec -ite NVM_DIR="/root/.nvm" $containerName sh -c "\. \$NVM_DIR/nvm.sh && cd /openhim-core-js && npm install && npm install speculate && npm run build && npm run spec"

echo "Symlink the openhim-core folder with the rpmbuild folder"
docker exec -it $containerName sh -c "ln -s /openhim-core-js ~/rpmbuild"

# if the Release Version incluldes a dash, apply workaround for rpmbuild to not break on dashes
if [[ "${RELEASE_VERSION}" == *"-"* ]]
then
  RELEASE_VERSION_TEMP=${RELEASE_VERSION//-/_}
  echo "Release Version contains unsupported dash (-) for building rpm package. Replacing with underscore (_) temporarily"
  docker exec -it $containerName sh -c "sed -i 's/$RELEASE_VERSION/$RELEASE_VERSION_TEMP/g' ~/rpmbuild/SPECS/openhim-core.spec"
fi

echo "Build RPM package from spec"
docker exec -ite NVM_DIR="/root/.nvm" $containerName sh -c "\. \$NVM_DIR/nvm.sh && rpmbuild -bb ~/rpmbuild/SPECS/openhim-core.spec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment