Skip to content

Commit

Permalink
Merge pull request #574 from cardano-foundation/develop
Browse files Browse the repository at this point in the history
Merge from develop to main
  • Loading branch information
iFergal authored Jul 11, 2024
2 parents cbf2ab7 + d48c84c commit 479888d
Show file tree
Hide file tree
Showing 293 changed files with 42,818 additions and 11,071 deletions.
73 changes: 64 additions & 9 deletions .github/workflows/docker-builds.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: Build and publish docker artifacts

on:
push:
branches: [ main, develop ]
pull_request:
types: [ opened, synchronize ]
paths:
- 'Earthfile'
- '.github/workflows/docker-builds.yaml'
- 'services/credential-server-ui/**'
- 'services/credential-server/**'
workflow_dispatch:

env:
Expand All @@ -13,24 +22,54 @@ jobs:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
runs-on: [arc-runner-set]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set extra environment and metadata
id: metadata
run: |
BRANCH=${GITHUB_REF##*/}
GIT_SHORT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")
CURRENT_VERSION=$(jq -r .version package.json)
if [ ${{github.event_name}} == "pull_request" ]
then
GIT_BRANCH_SHORT_COMMIT=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})
PR_NUMBER=$(echo $GITHUB_REF | awk -F/ '{ print $3 }')
ARTIFACT_VERSION="${CURRENT_VERSION}-PR${PR_NUMBER}"
echo "ARTIFACT_VERSION=${ARTIFACT_VERSION}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
# set earthly docker image targets based on changed paths
set +e
DOCKER_IMAGES_TARGETS="$( \
( git log --pretty=format:'%h' -n 1 Earthfile | grep -q ${GIT_BRANCH_SHORT_COMMIT} ) && \
( git log --patch -n1 Earthfile | grep -q "ARG.*global.*KERIA_GIT" ) && \
echo idw-keria
)"
DOCKER_IMAGES_TARGETS="$DOCKER_IMAGES_TARGETS $( \
( git log --pretty=format:'%h' -n 1 Earthfile | grep -q ${GIT_BRANCH_SHORT_COMMIT} ) && \
( git log --patch -n1 Earthfile | grep -q "ARG.*global.*KERI_DOCKER" ) && \
echo idw-witness
)"
DOCKER_IMAGES_TARGETS="$DOCKER_IMAGES_TARGETS $( \
( git log --pretty=format:'%h' -n 1 services/credential-server | grep -q ${GIT_BRANCH_SHORT_COMMIT} ) && \
echo cred-issuance
)"
DOCKER_IMAGES_TARGETS="$DOCKER_IMAGES_TARGETS $( \
( git log --pretty=format:'%h' -n 1 services/credential-server-ui | grep -q ${GIT_BRANCH_SHORT_COMMIT} ) && \
echo cred-issuance-ui
)"
set -e
STRIPPED_DOCKER_IMAGES_TARGETS=$(echo $DOCKER_IMAGES_TARGETS | tr -s ' ' | sed -e 's|^ ||' -e 's| $||')
if [ ! -z "${STRIPPED_DOCKER_IMAGES_TARGETS}" ]; then
echo "DOCKER_IMAGES_TARGETS=${STRIPPED_DOCKER_IMAGES_TARGETS}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
fi
else
BRANCH=${GITHUB_REF##*/}
echo "BRANCH=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
ARTIFACT_VERSION=${CURRENT_VERSION}-${BRANCH}
Expand All @@ -39,8 +78,8 @@ jobs:
echo "DOCKER_COMMIT_TAG=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_COMMIT_GHRUNID_TAG=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}-${GITHUB_RUN_ID}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "EARTHLY_BUILD_ARGS=DOCKER_IMAGES_EXTRA_TAGS=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT} ${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}-${GITHUB_RUN_ID}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "EARTHLY_DOCKER_IMAGES_EXTRA_TAGS=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT} ${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}-${GITHUB_RUN_ID}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
- name: Docker Login (private registry)
uses: docker/login-action@v2
Expand All @@ -61,10 +100,26 @@ jobs:
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: "0.8.6"
version: "0.8.14"

