From 1d0f8c133a355ccac42450662211197299598043 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 10:49:13 +0100 Subject: [PATCH 01/17] Initial CI setup --- .github/workflows/ci.yaml | 72 +++++++++++++++++++++++++ .github/workflows/release.yaml | 97 ++++++++++++++++++++++++++++++++++ Dockerfile | 10 ---- 3 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..ba10ac0fa --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,72 @@ +# Continuous integration, including test and integration test +name: CI Node + +# Run in master and dev branches and in all pull requests to those branches +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + # Build and test the code + build: + # The type of runner that the job will run on + 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 + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + # Compile the code + - name: Install dependencies + working-directory: ./radar-app-config-frontend + run: npm run build + + docker: + - uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ohdsi/atlas + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.labels }} + labels: | + ${{ steps.docker_meta.outputs.labels }} + org.opencontainers.image.title="OHDSI ATLAS" + org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" + org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ + to conduct scientific analyses on standardized observational data converted to the \ + OMOP Common Data Model. It is served as a static site by Nginx." + org.opencontainers.image.licenses="Apache-2.0" + org.opencontainers.image.vendor="OHDSI" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..d6d3dff42 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,97 @@ +# Create release files +name: Release + +on: + release: + types: [published] + +jobs: + + upload: + # The type of runner that the job will run on + 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: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Cache + uses: actions/cache@v2.0.0 + with: + # A list of files, directories, and wildcard patterns to cache and restore + path: | + ~/.gradle/caches/jars-3 + ~/.gradle/caches/modules-2/files-2.1/ + ~/.gradle/caches/modules-2/metadata-2.96/ + ~/.gradle/native + ~/.gradle/wrapper + # An explicit key for restoring and saving the cache + key: ${{ runner.os }}-gradle + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + # Compile the code + - name: Build code + run: npm run build:docker + + - name: Make distribution + run: | + mkdir atlas + cp -r LICENSE README.md node_modules js images index.html atlas + zip -r atlas.zip atlas + + # Upload it to GitHub + - name: Upload to GitHub + uses: AButler/upload-release-assets@v2.0 + with: + files: 'atlas.zip' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + docker: + - uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ohdsi/atlas + tag-match: v(.*) + tag-match-group: 1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x + push: true + tags: ${{ steps.docker_meta.outputs.labels }} + labels: | + ${{ steps.docker_meta.outputs.labels }} + org.opencontainers.image.title="OHDSI ATLAS" + org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" + org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ + to conduct scientific analyses on standardized observational data converted to the \ + OMOP Common Data Model. It is served as a static site by Nginx." + org.opencontainers.image.licenses="Apache-2.0" + org.opencontainers.image.vendor="OHDSI" diff --git a/Dockerfile b/Dockerfile index 42790e932..3462e5ade 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,24 +28,14 @@ RUN RUN find . -type f "(" \ # Production Nginx image FROM nginxinc/nginx-unprivileged:1.19-alpine -# Published version of Atlas -ARG VERSION=SNAPSHOT -# Datetime that this image was created in ISO 8601 format -ARG CREATED=SNAPSHOT -# Git revision -ARG REVISION=SNAPSHOT - LABEL org.opencontainers.image.title="OHDSI ATLAS" LABEL org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" -LABEL org.opencontainers.image.version="${VERSION}" LABEL org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ to conduct scientific analyses on standardized observational data converted to the \ OMOP Common Data Model. It is served as a static site by Nginx." LABEL org.opencontainers.image.licenses="Apache-2.0" LABEL org.opencontainers.image.vendor="OHDSI" LABEL org.opencontainers.image.source="https://github.com/OHDSI/Atlas" -LABEL org.opencontainers.image.created="${CREATED}" -LABEL org.opencontainers.image.revision="${REVISION}" # URL where WebAPI can be queried by the client ENV WEBAPI_URL=http://localhost:8080/WebAPI/ From 7af2261dc8b801149dae8b5df08f62be8b88890a Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 11:45:39 +0100 Subject: [PATCH 02/17] Fix indentation --- .github/workflows/ci.yaml | 9 +++- .github/workflows/release.yaml | 75 ++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ba10ac0fa..0c5410a5b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,7 +35,12 @@ jobs: run: npm run build docker: - - uses: actions/checkout@v2 + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: actions/checkout@v2 - name: Docker meta id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 @@ -60,7 +65,7 @@ jobs: context: ./ file: ./Dockerfile push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.labels }} + tags: ${{ steps.docker_meta.outputs.tags }} labels: | ${{ steps.docker_meta.outputs.labels }} org.opencontainers.image.title="OHDSI ATLAS" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d6d3dff42..79b0198c9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -57,41 +57,46 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} docker: - - uses: actions/checkout@v2 - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - images: ohdsi/atlas - tag-match: v(.*) - tag-match-group: 1 + # The type of runner that the job will run on + runs-on: ubuntu-latest - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ohdsi/atlas + tag-match: v(.*) + tag-match-group: 1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x - push: true - tags: ${{ steps.docker_meta.outputs.labels }} - labels: | - ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.title="OHDSI ATLAS" - org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ - to conduct scientific analyses on standardized observational data converted to the \ - OMOP Common Data Model. It is served as a static site by Nginx." - org.opencontainers.image.licenses="Apache-2.0" - org.opencontainers.image.vendor="OHDSI" + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: | + ${{ steps.docker_meta.outputs.labels }} + org.opencontainers.image.title="OHDSI ATLAS" + org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" + org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ + to conduct scientific analyses on standardized observational data converted to the \ + OMOP Common Data Model. It is served as a static site by Nginx." + org.opencontainers.image.licenses="Apache-2.0" + org.opencontainers.image.vendor="OHDSI" From 1a40cf763216d9ce0f16755c7ebf1730452354d3 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 11:50:28 +0100 Subject: [PATCH 03/17] Add CI docs --- .github/workflows/ci.yaml | 3 +++ .github/workflows/release.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c5410a5b..2b9a1d9af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,12 +41,15 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - uses: actions/checkout@v2 + + # Add Docker labels and tags - name: Docker meta id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: images: ohdsi/atlas + # Setup docker build environment - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 79b0198c9..312de9281 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -63,6 +63,8 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - uses: actions/checkout@v2 + + # Add Docker labels and tags - name: Docker meta id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 @@ -71,6 +73,7 @@ jobs: tag-match: v(.*) tag-match-group: 1 + # Setup docker build environment - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx From 6ddc23ceb077e0e8cc3cfb4d3c50235f74444bad Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 12:01:11 +0100 Subject: [PATCH 04/17] Added more docs --- .github/workflows/ci.yaml | 13 +++++++++---- .github/workflows/release.yaml | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b9a1d9af..4c9c8a162 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,28 +18,32 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + + # Caches NPM dependencies, as long as the package-lock.json is not modified - uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- + - name: Use Node.js 12 uses: actions/setup-node@v1 with: node-version: 12 - # Compile the code - - name: Install dependencies - working-directory: ./radar-app-config-frontend + - name: Build code run: npm run build + # Check that the docker image builds correctly + # Push to ohdsi/atlas:master for commits on master. docker: # The type of runner that the job will run on 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 # Add Docker labels and tags @@ -67,8 +71,9 @@ jobs: with: context: ./ file: ./Dockerfile - push: ${{ github.event_name != 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} # Push the master branch only tags: ${{ steps.docker_meta.outputs.tags }} + # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} org.opencontainers.image.title="OHDSI ATLAS" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 312de9281..7b979385c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -56,6 +56,8 @@ jobs: files: 'atlas.zip' repo-token: ${{ secrets.GITHUB_TOKEN }} + # Build and push tagged release docker image to + # ohdsi/atlas: and ohdsi/atlas:latest. docker: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -91,9 +93,11 @@ jobs: with: context: ./ file: ./Dockerfile + # Allow running the image on the architectures supported by nginx-unprivileged:alpine. platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x push: true tags: ${{ steps.docker_meta.outputs.tags }} + # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} org.opencontainers.image.title="OHDSI ATLAS" From bcab7eba4795a83a478f9cfb71ede9a0b32b6064 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 12:06:05 +0100 Subject: [PATCH 05/17] Fixed CI name and labels --- .github/workflows/ci.yaml | 9 ++------- .github/workflows/release.yaml | 5 ----- Dockerfile | 7 +++---- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4c9c8a162..87bce3af0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,5 @@ -# Continuous integration, including test and integration test -name: CI Node +# Continuous integration +name: CI # Run in master and dev branches and in all pull requests to those branches on: @@ -76,10 +76,5 @@ jobs: # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.title="OHDSI ATLAS" org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ - to conduct scientific analyses on standardized observational data converted to the \ - OMOP Common Data Model. It is served as a static site by Nginx." - org.opencontainers.image.licenses="Apache-2.0" org.opencontainers.image.vendor="OHDSI" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7b979385c..1f33c6883 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -100,10 +100,5 @@ jobs: # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.title="OHDSI ATLAS" org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ - to conduct scientific analyses on standardized observational data converted to the \ - OMOP Common Data Model. It is served as a static site by Nginx." - org.opencontainers.image.licenses="Apache-2.0" org.opencontainers.image.vendor="OHDSI" diff --git a/Dockerfile b/Dockerfile index 3462e5ade..aa626ee93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,11 +28,10 @@ RUN RUN find . -type f "(" \ # Production Nginx image FROM nginxinc/nginx-unprivileged:1.19-alpine -LABEL org.opencontainers.image.title="OHDSI ATLAS" +LABEL org.opencontainers.image.title="OHDSI-Atlas" LABEL org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" -LABEL org.opencontainers.image.description="ATLAS is an open source software tool for researchers \ -to conduct scientific analyses on standardized observational data converted to the \ -OMOP Common Data Model. It is served as a static site by Nginx." +LABEL org.opencontainers.image.description="ATLAS is an open source software tool for researchers to \ +conduct scientific analyses on standardized observational data" LABEL org.opencontainers.image.licenses="Apache-2.0" LABEL org.opencontainers.image.vendor="OHDSI" LABEL org.opencontainers.image.source="https://github.com/OHDSI/Atlas" From 50d7afce3f396a3197ed991522ef56fc5118ddec Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 12:19:27 +0100 Subject: [PATCH 06/17] Log in to thehyve docker instead --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 87bce3af0..eec7061ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,7 +51,7 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - images: ohdsi/atlas + images: thehyve/ohdsi-atlas # Setup docker build environment - name: Set up QEMU diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1f33c6883..2a5a3d78c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -71,7 +71,7 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - images: ohdsi/atlas + images: thehyve/ohdsi-atlas tag-match: v(.*) tag-match-group: 1 From 035d76f48b678c4c47fee6b9c37987a976c61c22 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 14:06:14 +0100 Subject: [PATCH 07/17] Fix multi-platform build --- .github/workflows/release.yaml | 2 +- Dockerfile | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2a5a3d78c..dec120c49 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -94,7 +94,7 @@ jobs: context: ./ file: ./Dockerfile # Allow running the image on the architectures supported by nginx-unprivileged:alpine. - platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm/v7,linux/ppc64le,linux/s390x push: true tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels diff --git a/Dockerfile b/Dockerfile index aa626ee93..b80f38338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the source -FROM node:12 as builder +FROM node:12-alpine as builder WORKDIR /code diff --git a/package.json b/package.json index 5cf772310..55d83484f 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "@babel/polyfill": "^7.0.0", "@babel/preset-env": "^7.1.5", "esprima": "^4.0.1", - "html-document": "^0.8.1", "genversion": "^2.2.0", + "html-document": "^0.8.1", "requirejs": "^2.3.6", "rimraf": "^2.6.2", "terser": "3.17.0" From e25b1c4037f754c2ffcfb9cf39466d3916955f2a Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 14:19:24 +0100 Subject: [PATCH 08/17] Add docker build cache for layers --- .github/workflows/ci.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eec7061ac..868cc0a94 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,6 +46,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + # Add Docker labels and tags - name: Docker meta id: docker_meta @@ -71,6 +79,8 @@ jobs: with: context: ./ file: ./Dockerfile + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max push: ${{ github.event_name != 'pull_request' }} # Push the master branch only tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels From 46e543992dde29dd81aed1557c921ee1c7741dc1 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 14:30:16 +0100 Subject: [PATCH 09/17] Install dependencies --- .github/workflows/release.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index dec120c49..c721703f7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -39,6 +39,9 @@ jobs: restore-keys: | ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + # Compile the code - name: Build code run: npm run build:docker @@ -94,7 +97,7 @@ jobs: context: ./ file: ./Dockerfile # Allow running the image on the architectures supported by nginx-unprivileged:alpine. - platforms: linux/amd64,linux/arm/v7,linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm/v7 push: true tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels From 0ed691b91d5fc0c872824643408a63b0ba590624 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 16:32:44 +0100 Subject: [PATCH 10/17] Tweaks to release files --- .github/workflows/release.yaml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c721703f7..94b569840 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,18 +20,6 @@ jobs: with: node-version: 12 - - name: Cache - uses: actions/cache@v2.0.0 - with: - # A list of files, directories, and wildcard patterns to cache and restore - path: | - ~/.gradle/caches/jars-3 - ~/.gradle/caches/modules-2/files-2.1/ - ~/.gradle/caches/modules-2/metadata-2.96/ - ~/.gradle/native - ~/.gradle/wrapper - # An explicit key for restoring and saving the cache - key: ${{ runner.os }}-gradle - uses: actions/cache@v2 with: path: ~/.npm @@ -97,7 +85,7 @@ jobs: context: ./ file: ./Dockerfile # Allow running the image on the architectures supported by nginx-unprivileged:alpine. - platforms: linux/amd64,linux/arm/v7 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels From a61638b6d63df5e1993d740f250b7592fd887fbb Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 16:36:24 +0100 Subject: [PATCH 11/17] Build fixes --- .github/workflows/ci.yaml | 10 ++++++++++ .github/workflows/release.yaml | 20 ++++++-------------- Dockerfile | 2 +- package.json | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 87bce3af0..1655d18e0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,6 +46,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + # Add Docker labels and tags - name: Docker meta id: docker_meta @@ -71,6 +79,8 @@ jobs: with: context: ./ file: ./Dockerfile + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max push: ${{ github.event_name != 'pull_request' }} # Push the master branch only tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1f33c6883..c1d698df6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,25 +20,17 @@ jobs: with: node-version: 12 - - name: Cache - uses: actions/cache@v2.0.0 - with: - # A list of files, directories, and wildcard patterns to cache and restore - path: | - ~/.gradle/caches/jars-3 - ~/.gradle/caches/modules-2/files-2.1/ - ~/.gradle/caches/modules-2/metadata-2.96/ - ~/.gradle/native - ~/.gradle/wrapper - # An explicit key for restoring and saving the cache - key: ${{ runner.os }}-gradle - - uses: actions/cache@v2 + - name: NPM cache + uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + # Compile the code - name: Build code run: npm run build:docker @@ -94,7 +86,7 @@ jobs: context: ./ file: ./Dockerfile # Allow running the image on the architectures supported by nginx-unprivileged:alpine. - platforms: linux/amd64,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels diff --git a/Dockerfile b/Dockerfile index aa626ee93..b80f38338 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the source -FROM node:12 as builder +FROM node:12-alpine as builder WORKDIR /code diff --git a/package.json b/package.json index 5cf772310..55d83484f 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "@babel/polyfill": "^7.0.0", "@babel/preset-env": "^7.1.5", "esprima": "^4.0.1", - "html-document": "^0.8.1", "genversion": "^2.2.0", + "html-document": "^0.8.1", "requirejs": "^2.3.6", "rimraf": "^2.6.2", "terser": "3.17.0" From 3619a928c2102db901cc038dc940c9434866b293 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 16:56:34 +0100 Subject: [PATCH 12/17] Inspect image after building --- .github/workflows/ci.yaml | 9 ++++++++- .github/workflows/release.yaml | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1655d18e0..b8b4f0c45 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,9 @@ on: pull_request: branches: [ master ] +env: + DOCKER_IMAGE: ohdsi/atlas + jobs: # Build and test the code build: @@ -59,7 +62,7 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - images: ohdsi/atlas + images: ${{ env.DOCKER_IMAGE }} # Setup docker build environment - name: Set up QEMU @@ -88,3 +91,7 @@ jobs: ${{ steps.docker_meta.outputs.labels }} org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" org.opencontainers.image.vendor="OHDSI" + + - name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c1d698df6..8a7b85d65 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,8 +5,10 @@ on: release: types: [published] -jobs: +env: + DOCKER_IMAGE: ohdsi/atlas +jobs: upload: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -63,7 +65,7 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - images: ohdsi/atlas + images: ${{ env.DOCKER_IMAGE }} tag-match: v(.*) tag-match-group: 1 @@ -94,3 +96,7 @@ jobs: ${{ steps.docker_meta.outputs.labels }} org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" org.opencontainers.image.vendor="OHDSI" + + - name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} From 563859d2e4f3d7a3782146f5ff6d5ed9654c192e Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 17:02:34 +0100 Subject: [PATCH 13/17] Make docker image available for inspection --- .github/workflows/ci.yaml | 7 +------ .github/workflows/release.yaml | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d522ce12d..be35a447b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,12 +70,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -84,6 +78,7 @@ jobs: file: ./Dockerfile cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + load: true push: ${{ github.event_name != 'pull_request' }} # Push the master branch only tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fe85ce9a4..acf83dc78 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -90,6 +90,7 @@ jobs: # Allow running the image on the architectures supported by nginx-unprivileged:alpine. platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true + load: true tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels labels: | From 3727238be406590579152613e2742c7328180d3c Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 17:05:58 +0100 Subject: [PATCH 14/17] Tweak labels --- .github/workflows/ci.yaml | 20 +++++++++++++++++--- .github/workflows/release.yaml | 6 ++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index be35a447b..c0ab66866 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,6 +57,14 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + # Log into docker hub if we're going to push the result + - name: Login to DockerHub + uses: docker/login-action@v1 + if: ${{ github.event_name != 'pull_request' }} + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + # Add Docker labels and tags - name: Docker meta id: docker_meta @@ -78,14 +86,20 @@ jobs: file: ./Dockerfile cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max - load: true push: ${{ github.event_name != 'pull_request' }} # Push the master branch only + load: ${{ github.event_name == 'pull_request' }} # Otherwise, just load it locally tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.vendor="OHDSI" + maintainer=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.authors=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.vendor=OHDSI + + # If the image was pushed, we need to pull it again to inspect it + - name: Pull image + if: ${{ github.event_name != 'pull_request' }} + run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} - name: Inspect image run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index acf83dc78..f8b306720 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -95,9 +95,11 @@ jobs: # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.vendor="OHDSI" + maintainer=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.authors=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.vendor=OHDSI - name: Inspect image run: | + docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} From 2aa49f0ef43f81d9bb063df1be15e63d5059f5fe Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Tue, 17 Nov 2020 17:18:00 +0100 Subject: [PATCH 15/17] Tweaks --- .github/workflows/ci.yaml | 12 ++++++++++-- .github/workflows/release.yaml | 6 ++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b8b4f0c45..ec4e74eb4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,6 +72,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 + if: ${{ github.event_name != 'pull_request' }} with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -85,12 +86,19 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max push: ${{ github.event_name != 'pull_request' }} # Push the master branch only + load: ${{ github.event_name == 'pull_request' }} # Otherwise, just load it locally tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.vendor="OHDSI" + maintainer=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.authors=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.vendor=OHDSI + + # If the image was pushed, we need to pull it again to inspect it + - name: Pull image + if: ${{ github.event_name != 'pull_request' }} + run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} - name: Inspect image run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8a7b85d65..f0fc24b9e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -94,9 +94,11 @@ jobs: # Use runtime labels from docker_meta as well as fixed labels labels: | ${{ steps.docker_meta.outputs.labels }} - org.opencontainers.image.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" - org.opencontainers.image.vendor="OHDSI" + maintainer=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.authors=Joris Borgdorff , Lee Evans - www.ltscomputingllc.com + org.opencontainers.image.vendor=OHDSI - name: Inspect image run: | + docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} From d39ec96f1891d29a391bd8c5264ee96b2d2d8758 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 18 Nov 2020 10:09:11 +0100 Subject: [PATCH 16/17] Simplify build --- .github/workflows/ci.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85a770c18..f473bac26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,19 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Set build parameters + id: build_params + run: | + if [ ${{ github.event_name == 'pull_request' }} ]; then + echo "::set-output name=push::false" + echo "::set-output name=load::true" + echo "::set-output name=platforms::linux/amd64" + else + echo "::set-output name=push::true" + echo "::set-output name=load::false" + echo "::set-output name=platforms::linux/amd64,linux/arm/v7,linux/arm64" + fi + - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -85,8 +98,9 @@ jobs: file: ./Dockerfile cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache,mode=max - push: ${{ github.event_name != 'pull_request' }} # Push the master branch only - load: ${{ github.event_name == 'pull_request' }} # Otherwise, just load it locally + platforms: ${{ steps.build_params.outputs.platforms }} + push: ${{ steps.build_params.outputs.push }} + load: ${{ steps.build_params.outputs.load }} tags: ${{ steps.docker_meta.outputs.tags }} # Use runtime labels from docker_meta as well as fixed labels labels: | @@ -97,7 +111,7 @@ jobs: # If the image was pushed, we need to pull it again to inspect it - name: Pull image - if: ${{ github.event_name != 'pull_request' }} + if: ${{ steps.build_params.outputs.push }} run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} - name: Inspect image From bdd7adcdbe6de2a53e80b90201427b1fd87b0dcc Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 18 Nov 2020 14:25:50 +0100 Subject: [PATCH 17/17] Try to fix build_params --- .github/workflows/ci.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f473bac26..8fc85495b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,13 +70,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - if: ${{ github.event_name != 'pull_request' }} - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Set build parameters id: build_params run: | @@ -90,6 +83,13 @@ jobs: echo "::set-output name=platforms::linux/amd64,linux/arm/v7,linux/arm64" fi + - name: Login to DockerHub + uses: docker/login-action@v1 + if: steps.build_params.outputs.push == 'true' + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -111,7 +111,7 @@ jobs: # If the image was pushed, we need to pull it again to inspect it - name: Pull image - if: ${{ steps.build_params.outputs.push }} + if: steps.build_params.outputs.push == 'true' run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} - name: Inspect image