diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..8fc85495b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,119 @@ +# Continuous integration +name: CI + +# Run in master and dev branches and in all pull requests to those branches +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + DOCKER_IMAGE: thehyve/ohdsi-atlas + +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 + + # 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 + + - 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 + + - 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 + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ${{ env.DOCKER_IMAGE }} + + # Setup docker build environment + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - 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: 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 + with: + context: ./ + file: ./Dockerfile + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + 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: | + ${{ steps.docker_meta.outputs.labels }} + 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: steps.build_params.outputs.push == 'true' + run: docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} + + - 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 new file mode 100644 index 000000000..8565cf907 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,104 @@ +# Create release files +name: Release + +on: + release: + types: [published] + +env: + DOCKER_IMAGE: thehyve/ohdsi-atlas + +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: 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 + + - 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 }} + + # 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 + + # 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: ${{ env.DOCKER_IMAGE }} + 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 + 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 + # Allow running the image on the architectures supported by nginx-unprivileged:alpine. + 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 + labels: | + ${{ steps.docker_meta.outputs.labels }} + 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 }} diff --git a/Dockerfile b/Dockerfile index 42790e932..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 @@ -28,24 +28,13 @@ 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.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.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" -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/ 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"