- name: 🌍 earthly (docker build and push)
env:
EARTHLY_BUILD_ARGS: ${{ steps.metadata.outputs.EARTHLY_BUILD_ARGS }},DOCKER_REGISTRIES=${{ secrets.DOCKER_REGISTRIES }}
run: |
earthly +docker-publish
# For PR builds, we skip any earthly build if there are no changes on any known target-related file, for branch builds, we just build everything
if [ ${{github.event_name}} == "pull_request" ]
then
if [ ! -z "${DOCKER_IMAGES_TARGETS}" ]
then
earthly +docker-publish \
--PUSH=true \
--DOCKER_REGISTRIES="${{ secrets.DOCKER_REGISTRIES }}" \
--DOCKER_IMAGES_EXTRA_TAGS="${EARTHLY_DOCKER_IMAGES_EXTRA_TAGS}" \
--DOCKER_IMAGES_TARGETS="${DOCKER_IMAGES_TARGETS}"
else
echo "[+] No changes on any known target-related file, skipping earthly build..."
fi
else
earthly +docker-publish \
--PUSH=true \
--DOCKER_REGISTRIES="${{ secrets.DOCKER_REGISTRIES }}" \
--DOCKER_IMAGES_EXTRA_TAGS="${EARTHLY_DOCKER_IMAGES_EXTRA_TAGS}"
fi
18 changes: 18 additions & 0 deletions .github/workflows/e2e_mobile_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Mobile e2e tests
on:
workflow_dispatch:
jobs:
test:
timeout-minutes: 60
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
run: npm ci
5 changes: 2 additions & 3 deletions .github/workflows/gh-vercel-branch-deploys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy-branch:
runs-on: ubuntu-latest
runs-on: [arc-runner-set]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -34,11 +34,10 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive # Fetch private content
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod
lfs: true

# Initiate GH deployment status
- name: Start Deployment
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/gh-vercel-pr-deploys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
# This workflow contains a single job called "deploy-preview"
deploy-preview:
runs-on: ubuntu-latest
runs-on: [arc-runner-set]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -31,11 +31,10 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive # Fetch private content
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod
lfs: true

- name: Setup Node
uses: actions/setup-node@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dependencies
node_modules
keria
/.pnp
.pnp.js

Expand Down
169 changes: 100 additions & 69 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,103 +1,134 @@
VERSION 0.8

ARG --global DOCKER_IMAGES_TARGETS="keria vlei credential-issuance-server"
ARG --global DOCKER_IMAGES_TARGETS="idw-keria idw-witness cred-issuance cred-issuance-ui"

ARG --global KERIA_GIT_REPO_URL="https://github.com/WebOfTrust/keria.git"
ARG --global KERIA_GIT_REF=fb6009a7ceaf39f36bf63651f14fc5a53dc743d4
ARG --global KERIA_GIT_REPO_URL="https://github.com/cardano-foundation/keria.git"
ARG --global KERIA_GIT_REF=03a1b13047f91f7f287e0a03d227084835db6616

ARG --global VLEI_GIT_REPO_URL="https://github.com/WebOfTrust/vLEI.git"
ARG --global VLEI_GIT_REF="ed982313dab86bfada3825857601a10d71ce9631"

ARG --global ARIES_MEDIATOR_GIT_REPO_URL="https://github.com/hyperledger/aries-mediator-service.git"
ARG --global ARIES_MEDIATOR_GIT_REF="765914d969ea73854eae401795dbe85c64f8a115"
ARG --global KERI_DOCKER_IMAGE_REPO=weboftrust/keri
ARG --global KERI_DOCKER_IMAGE_TAG=1.1.6

ARG --global DOCKER_IMAGE_PREFIX="cf"
ARG --global DOCKER_IMAGES_EXTRA_TAGS=""
ARG --global DOCKER_REGISTRIES=""
ARG --global DOCKER_REGISTRIES="hub.docker.com"
ARG --global HUB_DOCKER_COM_USER=cardanofoundation
ARG --global PUSH=false

all:
LOCALLY
FOR image_target IN $DOCKER_IMAGES_TARGETS
BUILD +$image_target
BUILD +$image_target --PUSH=$PUSH
END

docker-publish:
BUILD +all --PUSH=$PUSH

