Skip to content

Commit

Permalink
ci: set up release tags
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed May 26, 2023
1 parent d0920cb commit 5106ff5
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 51 deletions.
27 changes: 5 additions & 22 deletions .github/workflows/deploy-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ name: Build and Deploy Stack
on:
workflow_dispatch:
inputs:
build-mediator:
default: true
type: boolean
required: false
description: Build mediator image before deploying
tag:
description: 'Tag to use for the image'
required: true
type: string

jobs:
build_and_deploy:
Expand All @@ -18,22 +17,6 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Log in to the Container registry
if: inputs.build-mediator == true
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Publish Mediator
uses: ./.github/actions/publish-docker-image
if: inputs.build-mediator == true
with:
image-name: ghcr.io/animo/animo-mediator
context: .
docker-file: Dockerfile

- name: Deploy Template Stack
uses: ./.github/actions/deploy
env:
Expand All @@ -47,5 +30,5 @@ jobs:
with:
envs: WALLET_KEY,POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DATABASE_URL,POSTGRES_ADMIN_USER,POSTGRES_ADMIN_PASSWORD,POSTGRES_TLS_CA
stack-name: animo-afj-mediator
stack-file: ./docker-compose.yml
stack-file: ./docker-compose-animo-mediator.yml
private-key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }}
29 changes: 29 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release Image

on:
push:
tags:
- v*

jobs:
build_and_deploy:
name: Build and Deploy Stack
runs-on: ubuntu-20.04

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Publish Mediator
uses: ./.github/actions/publish-docker-image
with:
image-name: ghcr.io/animo/animo-mediator
context: .
docker-file: Dockerfile
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Why should you use this mediator?
## Getting Started

