diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..87bce3af0 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,80 @@ +# 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 ] + +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 + + # 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 + 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' }} # 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.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" + org.opencontainers.image.vendor="OHDSI" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..1f33c6883 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,104 @@ +# 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 }} + + # 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: ohdsi/atlas + 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/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.authors="Joris Borgdorff , Lee Evans - www.ltscomputingllc.com" + org.opencontainers.image.vendor="OHDSI" diff --git a/Dockerfile b/Dockerfile index 42790e932..aa626ee93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/