Skip to content

Commit 141ee24

Browse files
raynatopedrajetapetermetz
authored andcommitted
feat(connector-daml): aio image
Primary Changes --------------- 1. Create a docker image on daml-all-in-one folder that contains an initial creation of DAML smart contracts Fixes #3284 Signed-off-by: raynato.c.pedrajeta <[email protected]>
1 parent 0e368de commit 141ee24

File tree

7 files changed

+173
-0
lines changed

7 files changed

+173
-0
lines changed

.github/workflows/ci.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,13 @@ jobs:
25992599
- name: ghcr.io/hyperledger/cactus-fabric2-all-in-one
26002600
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/fabric-all-in-one/ -f ./tools/docker/fabric-all-in-one/Dockerfile_v2.x
26012601

2602+
ghcr-daml-all-in-one:
2603+
runs-on: ubuntu-22.04
2604+
steps:
2605+
- uses: actions/[email protected]
2606+
- name: ghcr.io/hyperledger/daml-all-in-one
2607+
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/daml-all-in-one/ -f ./tools/docker/daml-all-in-one/Dockerfile
2608+
26022609
ghcr-keychain-vault-server:
26032610
runs-on: ubuntu-22.04
26042611
steps:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: daml-all-in-one-publish
2+
3+
on:
4+
# Publish `v1.2.3` tags as releases.
5+
push:
6+
tags:
7+
- v*
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
IMAGE_NAME: cacti-daml-all-in-one
15+
16+
jobs:
17+
# Push image to GitHub Packages.
18+
# See also https://docs.docker.com/docker-hub/builds/
19+
build-tag-push-container:
20+
runs-on: ubuntu-22.04
21+
env:
22+
DOCKER_BUILDKIT: 1
23+
DOCKERFILE_PATH: ./tools/docker/daml-all-in-one/Dockerfile
24+
DOCKER_BUILD_DIR: ./tools/docker/daml-all-in-one/
25+
permissions:
26+
packages: write
27+
contents: read
28+
29+
steps:
30+
- uses: actions/[email protected]
31+
32+
- name: Build image
33+
run: docker build "$DOCKER_BUILD_DIR" --file "$DOCKERFILE_PATH" --tag "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}"
34+
35+
- name: Log in to registry
36+
# This is where you will update the PAT to GITHUB_TOKEN
37+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
38+
39+
- name: Push image
40+
run: |
41+
SHORTHASH=$(git rev-parse --short "$GITHUB_SHA")
42+
TODAYS_DATE="$(date +%F)"
43+
DOCKER_TAG="$TODAYS_DATE-$SHORTHASH"
44+
IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME"
45+
# Change all uppercase to lowercase
46+
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]')
47+
# Strip git ref prefix from version
48+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
49+
# Strip "v" prefix from tag name
50+
[[ "${{ github.ref }}" == "refs/tags/*" ]] && VERSION="${VERSION//^v//}"
51+
# Do not use the `latest` tag at all, tag with date + git short hash if there is no git tag
52+
[ "$VERSION" == "main" ] && VERSION=$DOCKER_TAG
53+
echo IMAGE_ID="$IMAGE_ID"
54+
echo VERSION="$VERSION"
55+
docker tag "$IMAGE_NAME" "$IMAGE_ID:$VERSION"
56+
docker push "$IMAGE_ID:$VERSION"
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt update
4+
RUN apt install curl openjdk-21-jdk -y
5+
6+
# Download and install DAML SDK 2.9.3
7+
RUN curl -L https://github.com/digital-asset/daml/releases/download/v2.9.3/daml-sdk-2.9.3-linux.tar.gz | tar -xz -C /opt && \
8+
cd /opt/sdk-2.9.3 && \
9+
./install.sh
10+
11+
ENV PATH="/root/.daml/bin:${PATH}"
12+
RUN apt-get install xxd
13+
RUN daml new quickstart --template quickstart-java
14+
WORKDIR /quickstart
15+
16+
# Create the config file for daml json-api
17+
RUN echo '{"server": {"address": "0.0.0.0","port": 7575},"ledger-api": {"address": "0.0.0.0","port": 6865}}' > json-api-app.conf
18+
19+
# Run the auto generation of Authorization Bearer Token
20+
RUN apt-get update && apt-get install -y openssl
21+
COPY generate-jwt-token.sh /quickstart/generate-jwt-token.sh
22+
RUN chmod +x /quickstart/generate-jwt-token.sh
23+
RUN /quickstart/generate-jwt-token.sh
24+
25+
RUN apt-get update && apt-get install -y supervisor
26+
RUN mkdir -p /var/log/supervisor
27+
COPY supervisord.conf /etc/supervisord.conf
28+
29+
EXPOSE 9001
30+
31+
ENTRYPOINT ["/usr/bin/supervisord"]
32+
CMD ["--configuration","/etc/supervisord.conf", "--nodaemon"]
33+
34+
COPY healthcheck.sh /quickstart/healthcheck.sh
35+
RUN chmod +x /quickstart/healthcheck.sh
36+
37+
HEALTHCHECK --interval=30s --timeout=60s --start-period=100s --retries=100 CMD /quickstart/healthcheck.sh
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# DAML All in One Image
2+
3+
An all in one DAML docker image with the `sample ledger contracts`.
4+
- This docker image is for `testing` and `development` only.
5+
- **Do NOT use in production!**
6+
7+
## Build an image locally
8+
9+
To build the daml-all-in-one image locally, use:
10+
```sh
11+
docker build ./tools/docker/daml-all-in-one/ -t daml-all-in-one
12+
```
13+
14+
## Running daml-all-in-one container
15+
16+
```sh
17+
docker run --privileged -p 6865:6865 -p 7575:7575 daml-all-in-one
18+
```
19+
20+
The following ports are open on the container:
21+
22+
```yaml
23+
- 6865:6865 # DAML Navigator
24+
- 7575:7575 # DAML API entrypoint
25+
26+
```
27+
## Logs of DAML via supervisord web UI:
28+
29+
Navigate your browser to http://localhost:9001
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
#This will generate the Auth Bearer Token identical on how will it be generated at https://jwt.io/
4+
header=$(echo -n '{"alg":"HS256","typ":"JWT"}' | base64 | sed s/\+/-/g | sed 's/\//_/g' | sed -E s/=+$//)
5+
payload=$(echo -n '{"https://daml.com/ledger-api": {"ledgerId": "sandbox", "applicationId": "foobar","actAs":["Alice"]}}' | openssl base64 -e -A | sed s/\+/-/ | sed -E s/=+$//)
6+
hmac_signature=$(echo -n '$header.$payload' | openssl dgst -sha256 -hmac secret -binary | openssl base64 -e -A | sed s/\+/-/ | sed -E s/=+$//)
7+
8+
export jwt=$header.$payload.$hmac_signature
9+
echo $jwt > jwt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
jwt_content=$(cat jwt)
3+
set -e
4+
curl -X GET http://localhost:7575/v1/query -H "Content-Type: application/json" -H "Authorization: Bearer $jwt_content"
5+
6+
echo "DAML API Success!"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[supervisord]
2+
logfile_maxbytes = 50MB
3+
logfile_backups=10
4+
loglevel = info
5+
6+
[program:daml]
7+
# command=daml build && && daml sandbox --wall-clock-time --dar ./.daml/dist/quickstart-0.0.1.dar && daml json-api --config json-api-app.conf
8+
command = bash -c 'daml build && daml sandbox --wall-clock-time --dar ./.daml/dist/quickstart-0.0.1.dar || { echo "Command failed" >&2; exit 1; }'
9+
autostart=true
10+
autorestart=true
11+
stderr_logfile=/var/log/daml.err.log
12+
stdout_logfile=/var/log/daml.out.log
13+
14+
15+
16+
[program:jsonapi]
17+
# command=daml build && && daml sandbox --wall-clock-time --dar ./.daml/dist/quickstart-0.0.1.dar && daml json-api --config json-api-app.conf
18+
command = daml json-api --config json-api-app.conf
19+
autostart=true
20+
autorestart=true
21+
stderr_logfile=/var/log/daml.err.log
22+
stdout_logfile=/var/log/daml.out.log
23+
24+
[inet_http_server]
25+
port = 0.0.0.0:9001
26+
27+
28+

0 commit comments

Comments
 (0)