> If you want to deploy the mediator based on the pre-built docker image, please see the [Using Docker](#using-docker) section.
Make sure you have followed the `libindy` setup form the AFJ docs: https://aries.js.org/guides/next/getting-started/set-up/indy-sdk

Then run install to install dependencies:
Expand Down Expand Up @@ -99,10 +101,10 @@ The `POSTGRES_` variables won't be used in development mode (`NODE_ENV=developme
| Variable | Description |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AGENT_ENDPOINTS` | Comma separated list of endpoints, in order of preference. In most cases you want to provide two endpoints, where the first one is an HTTP url, and the second one is an WebSocket url |
| `AGENT_WALLET_KEY` | The key to unlock the wallet. |
| `AGENT_WALLET_NAME` | The name of the wallet to use. |
| `AGENT_NAME` | The name of the agent. This will be used in invitations and will be publicly advertised. |
| `AGENT_PORT` | The port that is exposed for incoming traffic. Both the HTTP and WS inbound transport handlers are exposes on this port, and HTTP traffic will be upgraded to the WebSocket server when applicable. |
| `WALLET_NAME` | The name of the wallet to use. |
| `WALLET_KEY` | The key to unlock the wallet. |
| `INVITATION_URL` | Optional URL that can be used as the base for the invitation url. This would allow you to render a certain web page that can extract the invitation form the `oob` parameter, and show the QR code, or show useful information to the end-user. Less applicable to mediator URLs. |
| `POSTGRES_DATABASE_URL` | The postgres database url. |
| `POSTGRES_USER` | The postgres user. |
Expand All @@ -122,6 +124,17 @@ To deploy the mediator, a postgres database is required. Any postgres database w

## Using Docker

### Using the pre-built Docker Image

1. Make sure you're [authenticated to the Github Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry)
2. Run the docker image using the following command:

```sh
docker run
```

### Building the Docker Image

1. Build the docker image

```
Expand All @@ -131,12 +144,26 @@ docker build \
.
```

1. Run the docker image

```
docker run ghcr.io/animo/animo-mediator
2. Run the docker image using the following command:

```sh
docker run \
-e "AGENT_ENDPOINTS=http://localhost:3000,ws://localhost:3000" \
-e "WALLET_KEY=<your-wallet-key>" \
-e "WALLET_NAME=mediator" \
-e "AGENT_NAME=Mediator" \
-e "AGENT_PORT=3000" \
-e "POSTGRES_DATABASE_URL=postgres://postgres:postgres@localhost:5432/mediator" \
-e "POSTGRES_USER=postgres" \
-e "POSTGRES_PASSWORD=<your-postgres-password>" \
-e "POSTGRES_ADMIN_USER=postgres" \
-e "POSTGRES_ADMIN_PASSWORD=<your-postgres-password>" \
-p 3000:3000 \
ghcr.io/animo/animo-mediator:latest
```

You can also adapt the `docker-compose.yml` file to your needs. Make sure to use the correct tag. By default `latest` will be used which can have unexpected breakage. See the releases for the latest stable tag.

## Roadmap

The contents in this repository started out as a simple mediator built using Aries Framework JavaScript that can be used for development. Over time we've added some features, but there's still a lot we want to add to this repository over time. Some things on the roadmap:
Expand Down
39 changes: 39 additions & 0 deletions docker-compose-animo-mediator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.5'

services:
animo-mediator:
image: ghcr.io/animo/animo-mediator:main
networks:
- traefik
deploy:
labels:
# Enable traefik so the container can be exposed to the outside world
traefik.enable: 'true'

# HTTP and WS communication
traefik.http.routers.animo-mediator.rule: Host(`mediator.dev.animo.id`)
traefik.http.routers.animo-mediator.entrypoints: web-secure
traefik.http.routers.animo-mediator.tls.certresolver: zerossl
traefik.http.routers.animo-mediator.service: animo-mediator-service
traefik.http.services.animo-mediator-service.loadbalancer.server.port: 3000
environment:
AGENT_PORT: 3000
AGENT_NAME: Animo Mediator
WALLET_NAME: animo-mediator
WALLET_KEY: ${WALLET_KEY}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DATABASE_URL: ${POSTGRES_DATABASE_URL}
POSTGRES_ADMIN_USER: ${POSTGRES_ADMIN_USER}
POSTGRES_ADMIN_PASSWORD: ${POSTGRES_ADMIN_PASSWORD}
POSTGRES_TLS_CA: ${POSTGRES_TLS_CA}
AGENT_ENDPOINTS: 'https://mediator.dev.animo.id,wss://mediator.dev.animo.id'
INVITATION_URL: https://mediator.dev.animo.id/invite
LOG_LEVEL: 2
ports:
- '3000'

networks:
traefik:
external: true
name: traefik
27 changes: 4 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
version: '3.5'

services:
animo-mediator:
animomediator:
image: ghcr.io/animo/animo-mediator:main
networks:
- traefik
deploy:
labels:
# Enable traefik so the container can be exposed to the outside world
traefik.enable: 'true'

# HTTP and WS communication
traefik.http.routers.animo-mediator.rule: Host(`mediator.dev.animo.id`)
traefik.http.routers.animo-mediator.entrypoints: web-secure
traefik.http.routers.animo-mediator.tls.certresolver: zerossl
traefik.http.routers.animo-mediator.service: animo-mediator-service
traefik.http.services.animo-mediator-service.loadbalancer.server.port: 3000
environment:
AGENT_PORT: 3000
AGENT_NAME: Animo Mediator
WALLET_NAME: animo-mediator
AGENT_NAME: Mediator
WALLET_NAME: mediator
WALLET_KEY: ${WALLET_KEY}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DATABASE_URL: ${POSTGRES_DATABASE_URL}
POSTGRES_ADMIN_USER: ${POSTGRES_ADMIN_USER}
POSTGRES_ADMIN_PASSWORD: ${POSTGRES_ADMIN_PASSWORD}
POSTGRES_TLS_CA: ${POSTGRES_TLS_CA}
AGENT_ENDPOINTS: 'https://mediator.dev.animo.id,wss://mediator.dev.animo.id'
INVITATION_URL: https://mediator.dev.animo.id/invite
AGENT_ENDPOINTS: 'https://my-mediator.com,wss://my-mediator.com'
LOG_LEVEL: 2
ports:
- '3000'

networks:
traefik:
external: true
name: traefik

0 comments on commit 5106ff5

Please sign in to comment.