From 1ad4479b65441d7c3c59eb8ed5959e3cc3b92302 Mon Sep 17 00:00:00 2001 From: Yannick Marcon Date: Fri, 17 May 2024 19:05:47 +0200 Subject: [PATCH] feat: github actions --- .github/workflows/docker-publish.yml | 55 +++++++++++++++++++++++++++ amber-studio/Dockerfile => Dockerfile | 0 Makefile | 35 ----------------- README.md | 38 +----------------- amber-collect/Dockerfile | 19 --------- amber-visit/Dockerfile | 19 --------- amber/Dockerfile | 23 ----------- 7 files changed, 57 insertions(+), 132 deletions(-) create mode 100644 .github/workflows/docker-publish.yml rename amber-studio/Dockerfile => Dockerfile (100%) delete mode 100644 Makefile delete mode 100644 amber-collect/Dockerfile delete mode 100644 amber-visit/Dockerfile delete mode 100644 amber/Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..432f06c --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,55 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + env: + REGISTRY: index.docker.io + IMAGE_NAME: obiba/amber-studio + permissions: + id-token: write + contents: read + attestations: write + packages: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=match,pattern=amber-studio-(\d+.\d+.\d+),group=1 + type=match,pattern=amber-studio-(\d+.\d+),group=1 + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: false + diff --git a/amber-studio/Dockerfile b/Dockerfile similarity index 100% rename from amber-studio/Dockerfile rename to Dockerfile diff --git a/Makefile b/Makefile deleted file mode 100644 index 721533e..0000000 --- a/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Docker helper -# -tag=1.2 -stag=1.2 -ctag=1.1 -vtag=1.0 -no_cache=false - -help: - @echo sudo make all tag=x.x vtag=y.y - @echo make push-all tag=x.x vtag=y.y - -all: - cd amber && docker build --no-cache=true -t="obiba/amber:$(tag)" . && docker build -t="obiba/amber:latest" . - cd amber-studio && docker build --no-cache=true -t="obiba/amber-studio:$(stag)" . && docker build -t="obiba/amber-studio:latest" . - cd amber-collect && docker build --no-cache=true -t="obiba/amber-collect:$(ctag)" . && docker build -t="obiba/amber-collect:latest" . - cd amber-visit && docker build --no-cache=true -t="obiba/amber-visit:$(vtag)" . && docker build -t="obiba/amber-visit:latest" . - -push-all: - docker image push obiba/amber:$(tag) - docker image push obiba/amber:latest - docker image push obiba/amber-studio:$(stag) - docker image push obiba/amber-studio:latest - docker image push obiba/amber-collect:$(ctag) - docker image push obiba/amber-collect:latest - docker image push obiba/amber-visit:$(vtag) - docker image push obiba/amber-visit:latest - -# Build Docker image -build: - cd $(app) && docker build --no-cache=$(no_cache) -t="obiba/$(app):$(tag)" . - -push: - docker image push obiba/$(app):$(tag) diff --git a/README.md b/README.md index fa613bf..4c950c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Docker Amber -============ +Docker Amber Studio +=================== [Docker](https://docs.docker.com/) images for Amber server and apps, see: [amber](https://github.com/obiba/amber), [amber-studio](https://github.com/obiba/amber-studio), [amber-collect](https://github.com/obiba/amber-collect) and [amber-visit](https://github.com/obiba/amber-visit). @@ -7,14 +7,6 @@ These are base images that needs to be extended up for amending and building the A template repository is provided to showcase how to extend and customize these Docker images: [amber-template](https://github.com/obiba/amber-template) -Amber server Dockerfile ------------------------ - -Amber server is a [nodejs](https://nodejs.org/) application. Most of the runtime parameters can be set using [environment variables]((https://github.com/obiba/amber/blob/main/README.md#environment-variables)). For advanced usage, the runtime settings **can** also be amended by copying a local [./config/production.json](https://github.com/obiba/amber/blob/main/config/production.json) file. - -The `Dockerfile` for a production Amber server will then look like: [Amber Server template](https://github.com/obiba/amber-template/tree/master/amber) - - Amber Studio app Dockerfile --------------------------- @@ -27,29 +19,3 @@ Optionally, some source files can be modified as well: * [src/css](https://github.com/obiba/amber-studio/tree/main/src/css) folder that contains the [SCSS](https://sass-lang.com/documentation/syntax) files. The `Dockerfile` for a production web server providing the Amber Studio app will then look like: [Amber Studio template](https://github.com/obiba/amber-template/tree/master/amber-studio) - -Amber Collect app Dockerfile ----------------------------- - -Amber Collect is a [Quasar PWA](https://quasar.dev/quasar-cli-vite/developing-pwa/introduction) (progressive web application) web app delivered by a [NGINX](https://www.nginx.com/) web server. The web app **must** be built with the site specific settings such as the Amber server URL and the [reCAPTCHA](https://developers.google.com/recaptcha/) site key. - -Optionally, some source files can be modified as well: - -* [settings.json](https://github.com/obiba/amber-collect/blob/main/settings.json) file that is a simple way of tweaking the default theme and for adding new languages. -* [public](https://github.com/obiba/amber-collect/tree/main/public) folder that contains the app icons. -* [src/css](https://github.com/obiba/amber-collect/tree/main/src/css) folder that contains the [SCSS](https://sass-lang.com/documentation/syntax) files. - -The `Dockerfile` for a production web server providing the Amber Collect app will then look like: [Amber Collect template](https://github.com/obiba/amber-template/tree/master/amber-collect) - -Amber Visit app Dockerfile ----------------------------- - -Amber Collect is a [Quasar SPA](https://quasar.dev/quasar-cli-vite/developing-spa/introduction) (single page application) web app delivered by a [NGINX](https://www.nginx.com/) web server. The web app **must** be built with the site specific settings such as the Amber server URL and the [reCAPTCHA](https://developers.google.com/recaptcha/) site key. - -Optionally, some source files can be modified as well: - -* [settings.json](https://github.com/obiba/amber-visit/blob/main/settings.json) file that is a simple way of tweaking the default theme and for adding new languages. -* [public](https://github.com/obiba/amber-visitt/tree/main/public) folder that contains the app icons. -* [src/css](https://github.com/obiba/amber-visit/tree/main/src/css) folder that contains the [SCSS](https://sass-lang.com/documentation/syntax) files. - -The `Dockerfile` for a production web server providing the Amber Visit app will then look like: [Amber Visit template](https://github.com/obiba/amber-template/tree/master/amber-visit) diff --git a/amber-collect/Dockerfile b/amber-collect/Dockerfile deleted file mode 100644 index c1f7b4f..0000000 --- a/amber-collect/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# -# Amber Collect Dockerfile -# - -# release stage -FROM node:20-alpine as release-stage - -ENV AMBER_COLLECT_VERSION 1.1.2 - -WORKDIR /app - -RUN set -x && \ - wget -q -O amber-collect.zip https://github.com/obiba/amber-collect/archive/refs/tags/${AMBER_COLLECT_VERSION}.zip && \ - unzip -q amber-collect.zip && \ - rm amber-collect.zip && \ - mv amber-collect-${AMBER_COLLECT_VERSION}/* . && \ - mv amber-collect-${AMBER_COLLECT_VERSION}/.yarn* . && \ - mv amber-collect-${AMBER_COLLECT_VERSION}/.eslint* amber-collect-${AMBER_COLLECT_VERSION}/.postcssrc.js . && \ - rm -rf amber-collect-${AMBER_COLLECT_VERSION} diff --git a/amber-visit/Dockerfile b/amber-visit/Dockerfile deleted file mode 100644 index ebe19ec..0000000 --- a/amber-visit/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# -# Amber Collect Dockerfile -# - -# release stage -FROM node:20-alpine as release-stage - -ENV AMBER_VISIT_VERSION 1.0.3 - -WORKDIR /app - -RUN set -x && \ - wget -q -O amber-visit.zip https://github.com/obiba/amber-visit/archive/refs/tags/${AMBER_VISIT_VERSION}.zip && \ - unzip -q amber-visit.zip && \ - rm amber-visit.zip && \ - mv amber-visit-${AMBER_VISIT_VERSION}/* . && \ - mv amber-visit-${AMBER_VISIT_VERSION}/.yarn* . && \ - mv amber-visit-${AMBER_VISIT_VERSION}/.eslint* . && \ - rm -rf amber-visit-${AMBER_VISIT_VERSION} diff --git a/amber/Dockerfile b/amber/Dockerfile deleted file mode 100644 index ac56b9c..0000000 --- a/amber/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# -# Amber server Dockerfile -# - -FROM node:lts-alpine - -ENV AMBER_VERSION 1.2.0 - -WORKDIR /usr/src/app - -RUN set -x && \ - wget -q -O amber.zip https://github.com/obiba/amber/archive/refs/tags/${AMBER_VERSION}.zip && \ - unzip -q amber.zip && \ - rm amber.zip && \ - mv amber-${AMBER_VERSION} amber - -WORKDIR /usr/src/app/amber - -RUN echo -n "npm: " && npm -version && npm install - -EXPOSE 3030 - -CMD ["npm", "run", "start"]