diff --git a/.github/workflows/docker-openstudio.yml b/.github/workflows/docker-openstudio.yml index 86eedf3..ceb18f5 100644 --- a/.github/workflows/docker-openstudio.yml +++ b/.github/workflows/docker-openstudio.yml @@ -8,87 +8,96 @@ on: [push, pull_request] # branches: # - test_branch +concurrency: + group: openstudio-docker-${{ github.ref }} + cancel-in-progress: true + env: USE_TESTING_TIMEOUTS: "true" - OPENSTUDIO_VERSION: 3.9.0 - OPENSTUDIO_SHA: c77fbb9569 - OPENSTUDIO_VERSION_EXT: "" + OPENSTUDIO_VERSION: 3.11.0 + OPENSTUDIO_SHA: dee62bf9dd + OPENSTUDIO_VERSION_EXT: "-rc1" + OPENSTUDIO_DOWNLOAD_URL: "https://openstudio-ci-builds.s3-us-west-2.amazonaws.com/develop/OpenStudio-3.11.0-rc1%2Bdee62bf9dd-Ubuntu-22.04-x86_64.deb" permissions: contents: read - id-token: write jobs: docker: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.8.x' + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12.x' - - name: test and build - shell: bash - run: | + - name: test and build + shell: bash + run: | + set -euo pipefail docker build -t openstudio:latest \ - --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_VERSION \ - --build-arg OPENSTUDIO_SHA=$OPENSTUDIO_SHA \ - --build-arg OPENSTUDIO_VERSION_EXT=$OPENSTUDIO_VERSION_EXT \ - --build-arg DOWNLOAD_PREFIX=$DOWNLOAD_PREFIX . + --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_VERSION \ + --build-arg OPENSTUDIO_SHA=$OPENSTUDIO_SHA \ + --build-arg OPENSTUDIO_VERSION_EXT=$OPENSTUDIO_VERSION_EXT . docker run openstudio:latest openstudio openstudio_version docker run openstudio:latest /usr/local/openstudio-$OPENSTUDIO_VERSION/Radiance/bin/rtrace -version - docker run -v $(pwd):/var/simdata/openstudio openstudio:latest ruby /var/simdata/openstudio/test/test_run.rb - docker run -v $(pwd)/test:/var/simdata/openstudio openstudio:latest ./test_gemfile.sh + docker run -v "$(pwd)":/var/simdata/openstudio openstudio:latest ruby /var/simdata/openstudio/test/test_run.rb + docker run -v "$(pwd)/test":/var/simdata/openstudio openstudio:latest ./test_gemfile.sh - - name: deploy docker - if: ${{ success() }} && - github.ref == 'refs/heads/master' || - github.ref == 'refs/heads/develop' || - github.ref == 'refs/heads/custom_branch_name' - shell: bash - run: ./deploy_docker.sh - env: - DOCKER_PASS: ${{ secrets.DOCKER_PASS }} - DOCKER_USER: ${{ secrets.DOCKER_USER }} + - name: deploy docker + if: ${{ success() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/custom_branch_name') }} + shell: bash + run: | + set -euo pipefail + ./deploy_docker.sh + env: + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + DOCKER_USER: ${{ secrets.DOCKER_USER }} apptainer: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.8.x' + runs-on: ubuntu-24.04 + needs: docker + if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/custom_branch_name' }} + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12.x' + + - name: install apptainer + shell: bash + run: | + set -euo pipefail + sudo add-apt-repository -y ppa:apptainer/ppa + sudo apt update + sudo apt install -y apptainer + + - name: build apptainer + shell: bash + run: | + set -euo pipefail + apptainer build \ + OpenStudio-$OPENSTUDIO_VERSION$OPENSTUDIO_VERSION_EXT.$OPENSTUDIO_SHA-Apptainer.sif \ + docker://nrel/openstudio:$OPENSTUDIO_VERSION$OPENSTUDIO_VERSION_EXT - - name: install apptainer - shell: bash - run: | - sudo add-apt-repository -y ppa:apptainer/ppa - sudo apt update - sudo apt install -y apptainer + - uses: actions/upload-artifact@v4 + with: + name: apptainer-image + path: OpenStudio-${{ env.OPENSTUDIO_VERSION }}${{ env.OPENSTUDIO_VERSION_EXT }}.${{ env.OPENSTUDIO_SHA }}-Apptainer.sif - - name: build apptainer - shell: bash - run: | - apptainer build \ - OpenStudio-$OPENSTUDIO_VERSION$OPENSTUDIO_VERSION_EXT.$OPENSTUDIO_SHA-Apptainer.sif \ - docker://nrel/openstudio:$OPENSTUDIO_VERSION$OPENSTUDIO_VERSION_EXT - - - uses: actions/upload-artifact@v3 - with: - name: apptainer-image - path: OpenStudio-${{ env.OPENSTUDIO_VERSION }}${{ env.OPENSTUDIO_VERSION_EXT }}.${{ env.OPENSTUDIO_SHA }}-Apptainer.sif - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - role-to-assume: arn:aws:iam::471211731895:role/OpenStudioGitHubActionsRole - role-session-name: GitHubActions + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::471211731895:role/OpenStudioGitHubActionsRole + role-session-name: GitHubActions - - name: Upload artifacts to AWS S3 - uses: usualdesigner/s3-artifact-upload@main - with: - bucket-name: openstudio-builds - prefix: ${{env.OPENSTUDIO_VERSION}} - file: OpenStudio-${{ env.OPENSTUDIO_VERSION }}${{ env.OPENSTUDIO_VERSION_EXT }}.${{ env.OPENSTUDIO_SHA }}-Apptainer.sif - \ No newline at end of file + - name: Upload artifacts to AWS S3 + uses: usualdesigner/s3-artifact-upload@main + with: + bucket-name: openstudio-builds + prefix: ${{ env.OPENSTUDIO_VERSION }} + file: OpenStudio-${{ env.OPENSTUDIO_VERSION }}${{ env.OPENSTUDIO_VERSION_EXT }}.${{ env.OPENSTUDIO_SHA }}-Apptainer.sif diff --git a/.github/workflows/manual_installer_test.yml b/.github/workflows/manual_installer_test.yml index 9d48d0c..459a093 100644 --- a/.github/workflows/manual_installer_test.yml +++ b/.github/workflows/manual_installer_test.yml @@ -25,13 +25,13 @@ env: jobs: build_container: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.8.x' + python-version: '3.11.x' - name: test and build shell: bash diff --git a/Dockerfile b/Dockerfile index a1a68ba..a753137 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ FROM ubuntu:22.04 AS base -MAINTAINER Nicholas Long nicholas.long@nrel.gov +LABEL maintainer="Nicholas Long nicholas.long@nrel.gov" # Set the version of OpenStudio when building the container. For example `docker build --build-arg -ARG OPENSTUDIO_VERSION=3.9.0 -ARG OPENSTUDIO_VERSION_EXT="" -ARG OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/master/OpenStudio-3.9.0%2Bc77fbb9569-Ubuntu-22.04-x86_64.deb" +ARG OPENSTUDIO_VERSION=3.11.0 +ARG OPENSTUDIO_VERSION_EXT="-rc1" +ARG OPENSTUDIO_SHA="dee62bf9dd" +# If OPENSTUDIO_DOWNLOAD_URL is not provided, construct a reasonable default using the +# OpenStudio CI S3 pattern. Users can override by passing --build-arg OPENSTUDIO_DOWNLOAD_URL=... +ARG OPENSTUDIO_DOWNLOAD_URL="" ENV RC_RELEASE=TRUE ENV OS_BUNDLER_VERSION=2.4.10 ENV RUBY_VERSION=3.2.2 @@ -17,19 +20,27 @@ ENV BUNDLE_WITHOUT=native_ext # install locales and set to en_US.UTF-8. This is needed for running the CLI on some machines # such as singularity. RUN apt-get update && apt-get install -y \ - curl \ - gdebi-core \ - libsqlite3-dev \ - libssl-dev \ - libffi-dev \ - build-essential \ - zlib1g-dev \ - vim \ - git \ - locales \ - sudo \ + curl \ + gdebi-core \ + libsqlite3-dev \ + libssl-dev \ + libffi-dev \ + build-essential \ + zlib1g-dev \ + vim \ + git \ + locales \ + sudo \ + && if [ -z "${OPENSTUDIO_DOWNLOAD_URL}" ]; then \ + ESC_VERSION=$(echo "${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}" | sed 's/+/%2B/g'); \ + if [ -n "${OPENSTUDIO_SHA}" ]; then \ + OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}%2B${OPENSTUDIO_SHA}-Ubuntu-22.04-x86_64.deb"; \ + else \ + OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}-Ubuntu-22.04-x86_64.deb"; \ + fi; \ + fi \ && echo "OpenStudio Package Download URL is ${OPENSTUDIO_DOWNLOAD_URL}" \ - && curl -SLO $OPENSTUDIO_DOWNLOAD_URL \ + && curl -SLO "$OPENSTUDIO_DOWNLOAD_URL" \ && OPENSTUDIO_DOWNLOAD_FILENAME=$(ls *.deb) \ # Verify that the download was successful (not access denied XML from s3) && grep -v -q "AccessDenied" ${OPENSTUDIO_DOWNLOAD_FILENAME} \ @@ -49,26 +60,29 @@ RUN curl -SLO -k https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz \ && ./configure \ && make && make install -## if the openstudio-${OPENSTUDIO_VERSION} folder existed, set it as the OPENSTUDIO -## folder, otherwise set the openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT} folder +## Detect the OpenStudio installation folder +## The folder will be openstudio-3.9.0 or something like openstudio-3.9.0-alpha +## We search for any folder matching the version pattern to handle various naming conventions -#the folder will be Openstudio-3.9.0 or something like Openstudio-3.9.0-alpha - -RUN if [ -d "/usr/local/openstudio-${OPENSTUDIO_VERSION}" ]; then \ - echo "OpenStudio folder is /usr/local/openstudio-${OPENSTUDIO_VERSION}"; \ - OPENSTUDIO_FOLDER=/usr/local/openstudio-${OPENSTUDIO_VERSION}; \ - else \ - echo "OpenStudio folder is /usr/local/openstudio-${OPENSTUDIO_VERSION}-${OPENSTUDIO_VERSION_EXT}"; \ - OPENSTUDIO_FOLDER=/usr/local/openstudio-${OPENSTUDIO_VERSION}-${OPENSTUDIO_VERSION_EXT}; \ +RUN echo "Searching for OpenStudio installation..." \ + && ls -la /usr/local \ + && ls -la /usr \ + && OPENSTUDIO_FOLDER=$(find /usr -maxdepth 2 -type d -name "openstudio-${OPENSTUDIO_VERSION}*" 2>/dev/null | head -1) \ + && if [ -z "$OPENSTUDIO_FOLDER" ]; then \ + echo "ERROR: OpenStudio folder not found matching pattern openstudio-${OPENSTUDIO_VERSION}*"; \ + echo "Searching for any openstudio folder..."; \ + find /usr -maxdepth 2 -type d -name "openstudio-*" 2>/dev/null; \ + exit 1; \ fi \ && echo "OpenStudio folder is ${OPENSTUDIO_FOLDER}" \ + && ls -la ${OPENSTUDIO_FOLDER} \ && rm -rf ruby* \ && gem install bundler -v $OS_BUNDLER_VERSION \ + && gem install zip \ && mkdir /var/oscli \ - && ls /usr/local \ && cp ${OPENSTUDIO_FOLDER}/Ruby/Gemfile /var/oscli/ \ && cp ${OPENSTUDIO_FOLDER}/Ruby/Gemfile.lock /var/oscli/ \ - && cp ${OPENSTUDIO_FOLDER}/Ruby/openstudio-gems.gemspec /var/oscli/\ + && cp ${OPENSTUDIO_FOLDER}/Ruby/openstudio-gems.gemspec /var/oscli/ \ && ln -s ${OPENSTUDIO_FOLDER} /usr/local/openstudio-${OPENSTUDIO_VERSION} ENV RUBYLIB=/usr/local/openstudio-${OPENSTUDIO_VERSION}/Ruby @@ -86,8 +100,8 @@ RUN bundle _${OS_BUNDLER_VERSION}_ install --path=gems --without=native_ext --jo # Configure the bootdir & confirm that openstudio is able to load the bundled gem set in /var/gemdata VOLUME /var/simdata/openstudio WORKDIR /var/simdata/openstudio -RUN openstudio --loglevel Trace --bundle /var/oscli/Gemfile --bundle_path /var/oscli/gems --bundle_without native_ext openstudio_version +RUN openstudio --loglevel Trace --bundle /var/oscli/Gemfile --bundle_path /var/oscli/gems --bundle_without native_ext gem_list # May need this for syscalls that do not have ext in path -CMD [ "/bin/bash" ] \ No newline at end of file +CMD [ "/bin/bash" ] diff --git a/README.md b/README.md index c22be36..300ae1a 100644 --- a/README.md +++ b/README.md @@ -85,3 +85,31 @@ If gem dependencies are required as part of the CLI outside of those # Issues Please submit issues on the project's [Github](https://github.com/nrel/docker-openstudio) page. + +## Building and publishing specific OpenStudio versions + + - **Local build for a specific version (example: 3.11.0-alpha):** + +```bash +docker build -t openstudio:latest \ + --build-arg OPENSTUDIO_VERSION=3.11.0 \ + --build-arg OPENSTUDIO_VERSION_EXT="-alpha" \ + --build-arg OPENSTUDIO_SHA= . +``` + +- **Tag and push locally (optional):** + +```bash +docker tag openstudio:latest yourrepo/openstudio:3.11.0-alpha +docker push yourrepo/openstudio:3.11.0-alpha +``` + +- **Trigger GitHub Actions build to publish to Docker Hub:** + + - Update `.github/workflows/docker-openstudio.yml` env values for `OPENSTUDIO_VERSION`, `OPENSTUDIO_VERSION_EXT`, and `OPENSTUDIO_SHA` on a branch. + - Create a pull request to `develop` and merge; the workflow will build and, if on `develop`, push the image to Docker Hub as the `develop` tag (and `latest`). + +Notes: + +- The `deploy_docker.sh` script tags images pushed to Docker Hub. You can override `DOCKER_REPO` for testing private repos. +- If `OPENSTUDIO_SHA` is empty, the downloader will attempt to use a generic S3 URL without the SHA. diff --git a/deploy_docker.sh b/deploy_docker.sh index 0de97fa..8490e1a 100755 --- a/deploy_docker.sh +++ b/deploy_docker.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash IMAGETAG=${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT} -echo "image would be tagged as $IMAGETAG if this were master branch" +echo "default image tag would be $IMAGETAG" IMAGETAG=skip +DOCKER_REPO=${DOCKER_REPO:-nrel/openstudio} # Check branch name for correct tagging if [ "${GITHUB_REF}" == "refs/heads/develop" ]; then @@ -29,12 +30,28 @@ fi # GITHUB_BASE_REF is only set on Pull Request events. Do not build those if [ "${IMAGETAG}" != "skip" ] && [[ -z "${GITHUB_BASE_REF}" ]]; then - echo "Tagging image as $IMAGETAG" + echo "Tagging image as $IMAGETAG and pushing to ${DOCKER_REPO}" echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin - docker tag openstudio:latest nrel/openstudio:$IMAGETAG; (( exit_status = exit_status || $? )) - docker tag openstudio:latest nrel/openstudio:latest; (( exit_status = exit_status || $? )) - docker push nrel/openstudio:$IMAGETAG; (( exit_status = exit_status || $? )) + # Tag versioned image + docker tag openstudio:latest ${DOCKER_REPO}:$IMAGETAG; (( exit_status = exit_status || $? )) + + # Only update and push 'latest' if this is a stable release (no extension) + if [ -z "${OPENSTUDIO_VERSION_EXT}" ]; then + echo "Stable release detected. Updating and pushing '${DOCKER_REPO}:latest'" + docker tag openstudio:latest ${DOCKER_REPO}:latest; (( exit_status = exit_status || $? )) + docker push ${DOCKER_REPO}:latest; (( exit_status = exit_status || $? )) + else + echo "Pre-release detected (extension: '${OPENSTUDIO_VERSION_EXT}'). Skipping 'latest' tag update." + fi + + # Push versioned tag + docker push ${DOCKER_REPO}:$IMAGETAG; (( exit_status = exit_status || $? )) + # If on develop branch, also push the develop tag pointing to this image + if [ "${IMAGETAG}" == "develop" ] || [ "${GITHUB_REF}" == "refs/heads/develop" ]; then + docker tag openstudio:latest ${DOCKER_REPO}:develop; (( exit_status = exit_status || $? )) + docker push ${DOCKER_REPO}:develop; (( exit_status = exit_status || $? )) + fi exit $exit_status else diff --git a/singularity/Dockerfile b/singularity/Dockerfile deleted file mode 100644 index b3166e6..0000000 --- a/singularity/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:18.04 - -ENV SINGULARITY_VERSION=2.5.1 -# singularity, then other dependencies -RUN apt-get update && apt-get install -y --no-install-recommends build-essential \ - python \ - python-pip \ - python-setuptools \ - libarchive-dev \ - squashfs-tools \ - curl \ - apt-transport-https \ - ca-certificates \ - software-properties-common \ - gnupg \ - vim \ - && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ - && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ - && apt-get update \ - && apt-get install -y --no-install-recommends docker-ce \ - && rm -rf /var/lib/apt/lists/* - -# Build and install singularity -WORKDIR /root/singularity-build -RUN curl -SLO https://github.com/singularityware/singularity/releases/download/$SINGULARITY_VERSION/singularity-$SINGULARITY_VERSION.tar.gz \ - && tar xvf singularity-$SINGULARITY_VERSION.tar.gz \ - && cd singularity-$SINGULARITY_VERSION \ - && ./configure --prefix=/usr/local \ - && make \ - && make install \ - && singularity --version - -COPY singularity/requirements.txt requirements.txt -RUN pip install -r requirements.txt - -WORKDIR /root/build -CMD ['/bin/bash'] \ No newline at end of file diff --git a/singularity/README.md b/singularity/README.md deleted file mode 100644 index 6cd155f..0000000 --- a/singularity/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# Creating Singularity Image - -* Build Singularity/Docker Image - - ```bash - docker build -t singularity -f singularity/Dockerfile . - ``` - -* Build OpenStudio Container (Locally) - - ```bash - # Set the version of OpenStudio to install - export OPENSTUDIO_VERSION=2.6.0 - export OPENSTUDIO_SHA=8c81faf8bc - - docker build -t docker-openstudio --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_VERSION --build-arg OPENSTUDIO_SHA=$OPENSTUDIO_SHA . - ``` - -* Launch the Container (in privileged mode with docker.sock mounted in the container) - - ```bash - docker run -it --rm --privileged -v $(pwd):/root/build -v /var/run/docker.sock:/var/run/docker.sock singularity bash - ``` - -* Inside singularity build the docker container - - ```bash - - if [ ! "$(docker ps -q -f name=for_export)" ]; then docker rm for_export; else echo "Container does not exist"; fi - # start an instance of the container for export - docker run --name for_export docker-openstudio /bin/true - if [ -f docker-openstudio.simg ]; then rm -f docker-openstudio.simg; else echo "File does not exist"; fi - singularity image.create -s 2000 docker-openstudio.simg - docker export for_export | singularity image.import docker-openstudio.simg - - # test singularity - singularity shell -B $(pwd):/singtest docker-openstudio.simg - # RUBYLIB isn't copied into Singularity container for some reason - export RUBYLIB=/usr/local/openstudio-2.6.0/Ruby - ruby /singtest/test/test.rb - - ``` - -* Exit out of the container and singularity image will be in the docker-openstudio root directory - -# Using Singularity Container - -* Download singularity image from S3 - -``` -curl -SLO https://s3.amazonaws.com/openstudio-builds/2.6.0/OpenStudio-2.6.0.ac20db5eff-Singularity.simg -``` - -* Run singularity container - -``` -module load singularity-container -# Mount /scratch for analysis -singularity shell -B /scratch:/scratch OpenStudio-2.6.0.ac20db5eff-Singularity.simg - -# Call bash (without --norc) for now until LANG is fixed -bash - -openstudio --version -``` - -* Running singularity in line - -``` -singularity exec -B /scratch:/var/simdata/openstudio OpenStudio-2.6.0.ac20db5eff-Singularity.simg openstudio run -w in.osw - - diff --git a/singularity/Singularity b/singularity/Singularity deleted file mode 100644 index fd0c7af..0000000 --- a/singularity/Singularity +++ /dev/null @@ -1,4 +0,0 @@ -Bootstrap: docker -Registry: http://127.0.0.1:5000 -Namespace: -From: docker-openstudio:latest diff --git a/singularity/build_singularity.sh b/singularity/build_singularity.sh deleted file mode 100755 index 4f06106..0000000 --- a/singularity/build_singularity.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Build singularity container -cd singularity -SINGULARITY_NOHTTPS=1 singularity build docker-openstudio.simg Singularity -cp docker-openstudio.simg .. diff --git a/singularity/deploy_singularity.sh b/singularity/deploy_singularity.sh deleted file mode 100755 index 0b6202f..0000000 --- a/singularity/deploy_singularity.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -# Building a container with singularity installed to build the OpenStudio singularity image -docker build -f singularity/Dockerfile -t singularity . -# OPENSTUDIO_VERSION and OPENSTUDIO_SHA are set by travis -# export OPENSTUDIO_VERSION=2.6.0 -# export OPENSTUDIO_SHA=ac20db5eff -docker build -t docker-openstudio --target base --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_VERSION --build-arg OPENSTUDIO_SHA=$OPENSTUDIO_SHA --build-arg OPENSTUDIO_VERSION_EXT=$OPENSTUDIO_VERSION_EXT . - -# Start the registry and push docker-openstudio -docker run -d -p 5000:5000 --restart=always --name registry registry:2 -sleep 5 -docker tag docker-openstudio localhost:5000/docker-openstudio -docker push localhost:5000/docker-openstudio - -docker ps - -# Launch the singularity container -docker run --rm --privileged --network=container:registry -v $(pwd):/root/build -v /var/run/docker.sock:/var/run/docker.sock singularity /root/build/singularity/build_singularity.sh - -# Shut down and remove the local registry -docker container stop registry && docker container rm -v registry - -ls -altR - -# Test with non-root user. The -u 1000 is not needed when testing locally on OSX. -# docker run -it --rm --privileged -u 1000 -v $(pwd):/root/build -v /var/run/docker.sock:/var/run/docker.sock singularity bash -# singularity shell -B $(pwd):/singtest docker-openstudio.simg -#ruby /singtest/test/test.rb -#ls -alR - -# Determine the name of the tag -IMAGETAG=skip -if [ "${GITHUB_REF}" == "refs/heads/develop" ]; then - IMAGETAG=develop -elif [ "${GITHUB_REF}" == "refs/heads/2.9.X-LTS" ]; then - IMAGETAG="2.9.X-LTS" -elif [ "${GITHUB_REF}" == "refs/heads/master" ]; then - IMAGETAG=${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT} - # Uncomment and set branch name for custom builds. -elif [ "${GITHUB_REF}" == "refs/heads/custom_branch_name" ]; then - IMAGETAG=experimental -fi - -# upload to s3. The OPENSTUDIO_SHA is taken from the env vars -if [ "$IMAGETAG" != "skip" ]; then - pip install -r singularity/requirements.txt - python singularity/upload_s3.py -fi - diff --git a/singularity/index.html b/singularity/index.html deleted file mode 100644 index d857623..0000000 --- a/singularity/index.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - - - - - - - - \ No newline at end of file diff --git a/singularity/requirements.txt b/singularity/requirements.txt deleted file mode 100644 index ea948fa..0000000 --- a/singularity/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -boto3 -requests diff --git a/singularity/upload_s3.py b/singularity/upload_s3.py deleted file mode 100644 index e9b1ab0..0000000 --- a/singularity/upload_s3.py +++ /dev/null @@ -1,40 +0,0 @@ -import boto3 -import os -import argparse - - -def image_file_name_and_s3_key(basename, version, sha=None): - name = '%s-%s-Singularity.simg' % (basename, version) - if sha: - name = '%s-%s.%s-Singularity.simg' % (basename, version, sha) - s3_key = '%s/%s' % (version, name) - - return s3_key - - -def main(): - print("Starting upload_s3.py") - parser = argparse.ArgumentParser(description='Upload file to S3 with version and SHA') - parser.add_argument('--version', default=None) - parser.add_argument('--sha', default=None) - args = parser.parse_args() - - if args.version is None: - args.version = os.getenv('OPENSTUDIO_VERSION', 'latest') - if args.sha is None: - args.sha = os.getenv('OPENSTUDIO_SHA', None) - - print(args) - ############# Script ################ - s3 = boto3.client('s3') - bucket_name = 'openstudio-builds' - filename = 'docker-openstudio.simg' - if os.path.exists(filename): - s3_key = image_file_name_and_s3_key('OpenStudio', args.version, args.sha) - print("Uploading %s to %s" % (filename, s3_key)) - data = open(filename, 'rb') - s3.put_object(Bucket=bucket_name, Key=s3_key, Body=data) - - -if __name__ == '__main__': - main()