From 601d444e4dc9733d23b5357ffb24e0227576da2a Mon Sep 17 00:00:00 2001 From: "raynato.c.pedrajeta" Date: Mon, 15 Jul 2024 13:54:52 +0800 Subject: [PATCH] feat(connector-daml): aio image Fixes #3284 Signed-off-by: raynato.c.pedrajeta --- .github/workflows/ci.yaml | 7 +++ tools/docker/daml-all-in-one/Dockerfile | 15 +++++ tools/docker/daml-all-in-one/Readme.md | 16 ++++++ .../daml-all-in-one/daml-all-in-one.yaml | 56 +++++++++++++++++++ tools/docker/daml-all-in-one/healthcheck.sh | 6 ++ 5 files changed, 100 insertions(+) create mode 100644 tools/docker/daml-all-in-one/Dockerfile create mode 100644 tools/docker/daml-all-in-one/Readme.md create mode 100644 tools/docker/daml-all-in-one/daml-all-in-one.yaml create mode 100644 tools/docker/daml-all-in-one/healthcheck.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e501c6263b..508a98ca590 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2632,6 +2632,13 @@ jobs: - name: ghcr.io/hyperledger/cactus-fabric2-all-in-one run: DOCKER_BUILDKIT=1 docker build ./tools/docker/fabric-all-in-one/ -f ./tools/docker/fabric-all-in-one/Dockerfile_v2.x + ghcr-daml-all-in-one: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.1 + - name: ghcr.io/hyperledger/daml-all-in-one + run: DOCKER_BUILDKIT=1 docker build ./tools/docker/daml-all-in-one/ -f ./tools/docker/daml-all-in-one/Dockerfile + ghcr-keychain-vault-server: runs-on: ubuntu-22.04 steps: diff --git a/tools/docker/daml-all-in-one/Dockerfile b/tools/docker/daml-all-in-one/Dockerfile new file mode 100644 index 00000000000..bd389e3a33b --- /dev/null +++ b/tools/docker/daml-all-in-one/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:22.04 + +RUN apt update +RUN apt install curl openjdk-21-jdk -y +RUN curl -sSL https://get.daml.com/ | sh +ENV PATH="/root/.daml/bin:${PATH}" +RUN daml new create-daml-app --template create-daml-app +WORKDIR /create-daml-app + +CMD ["daml", "start"] + +COPY healthcheck.sh /healthcheck.sh +RUN chmod +x /healthcheck.sh + +HEALTHCHECK --interval=30s --timeout=60s --start-period=100s --retries=100 CMD /healthcheck.sh \ No newline at end of file diff --git a/tools/docker/daml-all-in-one/Readme.md b/tools/docker/daml-all-in-one/Readme.md new file mode 100644 index 00000000000..d0a4307b8a8 --- /dev/null +++ b/tools/docker/daml-all-in-one/Readme.md @@ -0,0 +1,16 @@ +# DAML Example - Sample DAML App + +## Usage + +## Building and running the container locally + +# Run the built image with ports mapped to the host machine as you see fit +1. On the file, locate the docker-all-in-one folder via this command: `cd tools/docker/daml-all-in-one` +2. Build the docker image using this: +docker build -t daml-all-in-one . +3. Run the docker image: +docker run --privileged -p 6865:6865 -p 7575:7575 daml-all-in-one +4. Observe the logs and check for this status to confirm that DAML has successfully started: + `[http-json-ledger-api-pekko.actor.default-dispatcher-12] INFO com.daml.http.Endpoints - Responding to client with HTTP 200 OK,` +5. For healthcheck, check the query for DAML contract on docker logs: + `" % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 26 0 26 0 0 24 0 --:--:-- 0:00:01 --:--:-- 24\r100 26 0 26 0 0 24 0 --:--:-- 0:00:01 --:--:-- 24\n{\"result\":[],\"status\":200}DAML API Success!\n"` \ No newline at end of file diff --git a/tools/docker/daml-all-in-one/daml-all-in-one.yaml b/tools/docker/daml-all-in-one/daml-all-in-one.yaml new file mode 100644 index 00000000000..5d7529d661e --- /dev/null +++ b/tools/docker/daml-all-in-one/daml-all-in-one.yaml @@ -0,0 +1,56 @@ +name: quorum-all-in-one-publish + +on: + # Publish `v1.2.3` tags as releases. + push: + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + IMAGE_NAME: cactus-quorum-all-in-one + +jobs: + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + build-tag-push-container: + runs-on: ubuntu-22.04 + env: + DOCKER_BUILDKIT: 1 + DOCKERFILE_PATH: ./tools/docker/daml-all-in-one/Dockerfile + DOCKER_BUILD_DIR: ./tools/docker/daml-all-in-one/ + permissions: + packages: write + contents: read + + steps: + - uses: actions/checkout@v4.1.1 + + - name: Build image + run: docker build "$DOCKER_BUILD_DIR" --file "$DOCKERFILE_PATH" --tag "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}" + + - name: Log in to registry + # This is where you will update the PAT to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Push image + run: | + SHORTHASH=$(git rev-parse --short "$GITHUB_SHA") + TODAYS_DATE="$(date +%F)" + DOCKER_TAG="$TODAYS_DATE-$SHORTHASH" + IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME" + # Change all uppercase to lowercase + IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]') + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/*" ]] && VERSION="${VERSION//^v//}" + # Do not use the `latest` tag at all, tag with date + git short hash if there is no git tag + [ "$VERSION" == "main" ] && VERSION=$DOCKER_TAG + echo IMAGE_ID="$IMAGE_ID" + echo VERSION="$VERSION" + docker tag "$IMAGE_NAME" "$IMAGE_ID:$VERSION" + docker push "$IMAGE_ID:$VERSION" diff --git a/tools/docker/daml-all-in-one/healthcheck.sh b/tools/docker/daml-all-in-one/healthcheck.sh new file mode 100644 index 00000000000..deea402dfb3 --- /dev/null +++ b/tools/docker/daml-all-in-one/healthcheck.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# docker exec -it eb40b692a662 /bin/bash + +curl -X GET http://localhost:7575/v1/query -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJzYW5kYm94IiwiYXBwbGljYXRpb25JZCI6ImZvb2JhciIsImFjdEFzIjpbIkFsaWNlIl19fQ.1Y9BBFH5uVz1Nhfmx12G_ECJVcMncwm-XLaWM40EHbY" + +echo "DAML API Success!" \ No newline at end of file