Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Initial commit - Webvh #1377

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions webvh/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/python-3/.devcontainer/base.Dockerfile
ARG VARIANT="3.12"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

ARG POETRY_VERSION="1.8.3"
ENV POETRY_HOME="/opt/poetry" \
POETRY_VERSION=${POETRY_VERSION}

RUN curl -sSL https://install.python-poetry.org | python3 - \
&& update-alternatives --install /usr/local/bin/poetry poetry /opt/poetry/bin/poetry 900 \
# Enable tab completion for bash
&& poetry completions bash >> /home/vscode/.bash_completion \
# Enable tab completion for Zsh
&& mkdir -p /home/vscode/.zfunc/ \
&& poetry completions zsh > /home/vscode/.zfunc/_poetry \
&& echo "fpath+=~/.zfunc\nautoload -Uz compinit && compinit" >> /home/vscode/.zshrc

COPY pyproject.toml ./
# COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create true \
&& poetry install --no-root --no-interaction --with integration --extras "aca-py" \
&& rm -rf /root/.cache/pypoetry
59 changes: 59 additions & 0 deletions webvh/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "webvh",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.12-bullseye",
"POETRY_VERSION": "1.8.3"
}
},
"customizations": {
"vscode": {
"extensions": ["ms-python.python", "ms-python.vscode-pylance"],
"settings": {
"python.testing.pytestArgs": ["./webvh", "--no-cov"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": "pytest",
"editor.defaultFormatter": null,
"editor.formatOnSave": false, // enable per language
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "charliermarsh.ruff",
"ruff.organizeImports": true
},
"ruff.codeAction.fixViolation": {
"enable": true
},
"ruff.fixAll": true,
"ruff.format.args": ["--config=./pyproject.toml"],
"ruff.lint.args": ["--config=./pyproject.toml"]
}
}
},

"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": false
}
},

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

"remoteEnv": {
"RUST_LOG": "aries-askar::log::target=error"
},

"mounts": [],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 3001],
"postCreateCommand": "bash ./.devcontainer/post-install.sh"
}
11 changes: 11 additions & 0 deletions webvh/.devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -ex

# Convenience workspace directory for later use
WORKSPACE_DIR=$(pwd)

# install all ACA-Py requirements
python -m pip install --upgrade pip

# Generate Poetry Lock file
poetry lock --no-update
9 changes: 9 additions & 0 deletions webvh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# < Replace With The Plugin Name >

## Description

< Replace with information about the reason this plugin was produced and a brief overview of the features >

## Configuration

< Replace this section with an outline of configuration options and basic defaults for deploying the plugin >
31 changes: 31 additions & 0 deletions webvh/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.12-slim AS base
WORKDIR /usr/src/app

# Install and configure poetry
USER root

ENV POETRY_VERSION=1.8.3
ENV POETRY_HOME=/opt/poetry
RUN apt-get update && apt-get install -y curl && apt-get clean
RUN curl -sSL https://install.python-poetry.org | python -

ENV PATH="/opt/poetry/bin:$PATH"
RUN poetry config virtualenvs.in-project true

# Setup project
RUN mkdir webvh && touch webvh/__init__.py
COPY pyproject.toml poetry.lock README.md ./
ARG install_flags='--with integration --extras aca-py'
RUN poetry install ${install_flags}
USER $user

FROM python:3.12-bullseye
WORKDIR /usr/src/app
COPY --from=base /usr/src/app/.venv /usr/src/app/.venv
ENV PATH="/usr/src/app/.venv/bin:$PATH"

