From 3c9c7e24eb453c2c4684b18a43c8fa5e19dd2924 Mon Sep 17 00:00:00 2001 From: Bob Hageman Date: Thu, 23 Nov 2023 15:14:23 +0100 Subject: [PATCH] Dockerize (#47) * improve: update dependency to remove stylelint deprecation warning * feat: dockerize app * feat: add workflow to publish container at ghcr * chore: add newline * chore: remove unneeded silent flag --- .dockerignore | 4 ++++ .github/workflows/delivery.yml | 43 ++++++++++++++++++++++++++++++++++ Dockerfile | 13 +++++----- docker-compose.yml | 10 ++++++++ package.json | 2 +- yarn.lock | 18 +++++++++++++- 6 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/delivery.yml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a12d12d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +build +**/.git +**/.DS_Store +**/node_modules diff --git a/.github/workflows/delivery.yml b/.github/workflows/delivery.yml new file mode 100644 index 0000000..e3db0ed --- /dev/null +++ b/.github/workflows/delivery.yml @@ -0,0 +1,43 @@ +name: Delivery + +on: + push: + branches: [ master ] + release: + # Note: a current limitation is that when a release is edited after publication, then the Docker tags are not automatically updated. + types: [ published ] + +permissions: + contents: write + packages: write + +jobs: + publish-docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{major}}.{{minor}}.{{patch}} + type=raw,value=edge + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build container and push to GitHub Container Registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 77f3b26..3ba977c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ -FROM node:16 - +FROM node:21-alpine as build WORKDIR /app +COPY . /app +RUN yarn install --immutable --immutable-cache --check-cache +RUN yarn build -COPY . . - -RUN yarn - -CMD [ "yarn", "start" ] +FROM joseluisq/static-web-server:latest +COPY --from=build /app/build /public diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ec840f6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.7' + +services: + + app: + build: + context: . + dockerfile: Dockerfile + ports: + - 3000:80 diff --git a/package.json b/package.json index 64beaa5..e04c4da 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "stylelint": "^15.10.1", "stylelint-config-recommended-scss": "^12.0.0", "stylelint-prettier": "^3.0.0", - "stylelint-scss": "^5.0.1" + "stylelint-scss": "^5.3.1" }, "scripts": { "lint": "eslint . --ext .js && stylelint ./src", diff --git a/yarn.lock b/yarn.lock index 4f8952f..2418781 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6204,6 +6204,11 @@ known-css-properties@^0.27.0: resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.27.0.tgz#82a9358dda5fe7f7bd12b5e7142c0a205393c0c5" integrity sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg== +known-css-properties@^0.29.0: + version "0.29.0" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.29.0.tgz#e8ba024fb03886f23cb882e806929f32d814158f" + integrity sha512-Ne7wqW7/9Cz54PDt4I3tcV+hAyat8ypyOGzYRJQfdxnnjeWsTxt1cy8pjvvKeI5kfXuyvULyeeAvwvvtAX3ayQ== + language-subtag-registry@~0.3.2: version "0.3.22" resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz#2e1500861b2e457eba7e7ae86877cbd08fa1fd1d" @@ -8696,7 +8701,7 @@ stylelint-prettier@^3.0.0: dependencies: prettier-linter-helpers "^1.0.0" -stylelint-scss@^5.0.0, stylelint-scss@^5.0.1: +stylelint-scss@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/stylelint-scss/-/stylelint-scss-5.0.1.tgz#b33a6580b5734eace083cfc2cc3021225e28547f" integrity sha512-n87iCRZrr2J7//I/QFsDXxFLnHKw633U4qvWZ+mOW6KDAp/HLj06H+6+f9zOuTYy+MdGdTuCSDROCpQIhw5fvQ== @@ -8706,6 +8711,17 @@ stylelint-scss@^5.0.0, stylelint-scss@^5.0.1: postcss-selector-parser "^6.0.13" postcss-value-parser "^4.2.0" +stylelint-scss@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/stylelint-scss/-/stylelint-scss-5.3.1.tgz#7f0f5f06d0a2a3c515aa71d3a8de3548045e03e1" + integrity sha512-5I9ZDIm77BZrjOccma5WyW2nJEKjXDd4Ca8Kk+oBapSO4pewSlno3n+OyimcyVJJujQZkBN2D+xuMkIamSc6hA== + dependencies: + known-css-properties "^0.29.0" + postcss-media-query-parser "^0.2.3" + postcss-resolve-nested-selector "^0.1.1" + postcss-selector-parser "^6.0.13" + postcss-value-parser "^4.2.0" + stylelint@^15.10.1: version "15.10.1" resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-15.10.1.tgz#93f189958687e330c106b010cbec0c41dcae506d"