diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e89330a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see https://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.github/workflows/dockerpush.yml b/.github/workflows/dockerpush.yml deleted file mode 100644 index fc640d7..0000000 --- a/.github/workflows/dockerpush.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Docker - -on: - push: - branches: - - master - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - demo: [community, base, onepage] - steps: - - uses: actions/checkout@v2 - - - name: Build Image ${{ matrix.demo }} - run: | - docker build ./${{ matrix.demo }}/ -t ${{matrix.demo}} diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 0000000..67e49f0 --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,49 @@ +name: Generate + +on: + pull_request: + paths: + - "source/**/*" + +concurrency: + # Cancel in-progress jobs if a new job is trigged by a commit from the same branch + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + generate: + name: Generate image files from source + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # Ref is required if auto-commit action is used in pull requests. + # https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch + ref: ${{ github.head_ref }} + # Token is required to trigger new workflow runs after auto-commit action. + # https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs + token: ${{ secrets.GH_WORKFLOW }} + + - name: Setup Deno + # https://github.com/marketplace/actions/setup-deno + uses: denoland/setup-deno@v1 + with: + deno-version: "^1" + + - name: Run generator script + run: deno task start + + - name: Auto-commit changed files + # Automatically commit files which have been changed during the workflow run and push changes back + # to remote repository. + # https://github.com/marketplace/actions/git-auto-commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "GenerRRRRR-ate image files from source!" + commit_user_name: "FriendsOfREDAXO-T" + commit_user_email: "FriendsOfREDAXO-T@users.noreply.github.com" + commit_author: "FriendsOfREDAXO-T " + file_pattern: "images/**/*" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..de8d7d4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,124 @@ +name: Publish + +on: + push: + branches: + - "main" + paths: + - "images/**/*" + # add workflow dispatch to manually publish the current images + workflow_dispatch: + +concurrency: + # Cancel in-progress jobs if a new job is trigged by a commit from the same branch + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + REGISTRY_IMAGE: friendsofredaxo/demo + +jobs: + collect: + name: Collect images from directories + runs-on: ubuntu-latest + outputs: + IMAGES: ${{ steps.images.outputs.directories }} + + steps: + - name: Checkout repository + # https://github.com/actions/checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Collect images from directories + id: images + run: | + cd images + directories=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name)') + echo $directories + echo "directories=$directories" >> $GITHUB_OUTPUT + + publish: + name: Publish + runs-on: ubuntu-latest + needs: [collect] + + strategy: + fail-fast: false + matrix: + image: ${{ fromJson(needs.collect.outputs.IMAGES) }} + + steps: + - name: Checkout repository + # https://github.com/marketplace/actions/checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Create tag list for image + # We make use of yp (https://mikefarah.gitbook.io/yq/) to create a taglist from + # the image’s `tags.yml` file, where all given tags (like `5-stable`, `5-edge`) are + # combined with all image registries (like ghcr, Docker Hub). + run: | + taglist=$(yq 'map( + ( + "${{ env.REGISTRY_IMAGE }}", + "ghcr.io/${{ env.REGISTRY_IMAGE }}" + ) + + ":" + .[]) | to_csv' ./images/${{ matrix.image }}/tags.yml) + echo "$taglist" + echo "TAGLIST=$taglist" >> $GITHUB_ENV + + - name: Set up QEMU + # https://github.com/marketplace/actions/docker-setup-qemu + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + # https://github.com/marketplace/actions/docker-setup-buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + # https://github.com/marketplace/actions/docker-login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + # https://github.com/marketplace/actions/docker-login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + # https://github.com/marketplace/actions/build-and-push-docker-images + uses: docker/build-push-action@v5 + with: + context: ./images/${{ matrix.image }} + platforms: linux/amd64,linux/arm64 + push: true + provenance: false + tags: ${{ env.TAGLIST }} + + - name: Update repo description + # https://github.com/marketplace/actions/docker-hub-description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ env.REGISTRY_IMAGE }} + short-description: ${{ github.event.repository.description }} + enable-url-completion: true + + - name: Delete untagged containers from GitHub Container Registry + # https://github.com/marketplace/actions/delete-untagged-ghcr + uses: Chizkiyahu/delete-untagged-ghcr-action@v3 + with: + token: ${{ secrets.GH_PACKAGES }} + untagged_only: true + owner_type: org + except_untagged_multiplatform: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f11cdf6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,58 @@ +name: Test + +on: + pull_request: + paths: + - "images/**/*" + +concurrency: + # Cancel in-progress jobs if a new job is trigged by a commit from the same branch + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + collect: + name: Collect images from directories + runs-on: ubuntu-latest + outputs: + IMAGES: ${{ steps.images.outputs.directories }} + + steps: + - name: Checkout repository + # https://github.com/marketplace/actions/checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Collect images from directories + id: images + run: | + cd images + directories=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name)') + echo $directories + echo "directories=$directories" >> $GITHUB_OUTPUT + + test: + name: Test + runs-on: ubuntu-latest + needs: [collect] + + strategy: + fail-fast: false + matrix: + image: ${{ fromJson(needs.collect.outputs.IMAGES) }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Build and push + # https://github.com/marketplace/actions/build-and-push-docker-images + uses: docker/build-push-action@v5 + with: + context: ./images/${{ matrix.image }} + load: true + tags: ${{ matrix.image }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 485dee6..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0bdf8e3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "deno.enable": true, + "deno.unstable": true, + "deno.importMap": "deno.json" +} diff --git a/LICENSE b/LICENSE index d385961..69c57ce 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Friends Of REDAXO +Copyright (c) 2023 Friends Of REDAXO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README-developers.md b/README-developers.md new file mode 100644 index 0000000..6c45bcc --- /dev/null +++ b/README-developers.md @@ -0,0 +1,5 @@ +# Dokumentation für Entwickelnde + +Dieses Projekt ist nahezu gleich aufgebaut wie [FriendsOfREDAXO/docker-redaxo](https://github.com/FriendsOfREDAXO/docker-redaxo). Um die Dokumentation nicht doppelt zu pflegen, gibt es an dieser Stelle nur einen Link dorthin: + +→ **[README-developers.md](https://github.com/FriendsOfREDAXO/docker-redaxo/blob/main/README-developers.md)** diff --git a/README.md b/README.md index 8bb2127..7be9d3b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,24 @@ # Docker website demo images for REDAXO -A collection of website demos made with ❤️ and REDAXO. +A collection of website demos for [REDAXO](https://github.com/redaxo/redaxo/) CMS, developed and maintained by [Friends Of REDAXO](https://github.com/FriendsOfREDAXO). ![Screenshot](https://raw.githubusercontent.com/FriendsOfREDAXO/docker-demos/assets/docker-demos_01.jpg) +Images are published both on [Docker Hub](https://hub.docker.com/r/friendsofredaxo/demo) and on [GitHub Container Registry](https://github.com/FriendsOfREDAXO/docker-demos/pkgs/container/demo), so you can choose between: + +- `friendsofredaxo/demo` +- `ghcr.io/friendsofredaxo/demo` + + ## Supported tags -* __`base`__ +* **`base`** This demo aims to primarily help beginners, and it demonstrates just _one_ way how to develop a website with REDAXO. [https://github.com/FriendsOfREDAXO/demo_base/](https://github.com/FriendsOfREDAXO/demo_base/) -* __`onepage`__ +* **`onepage`** This demo demonstrates 3 ways how to build a onepage website: with modules, with articles, with categories. _(German)_ [https://github.com/FriendsOfREDAXO/demo_onepage/](https://github.com/FriendsOfREDAXO/demo_onepage/) -* __`community`__ +* **`community`** In this demo you can see how to use the community addOn to create a website where users can register and login to protected areas. _(German)_ [https://github.com/FriendsOfREDAXO/demo_community/](https://github.com/FriendsOfREDAXO/demo_community/) @@ -29,7 +35,7 @@ A collection of website demos made with ❤️ and REDAXO. ### With [`docker-compose`](https://docs.docker.com/compose/reference/overview/) -Example for REDAXO base demo container with MySQL container: +Example for REDAXO base demo container with MariaDB container: ```yml version: '3' @@ -38,11 +44,11 @@ services: redaxo: image: friendsofredaxo/demo:base ports: - - 20080:80 + - 80:80 volumes: - redaxo:/var/www/html environment: - REDAXO_SERVER: http://localhost:20080 + REDAXO_SERVER: http://localhost REDAXO_SERVERNAME: 'My Website' REDAXO_ERROR_EMAIL: john@doe.example REDAXO_LANG: en_gb @@ -56,7 +62,7 @@ services: REDAXO_ADMIN_PASSWORD: 'PunKisNOT!dead' db: - image: mysql:8 + image: mariadb:10.11 volumes: - db:/var/lib/mysql environment: @@ -72,7 +78,7 @@ volumes: ## Recipes -🧁 See [recipes](https://github.com/FriendsOfREDAXO/docker-redaxo/tree/master/recipes) section within the REDAXO image repo for further examples! +🧁 See [recipes](https://github.com/FriendsOfREDAXO/docker-redaxo/tree/main/recipes) section for further examples! ## Need help? diff --git a/base/hooks/post_push b/base/hooks/post_push deleted file mode 100644 index 8392821..0000000 --- a/base/hooks/post_push +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - - -# What is this post_push.sh? -# It's the template for the post_push hook we use to push all image tags to Docker Hub. -# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks - - -for tag in base; do - - docker tag $IMAGE_NAME $DOCKER_REPO:$tag - docker push $DOCKER_REPO:$tag - - echo "$DOCKER_REPO:$tag" -done diff --git a/community/hooks/post_push b/community/hooks/post_push deleted file mode 100644 index 46902a0..0000000 --- a/community/hooks/post_push +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - - -# What is this post_push.sh? -# It's the template for the post_push hook we use to push all image tags to Docker Hub. -# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks - - -for tag in community; do - - docker tag $IMAGE_NAME $DOCKER_REPO:$tag - docker push $DOCKER_REPO:$tag - - echo "$DOCKER_REPO:$tag" -done diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..b4af921 --- /dev/null +++ b/deno.json @@ -0,0 +1,10 @@ +{ + "imports": { + "std/": "https://deno.land/std@0.208.0/" + }, + "tasks": { + "lint": "deno lint", + "generate-image-files": "deno run --allow-read --allow-write --allow-sys scripts/generate-image-files.ts", + "start": "deno task lint && deno task generate-image-files" + } +} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..8ecf743 --- /dev/null +++ b/deno.lock @@ -0,0 +1,134 @@ +{ + "version": "3", + "remote": { + "https://deno.land/std@0.208.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.208.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.208.0/fs/_util.ts": "fbf57dcdc9f7bc8128d60301eece608246971a7836a3bb1e78da75314f08b978", + "https://deno.land/std@0.208.0/fs/copy.ts": "ca19e4837965914471df38fbd61e16f9e8adfe89f9cffb0c83615c83ea3fc2bf", + "https://deno.land/std@0.208.0/fs/empty_dir.ts": "7fba29ef2d03f3503cd512616efc0535984cf1bbe7ca9d098e8b4d0d88910120", + "https://deno.land/std@0.208.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", + "https://deno.land/std@0.208.0/fs/ensure_file.ts": "39ac83cc283a20ec2735e956adf5de3e8a3334e0b6820547b5772f71c49ae083", + "https://deno.land/std@0.208.0/fs/ensure_link.ts": "c15e69c48556d78aae31b83e0c0ece04b7b8bc0951412f5b759aceb6fde7f0ac", + "https://deno.land/std@0.208.0/fs/ensure_symlink.ts": "b389c8568f0656d145ac7ece472afe710815cccbb2ebfd19da7978379ae143fe", + "https://deno.land/std@0.208.0/fs/eol.ts": "8565e1e076c5baced170236617150a7833668658e000205d896fc54084309ce1", + "https://deno.land/std@0.208.0/fs/exists.ts": "cb59a853d84871d87acab0e7936a4dac11282957f8e195102c5a7acb42546bb8", + "https://deno.land/std@0.208.0/fs/expand_glob.ts": "4f98c508fc9e40d6311d2f7fd88aaad05235cc506388c22dda315e095305811d", + "https://deno.land/std@0.208.0/fs/mod.ts": "bc3d0acd488cc7b42627044caf47d72019846d459279544e1934418955ba4898", + "https://deno.land/std@0.208.0/fs/move.ts": "b4f8f46730b40c32ea3c0bc8eb0fd0e8139249a698883c7b3756424cf19785c9", + "https://deno.land/std@0.208.0/fs/walk.ts": "c1e6b43f72a46e89b630140308bd51a4795d416a416b4cfb7cd4bd1e25946723", + "https://deno.land/std@0.208.0/path/_common/assert_path.ts": "061e4d093d4ba5aebceb2c4da3318bfe3289e868570e9d3a8e327d91c2958946", + "https://deno.land/std@0.208.0/path/_common/basename.ts": "0d978ff818f339cd3b1d09dc914881f4d15617432ae519c1b8fdc09ff8d3789a", + "https://deno.land/std@0.208.0/path/_common/common.ts": "9e4233b2eeb50f8b2ae10ecc2108f58583aea6fd3e8907827020282dc2b76143", + "https://deno.land/std@0.208.0/path/_common/constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.208.0/path/_common/dirname.ts": "2ba7fb4cc9fafb0f38028f434179579ce61d4d9e51296fad22b701c3d3cd7397", + "https://deno.land/std@0.208.0/path/_common/format.ts": "11aa62e316dfbf22c126917f5e03ea5fe2ee707386555a8f513d27ad5756cf96", + "https://deno.land/std@0.208.0/path/_common/from_file_url.ts": "ef1bf3197d2efbf0297a2bdbf3a61d804b18f2bcce45548ae112313ec5be3c22", + "https://deno.land/std@0.208.0/path/_common/glob_to_reg_exp.ts": "5c3c2b79fc2294ec803d102bd9855c451c150021f452046312819fbb6d4dc156", + "https://deno.land/std@0.208.0/path/_common/normalize.ts": "2ba7fb4cc9fafb0f38028f434179579ce61d4d9e51296fad22b701c3d3cd7397", + "https://deno.land/std@0.208.0/path/_common/normalize_string.ts": "88c472f28ae49525f9fe82de8c8816d93442d46a30d6bb5063b07ff8a89ff589", + "https://deno.land/std@0.208.0/path/_common/relative.ts": "1af19d787a2a84b8c534cc487424fe101f614982ae4851382c978ab2216186b4", + "https://deno.land/std@0.208.0/path/_common/strip_trailing_separators.ts": "7ffc7c287e97bdeeee31b155828686967f222cd73f9e5780bfe7dfb1b58c6c65", + "https://deno.land/std@0.208.0/path/_common/to_file_url.ts": "a8cdd1633bc9175b7eebd3613266d7c0b6ae0fb0cff24120b6092ac31662f9ae", + "https://deno.land/std@0.208.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", + "https://deno.land/std@0.208.0/path/_os.ts": "30b0c2875f360c9296dbe6b7f2d528f0f9c741cecad2e97f803f5219e91b40a2", + "https://deno.land/std@0.208.0/path/basename.ts": "04bb5ef3e86bba8a35603b8f3b69537112cdd19ce64b77f2522006da2977a5f3", + "https://deno.land/std@0.208.0/path/common.ts": "f4d061c7d0b95a65c2a1a52439edec393e906b40f1caf4604c389fae7caa80f5", + "https://deno.land/std@0.208.0/path/dirname.ts": "88a0a71c21debafc4da7a4cd44fd32e899462df458fbca152390887d41c40361", + "https://deno.land/std@0.208.0/path/extname.ts": "2da4e2490f3b48b7121d19fb4c91681a5e11bd6bd99df4f6f47d7a71bb6ecdf2", + "https://deno.land/std@0.208.0/path/format.ts": "3457530cc85d1b4bab175f9ae73998b34fd456c830d01883169af0681b8894fb", + "https://deno.land/std@0.208.0/path/from_file_url.ts": "e7fa233ea1dff9641e8d566153a24d95010110185a6f418dd2e32320926043f8", + "https://deno.land/std@0.208.0/path/glob.ts": "a00a81a55c02bbe074ab21a50b6495c6f7795f54cd718c824adaa92c6c9b7419", + "https://deno.land/std@0.208.0/path/glob_to_regexp.ts": "74d7448c471e293d03f05ccb968df4365fed6aaa508506b6325a8efdc01d8271", + "https://deno.land/std@0.208.0/path/is_absolute.ts": "67232b41b860571c5b7537f4954c88d86ae2ba45e883ee37d3dec27b74909d13", + "https://deno.land/std@0.208.0/path/is_glob.ts": "567dce5c6656bdedfc6b3ee6c0833e1e4db2b8dff6e62148e94a917f289c06ad", + "https://deno.land/std@0.208.0/path/join.ts": "98d3d76c819af4a11a81d5ba2dbb319f1ce9d63fc2b615597d4bcfddd4a89a09", + "https://deno.land/std@0.208.0/path/join_globs.ts": "9b84d5103b63d3dbed4b2cf8b12477b2ad415c7d343f1488505162dc0e5f4db8", + "https://deno.land/std@0.208.0/path/mod.ts": "3defabebc98279e62b392fee7a6937adc932a8f4dcd2471441e36c15b97b00e0", + "https://deno.land/std@0.208.0/path/normalize.ts": "aa95be9a92c7bd4f9dc0ba51e942a1973e2b93d266cd74f5ca751c136d520b66", + "https://deno.land/std@0.208.0/path/normalize_glob.ts": "674baa82e1c00b6cb153bbca36e06f8e0337cb8062db6d905ab5de16076ca46b", + "https://deno.land/std@0.208.0/path/parse.ts": "d87ff0deef3fb495bc0d862278ff96da5a06acf0625ca27769fc52ac0d3d6ece", + "https://deno.land/std@0.208.0/path/posix/_util.ts": "ecf49560fedd7dd376c6156cc5565cad97c1abe9824f4417adebc7acc36c93e5", + "https://deno.land/std@0.208.0/path/posix/basename.ts": "a630aeb8fd8e27356b1823b9dedd505e30085015407caa3396332752f6b8406a", + "https://deno.land/std@0.208.0/path/posix/common.ts": "e781d395dc76f6282e3f7dd8de13194abb8b04a82d109593141abc6e95755c8b", + "https://deno.land/std@0.208.0/path/posix/dirname.ts": "f48c9c42cc670803b505478b7ef162c7cfa9d8e751b59d278b2ec59470531472", + "https://deno.land/std@0.208.0/path/posix/extname.ts": "ee7f6571a9c0a37f9218fbf510c440d1685a7c13082c348d701396cc795e0be0", + "https://deno.land/std@0.208.0/path/posix/format.ts": "b94876f77e61bfe1f147d5ccb46a920636cd3cef8be43df330f0052b03875968", + "https://deno.land/std@0.208.0/path/posix/from_file_url.ts": "b97287a83e6407ac27bdf3ab621db3fccbf1c27df0a1b1f20e1e1b5acf38a379", + "https://deno.land/std@0.208.0/path/posix/glob_to_regexp.ts": "6ed00c71fbfe0ccc35977c35444f94e82200b721905a60bd1278b1b768d68b1a", + "https://deno.land/std@0.208.0/path/posix/is_absolute.ts": "159900a3422d11069d48395568217eb7fc105ceda2683d03d9b7c0f0769e01b8", + "https://deno.land/std@0.208.0/path/posix/is_glob.ts": "ec4fbc604b9db8487f7b56ab0e759b24a971ab6a45f7b0b698bc39b8b9f9680f", + "https://deno.land/std@0.208.0/path/posix/join.ts": "0c0d84bdc344876930126640011ec1b888e6facf74153ffad9ef26813aa2a076", + "https://deno.land/std@0.208.0/path/posix/join_globs.ts": "f4838d54b1f60a34a40625a3293f6e583135348be1b2974341ac04743cb26121", + "https://deno.land/std@0.208.0/path/posix/mod.ts": "f1b08a7f64294b7de87fc37190d63b6ce5b02889af9290c9703afe01951360ae", + "https://deno.land/std@0.208.0/path/posix/normalize.ts": "11de90a94ab7148cc46e5a288f7d732aade1d616bc8c862f5560fa18ff987b4b", + "https://deno.land/std@0.208.0/path/posix/normalize_glob.ts": "10a1840c628ebbab679254d5fa1c20e59106102354fb648a1765aed72eb9f3f9", + "https://deno.land/std@0.208.0/path/posix/parse.ts": "199208f373dd93a792e9c585352bfc73a6293411bed6da6d3bc4f4ef90b04c8e", + "https://deno.land/std@0.208.0/path/posix/relative.ts": "e2f230608b0f083e6deaa06e063943e5accb3320c28aef8d87528fbb7fe6504c", + "https://deno.land/std@0.208.0/path/posix/resolve.ts": "51579d83159d5c719518c9ae50812a63959bbcb7561d79acbdb2c3682236e285", + "https://deno.land/std@0.208.0/path/posix/separator.ts": "0b6573b5f3269a3164d8edc9cefc33a02dd51003731c561008c8bb60220ebac1", + "https://deno.land/std@0.208.0/path/posix/to_file_url.ts": "08d43ea839ee75e9b8b1538376cfe95911070a655cd312bc9a00f88ef14967b6", + "https://deno.land/std@0.208.0/path/posix/to_namespaced_path.ts": "c9228a0e74fd37e76622cd7b142b8416663a9b87db643302fa0926b5a5c83bdc", + "https://deno.land/std@0.208.0/path/relative.ts": "23d45ede8b7ac464a8299663a43488aad6b561414e7cbbe4790775590db6349c", + "https://deno.land/std@0.208.0/path/resolve.ts": "5b184efc87155a0af9fa305ff68a109e28de9aee81fc3e77cd01380f19daf867", + "https://deno.land/std@0.208.0/path/separator.ts": "40a3e9a4ad10bef23bc2cd6c610291b6c502a06237c2c4cd034a15ca78dedc1f", + "https://deno.land/std@0.208.0/path/to_file_url.ts": "edaafa089e0bce386e1b2d47afe7c72e379ff93b28a5829a5885e4b6c626d864", + "https://deno.land/std@0.208.0/path/to_namespaced_path.ts": "cf8734848aac3c7527d1689d2adf82132b1618eff3cc523a775068847416b22a", + "https://deno.land/std@0.208.0/path/windows/_util.ts": "f32b9444554c8863b9b4814025c700492a2b57ff2369d015360970a1b1099d54", + "https://deno.land/std@0.208.0/path/windows/basename.ts": "8a9dbf7353d50afbc5b221af36c02a72c2d1b2b5b9f7c65bf6a5a2a0baf88ad3", + "https://deno.land/std@0.208.0/path/windows/common.ts": "e781d395dc76f6282e3f7dd8de13194abb8b04a82d109593141abc6e95755c8b", + "https://deno.land/std@0.208.0/path/windows/dirname.ts": "5c2aa541384bf0bd9aca821275d2a8690e8238fa846198ef5c7515ce31a01a94", + "https://deno.land/std@0.208.0/path/windows/extname.ts": "07f4fa1b40d06a827446b3e3bcc8d619c5546b079b8ed0c77040bbef716c7614", + "https://deno.land/std@0.208.0/path/windows/format.ts": "343019130d78f172a5c49fdc7e64686a7faf41553268961e7b6c92a6d6548edf", + "https://deno.land/std@0.208.0/path/windows/from_file_url.ts": "d53335c12b0725893d768be3ac6bf0112cc5b639d2deb0171b35988493b46199", + "https://deno.land/std@0.208.0/path/windows/glob_to_regexp.ts": "290755e18ec6c1a4f4d711c3390537358e8e3179581e66261a0cf348b1a13395", + "https://deno.land/std@0.208.0/path/windows/is_absolute.ts": "245b56b5f355ede8664bd7f080c910a97e2169972d23075554ae14d73722c53c", + "https://deno.land/std@0.208.0/path/windows/is_glob.ts": "ec4fbc604b9db8487f7b56ab0e759b24a971ab6a45f7b0b698bc39b8b9f9680f", + "https://deno.land/std@0.208.0/path/windows/join.ts": "e6600bf88edeeef4e2276e155b8de1d5dec0435fd526ba2dc4d37986b2882f16", + "https://deno.land/std@0.208.0/path/windows/join_globs.ts": "f4838d54b1f60a34a40625a3293f6e583135348be1b2974341ac04743cb26121", + "https://deno.land/std@0.208.0/path/windows/mod.ts": "d7040f461465c2c21c1c68fc988ef0bdddd499912138cde3abf6ad60c7fb3814", + "https://deno.land/std@0.208.0/path/windows/normalize.ts": "9deebbf40c81ef540b7b945d4ccd7a6a2c5a5992f791e6d3377043031e164e69", + "https://deno.land/std@0.208.0/path/windows/normalize_glob.ts": "344ff5ed45430495b9a3d695567291e50e00b1b3b04ea56712a2acf07ab5c128", + "https://deno.land/std@0.208.0/path/windows/parse.ts": "120faf778fe1f22056f33ded069b68e12447668fcfa19540c0129561428d3ae5", + "https://deno.land/std@0.208.0/path/windows/relative.ts": "026855cd2c36c8f28f1df3c6fbd8f2449a2aa21f48797a74700c5d872b86d649", + "https://deno.land/std@0.208.0/path/windows/resolve.ts": "5ff441ab18a2346abadf778121128ee71bda4d0898513d4639a6ca04edca366b", + "https://deno.land/std@0.208.0/path/windows/separator.ts": "ae21f27015f10510ed1ac4a0ba9c4c9c967cbdd9d9e776a3e4967553c397bd5d", + "https://deno.land/std@0.208.0/path/windows/to_file_url.ts": "8e9ea9e1ff364aa06fa72999204229952d0a279dbb876b7b838b2b2fea55cce3", + "https://deno.land/std@0.208.0/path/windows/to_namespaced_path.ts": "e0f4d4a5e77f28a5708c1a33ff24360f35637ba6d8f103d19661255ef7bfd50d", + "https://deno.land/std@0.208.0/yaml/_dumper/dumper.ts": "717403d0e700de783f2ef5c906b3d7245383e1509fc050e7ff5d4a53a03dbf40", + "https://deno.land/std@0.208.0/yaml/_dumper/dumper_state.ts": "f0d0673ceea288334061ca34b63954c2bb5feb5bf6de5e4cfe9a942cdf6e5efe", + "https://deno.land/std@0.208.0/yaml/_error.ts": "b59e2c76ce5a47b1b9fa0ff9f96c1dd92ea1e1b17ce4347ece5944a95c3c1a84", + "https://deno.land/std@0.208.0/yaml/_loader/loader.ts": "63ec7f0a265dbbabc54b25a4beefff7650e205160a2d75c7d8f8363b5f84851a", + "https://deno.land/std@0.208.0/yaml/_loader/loader_state.ts": "0841870b467169269d7c2dfa75cd288c319bc06f65edd9e42c29e5fced91c7a4", + "https://deno.land/std@0.208.0/yaml/_mark.ts": "dcd8585dee585e024475e9f3fe27d29740670fb64ebb970388094cad0fc11d5d", + "https://deno.land/std@0.208.0/yaml/_state.ts": "ef03d55ec235d48dcfbecc0ab3ade90bfae69a61094846e08003421c2cf5cfc6", + "https://deno.land/std@0.208.0/yaml/_type/binary.ts": "24d49614463a7339a8a16d894919c2ec18a10588ae360ec352093b60e2cc8b0d", + "https://deno.land/std@0.208.0/yaml/_type/bool.ts": "5bfa75da84343d45347b521ba4e5aeace9fe6f53447405290d53315a3fc20e66", + "https://deno.land/std@0.208.0/yaml/_type/float.ts": "056bd3cb9c5586238b20517511014fb24b0e36f98f9f6073e12da308b6b9808a", + "https://deno.land/std@0.208.0/yaml/_type/function.ts": "ff574fe84a750695302864e1c31b93f12d14ada4bde79a5f93197fc33ad17471", + "https://deno.land/std@0.208.0/yaml/_type/int.ts": "563ad074f0fa7aecf6b6c3d84135bcc95a8269dcc15de878de20ce868fd773fa", + "https://deno.land/std@0.208.0/yaml/_type/map.ts": "7b105e4ab03a361c61e7e335a0baf4d40f06460b13920e5af3fb2783a1464000", + "https://deno.land/std@0.208.0/yaml/_type/merge.ts": "8192bf3e4d637f32567917f48bb276043da9cf729cf594e5ec191f7cd229337e", + "https://deno.land/std@0.208.0/yaml/_type/mod.ts": "060e2b3d38725094b77ea3a3f05fc7e671fced8e67ca18e525be98c4aa8f4bbb", + "https://deno.land/std@0.208.0/yaml/_type/nil.ts": "606e8f0c44d73117c81abec822f89ef81e40f712258c74f186baa1af659b8887", + "https://deno.land/std@0.208.0/yaml/_type/omap.ts": "cfe59a294726f5cea705c39a61fd2b08199cf48f4ccd6b040cb550ec0f38d0a1", + "https://deno.land/std@0.208.0/yaml/_type/pairs.ts": "0032fdfe57558d21696a4f8cf5b5cfd1f698743177080affc18629685c905666", + "https://deno.land/std@0.208.0/yaml/_type/regexp.ts": "1ce118de15b2da43b4bd8e4395f42d448b731acf3bdaf7c888f40789f9a95f8b", + "https://deno.land/std@0.208.0/yaml/_type/seq.ts": "95333abeec8a7e4d967b8c8328b269e342a4bbdd2585395549b9c4f58c8533a2", + "https://deno.land/std@0.208.0/yaml/_type/set.ts": "f28ba44e632ef2a6eb580486fd47a460445eeddbdf1dbc739c3e62486f566092", + "https://deno.land/std@0.208.0/yaml/_type/str.ts": "a67a3c6e429d95041399e964015511779b1130ea5889fa257c48457bd3446e31", + "https://deno.land/std@0.208.0/yaml/_type/timestamp.ts": "706ea80a76a73e48efaeb400ace087da1f927647b53ad6f754f4e06d51af087f", + "https://deno.land/std@0.208.0/yaml/_type/undefined.ts": "94a316ca450597ccbc6750cbd79097ad0d5f3a019797eed3c841a040c29540ba", + "https://deno.land/std@0.208.0/yaml/_utils.ts": "26b311f0d42a7ce025060bd6320a68b50e52fd24a839581eb31734cd48e20393", + "https://deno.land/std@0.208.0/yaml/mod.ts": "28ecda6652f3e7a7735ee29c247bfbd32a2e2fc5724068e9fd173ec4e59f66f7", + "https://deno.land/std@0.208.0/yaml/parse.ts": "1fbbda572bf3fff578b6482c0d8b85097a38de3176bf3ab2ca70c25fb0c960ef", + "https://deno.land/std@0.208.0/yaml/schema.ts": "96908b78dc50c340074b93fc1598d5e7e2fe59103f89ff81e5a49b2dedf77a67", + "https://deno.land/std@0.208.0/yaml/schema/core.ts": "fa406f18ceedc87a50e28bb90ec7a4c09eebb337f94ef17468349794fa828639", + "https://deno.land/std@0.208.0/yaml/schema/default.ts": "0047e80ae8a4a93293bc4c557ae8a546aabd46bb7165b9d9b940d57b4d88bde9", + "https://deno.land/std@0.208.0/yaml/schema/extended.ts": "0784416bf062d20a1626b53c03380e265b3e39b9409afb9f4cb7d659fd71e60d", + "https://deno.land/std@0.208.0/yaml/schema/failsafe.ts": "d219ab5febc43f770917d8ec37735a4b1ad671149846cbdcade767832b42b92b", + "https://deno.land/std@0.208.0/yaml/schema/json.ts": "5f41dd7c2f1ad545ef6238633ce9ee3d444dfc5a18101e1768bd5504bf90e5e5", + "https://deno.land/std@0.208.0/yaml/schema/mod.ts": "4472e827bab5025e92bc2eb2eeefa70ecbefc64b2799b765c69af84822efef32", + "https://deno.land/std@0.208.0/yaml/stringify.ts": "fffc09c65c68d3d63f8159e8cbaa3f489bc20a8e55b4fbb61a8c2e9f914d1d02", + "https://deno.land/std@0.208.0/yaml/type.ts": "65553da3da3c029b6589c6e4903f0afbea6768be8fca61580711457151f2b30f" + } +} diff --git a/base/Dockerfile b/images/base/Dockerfile similarity index 100% rename from base/Dockerfile rename to images/base/Dockerfile diff --git a/base/custom-setup.sh b/images/base/custom-setup.sh old mode 100755 new mode 100644 similarity index 100% rename from base/custom-setup.sh rename to images/base/custom-setup.sh diff --git a/images/base/tags.yml b/images/base/tags.yml new file mode 100644 index 0000000..1ab5191 --- /dev/null +++ b/images/base/tags.yml @@ -0,0 +1,2 @@ +tags: + - base diff --git a/community/Dockerfile b/images/community/Dockerfile similarity index 100% rename from community/Dockerfile rename to images/community/Dockerfile diff --git a/community/custom-setup.sh b/images/community/custom-setup.sh old mode 100755 new mode 100644 similarity index 100% rename from community/custom-setup.sh rename to images/community/custom-setup.sh diff --git a/images/community/tags.yml b/images/community/tags.yml new file mode 100644 index 0000000..bd014f1 --- /dev/null +++ b/images/community/tags.yml @@ -0,0 +1,2 @@ +tags: + - community diff --git a/onepage/Dockerfile b/images/onepage/Dockerfile similarity index 100% rename from onepage/Dockerfile rename to images/onepage/Dockerfile diff --git a/onepage/custom-setup.sh b/images/onepage/custom-setup.sh old mode 100755 new mode 100644 similarity index 100% rename from onepage/custom-setup.sh rename to images/onepage/custom-setup.sh diff --git a/images/onepage/tags.yml b/images/onepage/tags.yml new file mode 100644 index 0000000..a019b81 --- /dev/null +++ b/images/onepage/tags.yml @@ -0,0 +1,2 @@ +tags: + - onepage diff --git a/onepage/hooks/post_push b/onepage/hooks/post_push deleted file mode 100644 index 93bbc90..0000000 --- a/onepage/hooks/post_push +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - - -# What is this post_push.sh? -# It's the template for the post_push hook we use to push all image tags to Docker Hub. -# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks - - -for tag in onepage; do - - docker tag $IMAGE_NAME $DOCKER_REPO:$tag - docker push $DOCKER_REPO:$tag - - echo "$DOCKER_REPO:$tag" -done diff --git a/scripts/generate-image-files.ts b/scripts/generate-image-files.ts new file mode 100644 index 0000000..90e9d28 --- /dev/null +++ b/scripts/generate-image-files.ts @@ -0,0 +1,70 @@ +import { isArray, isObject } from "std/yaml/_utils.ts"; +import { parse, stringify } from "std/yaml/mod.ts"; +import { emptyDirSync, ensureDirSync, copySync } from "std/fs/mod.ts"; + +const sourceDirectory = 'source'; +const imagesDirectory = 'images'; + +/** + * Prepare image configuration + */ +const imageConfiguration = parse(Deno.readTextFileSync(`${sourceDirectory}/images.yml`)); + +if (!isObject(imageConfiguration)) { + console.error("Invalid image configuration!"); + Deno.exit(1); +} + +const images = imageConfiguration["images"]; + +if (!isArray(images)) { + console.error("Invalid images array!"); + Deno.exit(1); +} + +/** + * Clear images directory + * Hint: we want all images to be removed that are no longer contained in the image configuration + */ +emptyDirSync(imagesDirectory); + +/** + * Generate images + */ +const customSetupFileSource = Deno.readTextFileSync(`${sourceDirectory}/custom-setup.sh`); + +for (const image of images) { + + const targetDir = `${imagesDirectory}/${image["name"]}`; + ensureDirSync(targetDir); + + /** + * Generate custom-setup.sh + */ + const replacements: Record = { + '%%PACKAGE_NAME%%': `${image["package-name"]}`, + '%%PACKAGE_VERSION%%': `${image["package-version"]}`, + }; + let currentCustomSetupFileSource = customSetupFileSource; + Object.keys(replacements).forEach((key) => { + currentCustomSetupFileSource = currentCustomSetupFileSource.replaceAll(key, replacements[key]); + }); + + Deno.writeTextFileSync(`${targetDir}/custom-setup.sh`, currentCustomSetupFileSource); + + /** + * Copy static files that do not require replacements + */ + const filesToCopy = [ + `Dockerfile`, + ]; + filesToCopy.forEach(file => { + copySync(`${sourceDirectory}/${file}`, `${targetDir}/${file}`); + }) + + /** + * Generate tag list + */ + const tagList = stringify({ tags: image["tags"] }); + Deno.writeTextFileSync(`${targetDir}/tags.yml`, tagList); +} diff --git a/templates/Dockerfile b/source/Dockerfile similarity index 100% rename from templates/Dockerfile rename to source/Dockerfile diff --git a/source/custom-setup.sh b/source/custom-setup.sh new file mode 100644 index 0000000..09fb613 --- /dev/null +++ b/source/custom-setup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail + +cd /var/www/html + +php redaxo/bin/console install:download -q %%PACKAGE_NAME%% %%PACKAGE_VERSION%% +php redaxo/bin/console package:install -q %%PACKAGE_NAME%% +php redaxo/bin/console cache:clear -q +php redaxo/bin/console %%PACKAGE_NAME%%:install -q -y + +chown -R www-data:www-data ./ diff --git a/source/images.yml b/source/images.yml new file mode 100644 index 0000000..7c9f97c --- /dev/null +++ b/source/images.yml @@ -0,0 +1,13 @@ +images: + - name: "base" + tags: ["base"] + package-name: "demo_base" + package-version: "3.0.1" + - name: "community" + tags: ["community"] + package-name: "demo_community" + package-version: "4.0.2" + - name: "onepage" + tags: ["onepage"] + package-name: "demo_onepage" + package-version: "1.7.2" diff --git a/templates/custom-setup.sh b/templates/custom-setup.sh deleted file mode 100644 index f9b9302..0000000 --- a/templates/custom-setup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -euo pipefail - -cd /var/www/html - -php redaxo/bin/console install:download -q %%PACKAGE%% %%VERSION%% -php redaxo/bin/console package:install -q %%PACKAGE%% -php redaxo/bin/console cache:clear -q -php redaxo/bin/console %%PACKAGE%%:install -q -y - -chown -R www-data:www-data ./ diff --git a/templates/post_push.sh b/templates/post_push.sh deleted file mode 100644 index 24176ec..0000000 --- a/templates/post_push.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - - -# What is this post_push.sh? -# It's the template for the post_push hook we use to push all image tags to Docker Hub. -# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks - - -for tag in %%TAGS%%; do - - docker tag $IMAGE_NAME $DOCKER_REPO:$tag - docker push $DOCKER_REPO:$tag - - echo "$DOCKER_REPO:$tag" -done diff --git a/update.sh b/update.sh deleted file mode 100755 index 4d28a4a..0000000 --- a/update.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/zsh -set -euo pipefail - - -# What is this update.sh? -# It's a helper script you run whenever you've updated the demo versions or modified the Docker setup. -# It generates all the Dockerfiles from templates and the post_push hooks containing image tags. -# Once you commit and push the changes, Docker Hub will trigger automated builds of new images. - -# Usage: -# `./update.sh` -# As you can see in line 1, the script runs in zsh. This is the default shell in Mac OS since Catalina. -# You could run it in a bash shell as well (`#!/bin/bash`), but it requires at least bash 4.x to deal -# with associative arrays (hash tables). Check your version with `bash --version`. - - -# configuration --------------------------------------------------------------- - -# declare commands and image bases for given variants -variants=( base community onepage ) - -# declare package versions -declare -A packageVersions=( - [base]='3.0.1' - [community]='4.0.2' - [onepage]='1.7.2' -) - -# ----------------------------------------------------------------------------- - -# loop through image variants -for variant in "${variants[@]}"; do - - # declare and make directory for given PHP version and image variant - dir="$variant" - mkdir -p "$dir" - - # declare tags for current version and variant - tags=( "${variant}" ) - - packageName="demo_${variant}" - packageVersion="${packageVersions[$variant]}" - - # bring out debug infos - echo "- Image: $variant - $packageName@$packageVersion" - echo " Tags:" - printf " - %s\n" ${tags} - - # copy hook from template, replace placeholders - mkdir -p "$dir/hooks" - sed -r \ - -e 's!%%TAGS%%!'"$tags"'!g' \ - "templates/post_push.sh" > "$dir/hooks/post_push" - - # copy custom-setup file, replace placeholders - sed -r \ - -e 's!%%PACKAGE%%!'"$packageName"'!g' \ - -e 's!%%VERSION%%!'"$packageVersion"'!g' \ - "templates/custom-setup.sh" > "$dir/custom-setup.sh" - chmod +x "$dir/custom-setup.sh" - - # copy remaining files - cp "templates/Dockerfile" "$dir/Dockerfile" -done \ No newline at end of file