COPY webvh/ webvh/
COPY docker/*.yml ./

ENTRYPOINT ["/bin/bash", "-c", "aca-py \"$@\"", "--"]
CMD ["start", "--arg-file", "endorser.yml"]
37 changes: 37 additions & 0 deletions webvh/docker/author.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
label: webvh-author

auto-provision: true

admin: [0.0.0.0, 4001]
admin-insecure-mode: false
admin-api-key: change-me

inbound-transport:
- [http, 0.0.0.0, 4000]
- [ws, 0.0.0.0, 4002]
outbound-transport: http
endpoint:
- http://host.docker.internal:4000

plugin:
- webvh

no-ledger: true

# Wallet
wallet-type: askar-anoncreds
wallet-name: author-wallet
wallet-key: insecure


log-level: info

auto-accept-invites: true
auto-respond-messages: true

# Plugin
plugin-config-value:
plugin-config-value:
- did-webvh.server_url=https://localhost:8000
- did-webvh.role=author
- did-webvh.endorser_invitation=http://host.docker.internal:3000?oob=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzEuMS9pbnZpdGF0aW9uIiwgIkBpZCI6ICI1ZWMwYTdhYi0xMGE3LTQxOTQtYjcxOC0zODM4MmY2Y2I2ZWEiLCAibGFiZWwiOiAid2VidmgtZW5kb3JzZXIiLCAiaGFuZHNoYWtlX3Byb3RvY29scyI6IFsiaHR0cHM6Ly9kaWRjb21tLm9yZy9kaWRleGNoYW5nZS8xLjAiXSwgInNlcnZpY2VzIjogW3siaWQiOiAiI2lubGluZSIsICJ0eXBlIjogImRpZC1jb21tdW5pY2F0aW9uIiwgInJlY2lwaWVudEtleXMiOiBbImRpZDprZXk6ejZNa3IydVRUYmh4SHVVdzh4aTd6NGFoZEE5emRNc2NZOUV5SmpkQXNuTnVkSnh0I3o2TWtyMnVUVGJoeEh1VXc4eGk3ejRhaGRBOXpkTXNjWTlFeUpqZEFzbk51ZEp4dCJdLCAic2VydmljZUVuZHBvaW50IjogImh0dHA6Ly9ob3N0LmRvY2tlci5pbnRlcm5hbDozMDAwIn1dfQ
36 changes: 36 additions & 0 deletions webvh/docker/endorser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
label: webvh-endorser

auto-provision: true

admin: [0.0.0.0, 3001]
admin-insecure-mode: false
admin-api-key: change-me

inbound-transport:
- [http, 0.0.0.0, 3000]
- [ws, 0.0.0.0, 3002]
outbound-transport: http
endpoint:
- http://host.docker.internal:3000

plugin:
- webvh

no-ledger: true

# Wallet
wallet-type: askar-anoncreds
wallet-name: endorser-wallet
wallet-key: insecure


log-level: info

auto-accept-invites: true
auto-respond-messages: true

# Plugin
plugin-config-value:
- did-webvh.server_url=https://localhost:8000
- did-webvh.role=endorser
- did-webvh.auto_endorse=true
20 changes: 20 additions & 0 deletions webvh/docker/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
label: webvh

admin: [0.0.0.0, 3001]
admin-insecure-mode: true

inbound-transport:
- [http, 0.0.0.0, 3000]
outbound-transport: http
endpoint:
- http://host.docker.internal:3000

plugin:
- webvh.v1_0

genesis-url: http://test.bcovrin.vonx.io/genesis

log-level: info

auto-accept-invites: true
auto-respond-messages: true
18 changes: 18 additions & 0 deletions webvh/integration/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.12

WORKDIR /fastapi

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv "$VIRTUAL_ENV"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN apt-get -y update
RUN apt-get -y install git

RUN pip install --upgrade pip
RUN pip install poetry
RUN git clone https://github.com/decentralized-identity/trustdidweb-server-py.git
WORKDIR /fastapi/trustdidweb-server-py/server
RUN poetry install

CMD ["python", "main.py"]
20 changes: 20 additions & 0 deletions webvh/integration/Dockerfile.test.runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.12-slim
WORKDIR /usr/src/app

# install poetry
RUN pip3 install --no-cache-dir poetry==1.8.3

# Add docker-compose-wait tool
ENV WAIT_VERSION 2.7.2
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait
RUN chmod +x /wait

# install dependencies
COPY pyproject.toml .
COPY poetry.lock .
RUN poetry install --only main

# add tests to image
COPY tests/* tests/

ENTRYPOINT ["/bin/sh", "-c", "/wait && poetry run pytest \"$@\"", "--"]
14 changes: 14 additions & 0 deletions webvh/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Integration Tests

All plugins should have a suite of integration tests. We use `docker compose` to set up the environment, and make use of the [Dockerfile](../docker/Dockerfile) to produce our ACA-Py/Plugin image. To simplify, we have another [Dockerfile](Dockerfile.test.runner) for running those [tests](/tests/).

## Build and run Tests

The integration tests will start 2 agents - bob and alice - and a juggernaut container that will execute the tests. Test results will be found in the juggernaut container output. The juggernaut container should close itself down, the logs can be reviewed in the `Docker` view, open `Containers`, open `integration`, right-click the `integration-tests` container and select `View Logs`

```sh
# open a terminal in vs code
cd integration
docker compose build
docker compose up
```
86 changes: 86 additions & 0 deletions webvh/integration/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
services:
endorser:
image: plugin-image
build:
context: ..
dockerfile: docker/Dockerfile
args:
- install_flags=--no-interaction --with integration --extras aca-py
command: >
start
--label Endorser
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://endorser:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--no-ledger
--wallet-type askar-anoncreds
--wallet-name endorser
--wallet-key insecure
--auto-provision
--log-level info
--notify-revocation
--plugin webvh
--plugin-config-value did-webvh.server_url=http://server:8000
--plugin-config-value did-webvh.role=endorser
--plugin-config-value did-webvh.auto_endorse=true
--wallet-allow-insecure-seed

author:
image: plugin-image
build:
context: ..
dockerfile: docker/Dockerfile
args:
- install_flags=--no-interaction --with integration --extras aca-py
command: >
start
--label Author
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://author:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--no-ledger
--wallet-type askar-anoncreds
--wallet-name author
--wallet-key insecure
--auto-provision
--log-level info
--monitor-revocation-notification
--plugin webvh
--plugin-config-value did-webvh.server_url=http://server:8000
--plugin-config-value did-webvh.role=author

server:
build:
context: .
dockerfile: Dockerfile.server
environment:
DOMAIN: server
SECRET_KEY: insecure
ENDORSER_MULTIKEY: z6MkgKA7yrw5kYSiDuQFcye4bMaJpcfHFry3Bx45pdWh3s8i
ports:
- 8000:8000
labels:
- traefik.enable=true
- traefik.http.routers.server.rule=Host(`server`)
- traefik.http.routers.server.entrypoints=web
- traefik.http.services.server.loadbalancer.server.port=8000

tests:
container_name: juggernaut
build:
context: .
dockerfile: Dockerfile.test.runner
environment:
- WAIT_BEFORE_HOSTS=3
- WAIT_HOSTS=endorser:3000, author:3000
- WAIT_HOSTS_TIMEOUT=60
- WAIT_SLEEP_INTERVAL=1
- WAIT_HOST_CONNECT_TIMEOUT=30
depends_on:
- endorser
- author
- server
Loading
Loading