From 73bd3642981b27f457efd8b84ae05cbaabec9c78 Mon Sep 17 00:00:00 2001 From: Barry d'Hoine Date: Sat, 23 Nov 2024 00:26:53 +0100 Subject: [PATCH] Add build for publish images --- .github/workflows/build.yml | 15 ++++++---- .gitignore | 2 +- Dockerfile | 15 ++++++---- README.md | 59 ++++++++++++++++++++++++++++++++++--- aem-start.sh | 6 ++-- 5 files changed, 77 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdd7f33..f60c746 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Create and publish a Docker image +name: Create and publish AEM images on: push: @@ -12,13 +12,16 @@ env: jobs: build-and-push-image: - name: Build and push image + name: Build and push AEM image runs-on: ubuntu-latest permissions: contents: read packages: write attestations: write id-token: write + strategy: + matrix: + runmode: ["author", "publish"] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -44,20 +47,20 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker + - name: Extract metadata id: meta uses: docker/metadata-action@v3 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image + - name: Build and push docker image id: push uses: docker/build-push-action@v3 with: context: . push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:${{ env.AEM_SDK_VERSION }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:${{ matrix.runmode }}-${{ env.AEM_SDK_VERSION }} platforms: linux/amd64 -# platforms: linux/amd64,linux/arm64 + # TODO: for multi platform use: linux/amd64,linux/arm64 labels: ${{ steps.meta.outputs.labels }} - name: Generate artifact attestation uses: actions/attest-build-provenance@v1 diff --git a/.gitignore b/.gitignore index fffcca8..728bcb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .idea -aem-sdk-*.zip +aem-sdk-artifacts diff --git a/Dockerfile b/Dockerfile index aca524a..1491064 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,20 +11,23 @@ RUN curl -L https://github.com/wttech/aemc/releases/download/v${AEMC_VERSION}/ae FROM azul/zulu-openjdk:11-jre-headless +ARG RUNMODE=author +ARG PORT=4502 + +ENV RUNMODE=${RUNMODE} +ENV AEM_VENDOR_JAVA_HOME_DIR=$JAVA_HOME + COPY --from=installer /usr/local/bin/aem /usr/local/bin/aem -EXPOSE 4502 +EXPOSE ${PORT} WORKDIR /opt COPY aem-start.sh /usr/local/bin/aem-start - -COPY aem-sdk-artifacts/aem-sdk-*.zip aem/home/lib/ - RUN chmod +x /usr/local/bin/aem-start -ENV AEM_VENDOR_JAVA_HOME_DIR=$JAVA_HOME +COPY aem-sdk-artifacts/aem-sdk-*.zip aem/home/lib/ -RUN aem instance -A launch && aem instance down +RUN aem instance --instance-${RUNMODE} launch && aem instance down CMD ["/usr/local/bin/aem-start"] diff --git a/README.md b/README.md index 9be3146..9d5caca 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,62 @@ # AEM SDK -Docker images with AEMaaCS SDK. +AEM author and publish docker images for AEMaaCS using the AEM SDK. -## How to use +## Pull the image -### Pull the image +The `version` should be in the original format like `2024.10.18459.20241031T210302Z-241000`. + +To pull the author image + +```shell +docker pull ghcr.io/orbinson/aem-sdk:author- +``` + +To pull the publish image + +```shell +docker pull ghcr.io/orbinson/aem-sdk:publish- +``` + +## Development + +First you need to get the artifacts from the private [aem-sdk-artifacts](https://github.com/orbinson/aem-sdk-artifacts) repository. + +```shell +git clone git@github.com:orbinson/aem-sdk-artifacts.git +git lfs pull +``` + +Or create the `aem-sdk-artifacts` directory and copy the artifacts there from your Downloads folder for example. ```shell -docker pull ghcr.io/orbinson/aem-sdk:main +mkdir aem-sdk-artifacts +mv ~/Downloads/aem-sdk-*.zip aem-sdk-artifacts/ ``` + +Afterward you can build the image, by default and author is built. + +```shell +docker build . -t aem-sdk:author +``` + +And run the image + +```shell +docker run -p 4502:4502 aem-sdk:author +``` + +To build the publish image, you need to specify the correct build arguments. + +```shell +docker build \ + --build-arg RUNMODE=publish \ + --build-arg PORT=4503 \ + . -t aem-sdk:publish +``` + +And run the image + +```shell +docker run -p 4503:4503 aem-sdk:publish +``` \ No newline at end of file diff --git a/aem-start.sh b/aem-start.sh index e545f82..a3bcacd 100644 --- a/aem-start.sh +++ b/aem-start.sh @@ -1,12 +1,12 @@ #!/usr/bin/env sh aem_stop() { - /usr/local/bin/aem instance -A stop + /usr/local/bin/aem instance --instance-${RUNMODE} stop exit 0 } trap aem_stop INT TERM -/usr/local/bin/aem instance -A start +/usr/local/bin/aem instance --instance-${RUNMODE} start -tail -F /opt/aem/home/var/instance/author/crx-quickstart/logs/error.log +tail -F /opt/aem/home/var/instance/${RUNMODE}/crx-quickstart/logs/error.log