TEMPLATED_DOCKER_TAG_N_PUSH:
FUNCTION
ARG EARTHLY_GIT_SHORT_HASH
WAIT
BUILD +all
END
ARG PUSH # we use this as --push is not supported in LOCALLY blocks
ARG DOCKER_IMAGE_NAME
ARG DOCKER_IMAGES_EXTRA_TAGS
LOCALLY
FOR registry IN $DOCKER_REGISTRIES
FOR image_target IN $DOCKER_IMAGES_TARGETS
IF [ ! -z "$DOCKER_IMAGES_EXTRA_TAGS" ]
FOR image_tag IN $DOCKER_IMAGES_EXTRA_TAGS
IF [ "$registry" = "hub.docker.com" ]
RUN docker tag ${image_target}:latest ${HUB_DOCKER_COM_USER}/${image_target}:${image_tag}
RUN docker push ${HUB_DOCKER_COM_USER}/${image_target}:${image_tag}
ELSE
RUN docker tag ${image_target}:latest ${registry}/${image_target}:${image_tag}
RUN docker push ${registry}/${image_target}:${image_tag}
END
END
END
FOR image_tag IN $DOCKER_IMAGES_EXTRA_TAGS
IF [ "$registry" = "hub.docker.com" ]
RUN docker tag ${image_target}:latest ${HUB_DOCKER_COM_USER}/${image_target}:${EARTHLY_GIT_SHORT_HASH}
RUN docker push ${HUB_DOCKER_COM_USER}/${image_target}:${EARTHLY_GIT_SHORT_HASH}
RUN docker tag ${DOCKER_IMAGE_NAME}:latest ${HUB_DOCKER_COM_USER}/${DOCKER_IMAGE_NAME}:${image_tag}
RUN if [ "$PUSH" = "true" ]; then docker push ${HUB_DOCKER_COM_USER}/${DOCKER_IMAGE_NAME}:${image_tag}; fi
ELSE
RUN docker tag ${image_target}:latest ${registry}/${image_target}:${EARTHLY_GIT_SHORT_HASH}
RUN docker push ${registry}/${image_target}:${EARTHLY_GIT_SHORT_HASH}
RUN docker tag ${DOCKER_IMAGE_NAME}:latest ${registry}/${DOCKER_IMAGE_NAME}:${image_tag}
RUN if [ "$PUSH" = "true" ]; then docker push ${registry}/${DOCKER_IMAGE_NAME}:${image_tag}; fi
END
END
IF [ "$registry" = "hub.docker.com" ]
RUN docker tag ${DOCKER_IMAGE_NAME}:latest ${HUB_DOCKER_COM_USER}/${DOCKER_IMAGE_NAME}:${EARTHLY_GIT_SHORT_HASH}
RUN if [ "$PUSH" = "true" ]; then docker push ${HUB_DOCKER_COM_USER}/${DOCKER_IMAGE_NAME}:${EARTHLY_GIT_SHORT_HASH}; fi
ELSE
RUN docker tag ${DOCKER_IMAGE_NAME}:latest ${registry}/${DOCKER_IMAGE_NAME}:${EARTHLY_GIT_SHORT_HASH}
RUN if [ "$PUSH" = "true" ]; then docker push ${registry}/${DOCKER_IMAGE_NAME}:${EARTHLY_GIT_SHORT_HASH}; fi
END
END

keria-src:
ARG KERIA_KERIPY_DEPEND_VERSION_OVERRIDE="keri @ git+https://git@github.com/weboftrust/keripy.git@efde86d303a9b6e26e6892e3350ea7a724ea8502"
FROM alpine
GIT CLONE --branch $KERIA_GIT_REF $KERIA_GIT_REPO_URL /keria
RUN sed -i "s|'keri>=.*,$|'$KERIA_KERIPY_DEPEND_VERSION_OVERRIDE',|" /keria/setup.py
FROM alpine/git
RUN git clone $KERIA_GIT_REPO_URL /keria && \
cd /keria && \
git checkout $KERIA_GIT_REF
SAVE ARTIFACT /keria

