Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 70 additions & 8 deletions .github/workflows/openstudio-server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
OPENSTUDIO_VERSION: 3.10.0
OPENSTUDIO_VERSION_SHA: 86d7e215a1
OPENSTUDIO_VERSION_EXT: ""
DOCKER_COMPOSE_VERSION: 1.29.2
DOCKER_COMPOSE_VERSION: 2.38.2
BUNDLE_WITHOUT: native_ext


Expand Down Expand Up @@ -101,12 +101,38 @@ jobs:
name: openstudio-server-gems-darwin
path: build/NREL/export/*.tar.gz
docker:
runs-on: ubuntu-24.04
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
os: ubuntu-24.04
platform: linux/amd64
- arch: arm64
os: ubuntu-24.04-arm
platform: linux/arm64
env:
DEPLOY_ARCH: ${{ matrix.arch }}
DOCKER_PLATFORM: ${{ matrix.platform }}
steps:
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Check out repository
uses: actions/checkout@v4
- name: Fix Docker Path for ARM64 Runner
run: |
if [ -f /usr/bin/docker ]; then
echo "Docker already exists in /usr/bin"
elif [ -f /usr/local/bin/docker ]; then
sudo ln -s /usr/local/bin/docker /usr/bin/docker
else
# If not found in common locations, explicitly locate and export it
DOCKER_BIN=$(which docker || find / -name docker -type f -perm -o+x 2>/dev/null | head -n 1)
if [ ! -z "$DOCKER_BIN" ]; then
sudo ln -s "$DOCKER_BIN" /usr/bin/docker
fi
fi
- name: setup
shell: bash
run: ./ci/github-actions/setup.sh
Expand All @@ -120,8 +146,15 @@ jobs:
docker volume create --name=osdata
docker images --all
docker --version
docker-compose --version
docker-compose -f docker-compose.test.yml pull
docker compose --version
if [ "${DEPLOY_ARCH}" = "arm64" ]; then
# The first arm64 run may predate an arm64 entry in the :latest
# manifests, so tolerate pull failure and build from scratch.
# BuildKit also skips missing cache_from images without failing.
docker compose -f docker-compose.test.yml pull || echo "arm64 pull skipped/failed; building from scratch"
else
docker compose -f docker-compose.test.yml pull
fi
# Rebuild the rserve image only when its inputs changed. PR runs otherwise reuse
# the pulled nrel/openstudio-rserve:latest (kept fresh by docker-upload on
# develop/master pushes): rebuilding R packages on every run cost ~10 min and
Expand All @@ -136,11 +169,11 @@ jobs:
echo "docker/R is unchanged by this PR: reusing pulled nrel/openstudio-rserve:latest instead of rebuilding it"
BUILD_SERVICES="web"
fi
docker-compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG $BUILD_SERVICES
docker-compose -f docker-compose.test.yml up -d
docker compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG --build-arg DOCKER_PLATFORM=$DOCKER_PLATFORM $BUILD_SERVICES
docker compose -f docker-compose.test.yml up -d
#set SKIP_URBANOPT_ALGO=true to skip UrbanOpt algo tests
docker-compose exec -e SKIP_URBANOPT_ALGO=true -T web /usr/local/bin/run-server-tests
docker-compose stop
docker compose exec -e SKIP_URBANOPT_ALGO=true -T web /usr/local/bin/run-server-tests
docker compose stop
git checkout -- .dockerignore && git checkout -- Dockerfile
env:
CI: true
Expand All @@ -167,3 +200,32 @@ jobs:
# https://docs.github.com/en/actions/reference/encrypted-secrets
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
docker-manifest:
# Merge the per-arch images pushed by the docker job into canonical
# multi-arch manifests. Runs after BOTH matrix legs (amd64 + arm64) push.
needs: docker
runs-on: ubuntu-24.04
if: |
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/3.10.0' ||
github.ref == 'refs/heads/179' ||
github.ref == 'refs/heads/fix/zip-read-only-extract'
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: setup
shell: bash
run: ./ci/github-actions/setup.sh
env:
BUILD_TYPE: docker
- name: merge multi-arch manifests
shell: bash
run: ./docker/deployment/scripts/merge_manifests_github_actions.sh
env:
CI: true
BUILD_TYPE: docker
# On forked Pull Requests secrets will not be sent to the runner. See more info here:
# https://docs.github.com/en/actions/reference/encrypted-secrets
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
6 changes: 3 additions & 3 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
OPENSTUDIO_VERSION: 3.10.0
OPENSTUDIO_VERSION_SHA: 86d7e215a1
OPENSTUDIO_VERSION_EXT: ""
DOCKER_COMPOSE_VERSION: 1.29.2
DOCKER_COMPOSE_VERSION: 2.38.2
BUNDLE_WITHOUT: native_ext


Expand All @@ -45,8 +45,8 @@ jobs:
docker volume create --name=osdata
docker images --all
docker --version
docker-compose --version
docker-compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG web
docker compose --version
docker compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG web
env:
CI: true
OS_SERVER_NUMBER_OF_WORKERS: 4
Expand Down
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AUTHOR: Nicholas Long
# DESCRIPTION: OpenStudio Server Docker Container
# TO_BUILD_AND_RUN: docker-compose up
# TO_BUILD_AND_RUN: docker compose up
# NOTES: Currently this is one big dockerfile and non-optimal.

# may include suffix
Expand Down Expand Up @@ -159,8 +159,13 @@ EXPOSE 8080 9090
# Multistage build includes test library. To build without testing run
# docker build --target base -t some-tag .
FROM base
ENV GECKODRIVER_VERSION=v0.21.0
# geckodriver >= v0.30.0 ships linux-aarch64 builds (v0.21.0 was linux64-only).
# The test suite no longer drives Firefox through geckodriver (see
# run-server-tests.sh), so this is mainly for manual/legacy test runs.
ENV GECKODRIVER_VERSION=v0.35.0
# Install vfb and firefox requirement if docker-test env
# Automatically populated by BuildKit (amd64 / arm64).
ARG TARGETARCH
RUN echo "Running in testing environment - Installing Firefox and Gecko Driver" && \
apt-get update && \
apt-get install -y xvfb \
Expand All @@ -172,10 +177,11 @@ RUN echo "Running in testing environment - Installing Firefox and Gecko Driver"
firefox && \
rm -rf /var/lib/apt/lists/* && \
cd /usr/local/bin && \
wget http://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz && \
tar -xvzf geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz && \
rm geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz && \
chmod +x geckodriver;
if [ "${TARGETARCH}" = "arm64" ]; then GECKODRIVER_ARCH="linux-aarch64"; else GECKODRIVER_ARCH="linux64"; fi && \
wget http://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-${GECKODRIVER_ARCH}.tar.gz && \
tar -xvzf geckodriver-${GECKODRIVER_VERSION}-${GECKODRIVER_ARCH}.tar.gz && \
rm geckodriver-${GECKODRIVER_VERSION}-${GECKODRIVER_ARCH}.tar.gz && \
chmod +x geckodriver

COPY /docker/server/run-server-tests.sh /usr/local/bin/run-server-tests
RUN chmod +x /usr/local/bin/run-server-tests
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ To develop locally the following dependency stack is recommended.
#### Docker Compose

```bash
docker-compose build
docker compose build
```

... [be patient](https://www.youtube.com/watch?v=f4hkPn0Un_Q) ... If the containers build successfully start them by
running `docker volume create --name=osdata && docker volume create --name=dbdata && OS_SERVER_NUMBER_OF_WORKERS=4 docker-compose up --scale worker=4`
running `docker volume create --name=osdata && docker volume create --name=dbdata && OS_SERVER_NUMBER_OF_WORKERS=4 docker compose up --scale worker=4`
where 4 is equal to the number of worker nodes you wish to run. For single node servers this should not be greater
than the total number of available cores minus 4.

Resetting the containers can be accomplished by running:

```bash
docker-compose rm -f
docker compose rm -f
docker volume rm osdata dbdata
docker volume create --name=osdata
docker volume create --name=dbdata
OS_SERVER_NUMBER_OF_WORKERS=N docker-compose up -d --scale worker=N
OS_SERVER_NUMBER_OF_WORKERS=N docker compose up -d --scale worker=N

# Or one line
docker-compose rm -f && docker-compose build && docker volume rm osdata dbdata && docker volume create --name=osdata && docker volume create --name=dbdata && OS_SERVER_NUMBER_OF_WORKERS=N docker-compose up -d --scale worker=N
docker compose rm -f && docker compose build && docker volume rm osdata dbdata && docker volume create --name=osdata && docker volume create --name=dbdata && OS_SERVER_NUMBER_OF_WORKERS=N docker compose up -d --scale worker=N
```

Congratulations! Visit `http://localhost:8080` to see the OpenStudio Server Management Console.
Expand All @@ -89,17 +89,17 @@ Congratulations! Visit `http://localhost:8080` to see the OpenStudio Server Mana
export OPENSTUDIO_TAG=develop
export RAILS_ENV=docker-test

docker-compose rm -f
docker compose rm -f
docker volume rm osdata
sed -i -E "s/.git//g" .dockerignore
docker volume create --name=osdata
docker-compose -f docker-compose.test.yml pull
docker-compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG
docker-compose -f docker-compose.test.yml up -d
docker-compose exec -T web /usr/local/bin/run-server-tests
docker-compose stop
docker compose -f docker-compose.test.yml pull
docker compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG
docker compose -f docker-compose.test.yml up -d
docker compose exec -T web /usr/local/bin/run-server-tests
docker compose stop
git checkout -- .dockerignore && git checkout -- Dockerfile
docker-compose rm -f
docker compose rm -f
```

### Local Docker Swarm Deployment
Expand Down
13 changes: 10 additions & 3 deletions ci/github-actions/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
set -euo pipefail
echo "The build architecture is ${ImageOS}"

if [ "${ImageOS}" == "ubuntu24" ] && [ "${BUILD_TYPE}" == "docker" ]; then
if { [ "${ImageOS}" == "ubuntu24" ] || [ "${ImageOS}" == "ubuntu24-arm64" ]; } && [ "${BUILD_TYPE}" == "docker" ]; then
echo "Installing docker compose"
sudo rm -f /usr/local/bin/docker-compose
echo "Check if docker compose is already installed"
if command -v docker-compose &> /dev/null; then
echo "docker-compose is already installed"
docker-compose --version
exit 0
fi
# install docker compose v2
sudo rm -f /usr/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
sudo mv docker-compose /usr/bin/
# install pipeviewer
sudo apt-get update
sudo apt-get install -y pv ruby
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker Compose creates multiple containers on a single machine.
# run `docker-compose up` to create and run/link the containers
# run `docker compose up` to create and run/link the containers
services:
db:
image: mongo:8.0.12
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker Compose creates multiple containers on a single machine.
# run `docker-compose up` to create and run/link the containers
# run `docker compose up` to create and run/link the containers
services:
db:
image: mongo:8.0.12
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker Compose creates multiple containers on a single machine.
# run `docker-compose up` to create and run/link the containers
# run `docker compose up` to create and run/link the containers
services:
db:
image: mongo:8.0.12
Expand Down
2 changes: 1 addition & 1 deletion docker/R/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AUTHOR: Nicholas Long
# DESCRIPTION: OpenStudio Server R Container
# TO_BUILD_AND_RUN: docker-compose up
# TO_BUILD_AND_RUN: docker compose up

ARG DOCKER_PLATFORM=linux/amd64
FROM --platform=${DOCKER_PLATFORM} nrel/openstudio-r:4.4.0
Expand Down
67 changes: 28 additions & 39 deletions docker/deployment/scripts/deploy_docker_github_actions.sh
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
#!/usr/bin/env bash
# Tags the locally-built images with an arch suffix and pushes them.
# The canonical (multi-arch) tags are created later by
# merge_manifests_github_actions.sh.
#
# Required env: DOCKER_USER, DOCKER_PASS
# Optional env: DEPLOY_ARCH (amd64|arm64, default amd64)
set -euo pipefail

# Default set IMAGETAG to skip.
IMAGETAG="skip"
source "$(dirname "$0")/get_image_tag.sh"
DEPLOY_ARCH=${DEPLOY_ARCH:-amd64}

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
# Retrieve the version number from rails
IMAGETAG="$(ruby -e "load 'server/app/lib/openstudio_server/version.rb'; print OpenstudioServer::Version+OpenstudioServer::VERSION_EXT")"
# Uncomment and set branch name for custom builds.
# Currently setting this to setup_github_actions to test upload.
elif [ "${GITHUB_REF}" == "refs/heads/setup_github_actions" ]; then
IMAGETAG=experimental
elif [ "${GITHUB_REF}" == "refs/heads/3.10.0" ]; then
IMAGETAG="3.10.0-rc2"
elif [ "${GITHUB_REF}" == "refs/heads/179" ]; then
IMAGETAG="3.10.0-179"
# issue-857 zip-corruption fix candidate for cluster testing; remove mapping once merged into 179
elif [ "${GITHUB_REF}" == "refs/heads/fix/zip-read-only-extract" ]; then
IMAGETAG="179-flock"
if [ "${IMAGETAG}" == "skip" ]; then
echo "Not on a deployable branch [master/develop/179/...] or this is a pull request"
exit 0
fi

if [ "${IMAGETAG}" != "skip" ]; then
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin

echo "Tagging image as $IMAGETAG"
docker tag nrel/openstudio-server nrel/openstudio-server:$IMAGETAG; (( exit_status = exit_status || $? ))
docker tag nrel/openstudio-rserve nrel/openstudio-rserve:$IMAGETAG; (( exit_status = exit_status || $? ))
docker push nrel/openstudio-server:$IMAGETAG; (( exit_status = exit_status || $? ))
docker push nrel/openstudio-rserve:$IMAGETAG; (( exit_status = exit_status || $? ))
# Push arch-suffixed images. The canonical tags are assembled by the manifest
# job so that parallel amd64/arm64 pushes never clobber each other.
for IMAGE in nrel/openstudio-server nrel/openstudio-rserve; do
echo "Tagging image as ${IMAGE}:${IMAGETAG}-${DEPLOY_ARCH}"
docker tag "${IMAGE}" "${IMAGE}:${IMAGETAG}-${DEPLOY_ARCH}"
docker push "${IMAGE}:${IMAGETAG}-${DEPLOY_ARCH}"
done

if [ "${GITHUB_REF}" == "refs/heads/master" ]; then
# Deploy master as the latest.
docker tag nrel/openstudio-server nrel/openstudio-server:latest; (( exit_status = exit_status || $? ))
docker tag nrel/openstudio-rserve nrel/openstudio-rserve:latest; (( exit_status = exit_status || $? ))

docker push nrel/openstudio-server:latest; (( exit_status = exit_status || $? ))
docker push nrel/openstudio-rserve:latest; (( exit_status = exit_status || $? ))
fi

exit $exit_status
else
echo "Not on a deployable branch [master/nrcan-master/develop] or this is a pull request"
if [ "${GITHUB_REF}" == "refs/heads/master" ]; then
# Deploy master as the latest.
for IMAGE in nrel/openstudio-server nrel/openstudio-rserve; do
docker tag "${IMAGE}" "${IMAGE}:latest-${DEPLOY_ARCH}"
docker push "${IMAGE}:latest-${DEPLOY_ARCH}"
done
fi

echo "Done pushing ${DEPLOY_ARCH} artifacts for ${IMAGETAG}"
27 changes: 27 additions & 0 deletions docker/deployment/scripts/get_image_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Determines the image tag based on the branch. Sourced by
# deploy_docker_github_actions.sh and merge_manifests_github_actions.sh.
# Sets IMAGETAG (or "skip" when nothing should be deployed/merged).
set -euo pipefail

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
# Retrieve the version number from rails
IMAGETAG="$(ruby -e "load 'server/app/lib/openstudio_server/version.rb'; print OpenstudioServer::Version+OpenstudioServer::VERSION_EXT")"
# Uncomment and set branch name for custom builds.
# Currently setting this to setup_github_actions to test upload.
elif [ "${GITHUB_REF}" == "refs/heads/setup_github_actions" ]; then
IMAGETAG=experimental
elif [ "${GITHUB_REF}" == "refs/heads/3.10.0" ]; then
IMAGETAG="3.10.0-rc2"
elif [ "${GITHUB_REF}" == "refs/heads/179" ]; then
IMAGETAG="3.10.0-179"
# issue-857 zip-corruption fix candidate for cluster testing; remove mapping once merged into 179
elif [ "${GITHUB_REF}" == "refs/heads/fix/zip-read-only-extract" ]; then
IMAGETAG="179-flock"
fi
Loading
Loading