Skip to content

Commit

Permalink
feat(connector-daml): aio image
Browse files Browse the repository at this point in the history
Fixes hyperledger-cacti#3284

Signed-off-by: raynato.c.pedrajeta <raynato.c.pedrajeta@accenture.com>
  • Loading branch information
raynatopedrajeta committed Jul 15, 2024
1 parent c7fce88 commit 601d444
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions tools/docker/daml-all-in-one/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions tools/docker/daml-all-in-one/Readme.md
Original file line number Diff line number Diff line change
@@ -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"`
56 changes: 56 additions & 0 deletions tools/docker/daml-all-in-one/daml-all-in-one.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions tools/docker/daml-all-in-one/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 601d444

Please sign in to comment.