keria:
idw-keria:
ARG EARTHLY_TARGET_NAME
FROM DOCKERFILE -f +keria-src/keria/images/keria.dockerfile +keria-src/keria/*
ENTRYPOINT keria start --config-file backer-oobis --config-dir ./scripts
SAVE IMAGE $EARTHLY_TARGET_NAME:$KERIA_GIT_REF
SAVE IMAGE $EARTHLY_TARGET_NAME:latest
ARG DOCKER_IMAGES_EXTRA_TAGS
LET DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}

vlei-src:
FROM scratch
GIT CLONE --branch $VLEI_GIT_REF $VLEI_GIT_REPO_URL /vlei
SAVE ARTIFACT /vlei
LOCALLY
ARG REGISTRY_IMAGE_EXISTS=$( ( docker manifest inspect ${HUB_DOCKER_COM_USER}/${EARTHLY_TARGET_NAME}:keria-${KERIA_GIT_REF} 2>/dev/null ) || echo false)
IF [ "${REGISTRY_IMAGE_EXISTS}" = "false" ]
WAIT
FROM DOCKERFILE -f +keria-src/keria/images/keria.dockerfile +keria-src/keria/*
ENTRYPOINT keria start --config-file backer-oobis --config-dir ./scripts
END
WAIT
SAVE IMAGE ${DOCKER_IMAGE_NAME}:$KERIA_GIT_REF
SAVE IMAGE ${DOCKER_IMAGE_NAME}:latest
END
DO +TEMPLATED_DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS} keria-${KERIA_GIT_REF}"
END

vlei:
ARG EARTHLY_TARGET_NAME
FROM DOCKERFILE -f +vlei-src/vlei/container/Dockerfile +vlei-src/vlei/*
ENTRYPOINT vLEI-server -s ./schema/acdc -c ./samples/acdc/ -o ./samples/oobis/
SAVE IMAGE $EARTHLY_TARGET_NAME:$VLEI_GIT_REF
SAVE IMAGE $EARTHLY_TARGET_NAME:latest

mediator-src:
FROM alpine
GIT CLONE --branch $ARIES_MEDIATOR_GIT_REF $ARIES_MEDIATOR_GIT_REPO_URL /aries-mediator-service
COPY ./docker-assets/mediator/Dockerfile /aries-mediator-service/afj/
COPY ./docker-assets/mediator/yarn.lock /aries-mediator-service/afj/
COPY ./docker-assets/mediator/tsconfig.json /aries-mediator-service/afj/
RUN sed -i 's|"start":.*|"start": "node ./dist/src/mediator.js",|' /aries-mediator-service/afj/package.json
SAVE ARTIFACT /aries-mediator-service

mediator-caddy:
idw-witness:
ARG EARTHLY_TARGET_NAME
ARG CADDY_DOCKER_IMAGE_TAG=2.7.6
FROM caddy:$CADDY_DOCKER_IMAGE_TAG
COPY ./docker-assets/mediator/Caddyfile /etc/caddy/Caddyfile
SAVE IMAGE $EARTHLY_TARGET_NAME
ARG DOCKER_IMAGES_EXTRA_TAGS
LET DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}

mediator:
LOCALLY
ARG REGISTRY_IMAGE_EXISTS=$( (docker manifest inspect ${EARTHLY_TARGET_NAME}:keri-${KERI_DOCKER_IMAGE_TAG} 2> /dev/null | grep -q layers) || echo false)

IF [ "${REGISTRY_IMAGE_EXISTS}" = "false" ]
WAIT
FROM ${KERI_DOCKER_IMAGE_REPO}:${KERI_DOCKER_IMAGE_TAG}
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
ENTRYPOINT kli witness demo
END
WAIT
SAVE IMAGE ${DOCKER_IMAGE_NAME}:keri-${KERI_DOCKER_IMAGE_TAG}
SAVE IMAGE ${DOCKER_IMAGE_NAME}:latest
END
DO +TEMPLATED_DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS} keri-${KERI_DOCKER_IMAGE_TAG}"
END

cred-issuance:
ARG EARTHLY_TARGET_NAME
FROM DOCKERFILE -f +mediator-src/aries-mediator-service/afj/Dockerfile +mediator-src/aries-mediator-service/afj/*
SAVE IMAGE $EARTHLY_TARGET_NAME:$ARIES_MEDIATOR_GIT_REF
LET DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}

credential-issuance-server:
WAIT
FROM DOCKERFILE ./services/credential-server
END
WAIT
SAVE IMAGE ${DOCKER_IMAGE_NAME}
END
DO +TEMPLATED_DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"

cred-issuance-ui:
ARG EARTHLY_TARGET_NAME
FROM DOCKERFILE ./services/credential-issuance-server
SAVE IMAGE $EARTHLY_TARGET_NAME
LET DOCKER_IMAGE_NAME=${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}

WAIT
FROM DOCKERFILE ./services/credential-server-ui
END
WAIT
SAVE IMAGE ${DOCKER_IMAGE_NAME}
END
DO +TEMPLATED_DOCKER_TAG_N_PUSH \
--PUSH=$PUSH \
--DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME} \
--DOCKER_IMAGES_EXTRA_TAGS="${DOCKER_IMAGES_EXTRA_TAGS}"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Ensure that your system meets these requirements to successfully use and develop
```bash
git clone https://github.com/cardano-foundation/cf-identity-wallet.git
cd cf-identity-wallet
make init # This will configure the git hooks
```

## Preparing the App
Expand Down
Loading

0 comments on commit 479888d

Please sign in to comment.