diff --git a/.github/workflows/deploy-stack.yml b/.github/workflows/deploy-stack.yml index 89a2324..7ec1183 100644 --- a/.github/workflows/deploy-stack.yml +++ b/.github/workflows/deploy-stack.yml @@ -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: @@ -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: @@ -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 }} diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..6ea94fd --- /dev/null +++ b/.github/workflows/release-image.yml @@ -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 diff --git a/README.md b/README.md index de8fc8b..68e6790 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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. | @@ -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 ``` @@ -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=" \ + -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=" \ + -e "POSTGRES_ADMIN_USER=postgres" \ + -e "POSTGRES_ADMIN_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: diff --git a/docker-compose-animo-mediator.yml b/docker-compose-animo-mediator.yml new file mode 100644 index 0000000..5953778 --- /dev/null +++ b/docker-compose-animo-mediator.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 5953778..5bf6cc2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,12 @@ 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} @@ -27,13 +14,7 @@ services: 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