Skip to content

Commit

Permalink
Merge branch 'main' into feature/urlValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
loneil authored Jul 21, 2023
2 parents d4bc4d5 + 200fb9d commit 8baf3bf
Show file tree
Hide file tree
Showing 15 changed files with 364 additions and 44 deletions.
18 changes: 0 additions & 18 deletions .vscode/launch.json

This file was deleted.

21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,32 @@ If you would like to contribute to Traction, please review the following:
- [Code of Conduct](./CODE_OF_CONDUCT.md)
- [Compliance](./COMPLIANCE.yaml)

## Developers: devcontainers
To aid in developers, there are 2 `devcontainers`: [plugins](./plugins/.devcontainer/devcontainer.json) and [tenant-ui](./services/tenant-ui/.devcontainer/devcontainer.json).

The devcontainers and associated vscode launch files are for convenience only, they are not mandatory for developing and debugging. Please feel free to develop anyway you choose.

1. In VS code, open `plugins`.
2. Follow all prompts to open the devcontainer.
3. In a second VS Code window, open `services/tenant-ui`
4. Follow all prompts to open the devcontainer.
5. in `plugins`, start up the ACA-Py / Traction instance: Run and Debug view, "Run/Debug Plugin", start/F5
6. in `services/tenant-ui`, start up the backend api: Run and Debug view, "backend - run dev", start/F5
7. in `services/tenant-ui`, start up the frontend api: Run and Debug view, "frontend - run dev", start/F5
8. in `services/tenant-ui`, load a Chrome browser for debugging frontend: Run and Debug view, "frontend - chrome", start/F5

If all starts up without a hitch, then you should be able to breakpoint the tenant-ui frontend (Vue/Chrome), tenant-ui backend api (Node.js) and traction plugins (Python) for local debugging.

Out of the box, the above will use the following ports:

- ACA-Py/Traction Plugins: 3000, 3001 (admin)
- Tenant Proxy: 8032
- Traction DB: 5432
- Tenant UI backend server: 8080
- Tenant UI frontend server: 5173

Note that Tenant Proxy and Traction DB are startec via docker compose when starting ACA-Py/Traction Plugins

### Repository workflow
Currently authorized users can create a branch and run a pull request to merge in changes. Unauthorized can always create a fork.

Expand Down
7 changes: 7 additions & 0 deletions plugins/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# Poetry
ARG POETRY_VERSION="none"
RUN if [ "${POETRY_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install poetry==${POETRY_VERSION}"; fi
71 changes: 71 additions & 0 deletions plugins/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "traction_plugins",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.9-bullseye",
"POETRY_VERSION": "1.4.2"
}
},
"customizations": {
"vscode": {
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.testing.pytestArgs": [
".",
"--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
},
"python.formatting.provider": "black",
"python.formatting.blackArgs": [],
"python.venvFolders": ["~.cache/virtualenvs"]
},
"extensions": [
"ms-python.python",
"ms-python.pylint",
"ms-python.vscode-pylance"
]
}
},

"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},

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

"remoteEnv": {
// "PATH": "${containerEnv:PATH}:${workspaceRoot}/.venv/bin"
},

"mounts": ["source=${localWorkspaceFolder}/demo/configs,target=/configs,type=bind,consistency=cached"],
// Use 'forwardPorts' to make a list of ports inside the container available locally.

"forwardPorts": [
3000,3001,3002,
8032
],

"postCreateCommand": "bash ./.devcontainer/post-install.sh"

}
28 changes: 28 additions & 0 deletions plugins/.devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -ex

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

# install all ACA-Py requirements
python -m pip install --upgrade pip
#pip3 install -r requirements.txt -r requirements.askar.txt -r requirements.bbs.txt -r requirements.dev.txt -r requirements.indy.txt

# Change some Poetry settings to better deal with working in a container
poetry config cache-dir ${WORKSPACE_DIR}/.cache
poetry config virtualenvs.in-project true
# Now install all dependencies
poetry install

export PATH=${PATH}:${WORKSPACE_DIR}/.venv/bin

# add all the requirements to the default python
poetry export --without-hashes --format=requirements.txt > requirements.txt
pip install -r requirements.txt

# install black for formatting
pip3 install black

# cleanup
rm poetry.lock
rm requirements.txt
3 changes: 3 additions & 0 deletions plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cache
.venv
poetry.lock
23 changes: 23 additions & 0 deletions plugins/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run/Debug Plugin",
"type": "python",
"request": "launch",
"preLaunchTask": "docker-compose-start",
"module": "poetry",
"justMyCode": false,
"args": [
"run",
"python",
"-m",
"aries_cloudagent",
"start",
"--arg-file=${workspaceRoot}/demo/configs/devcontainer.yml"
]
}]
}
23 changes: 23 additions & 0 deletions plugins/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "docker-compose-start",
"type": "shell",
"command": "docker compose -f ${workspaceRoot}/demo/docker-compose.devcontainer.yml up --build -d",
"isBackground": true,
"problemMatcher": [
{
"pattern": [{ "regexp": ".", "file": 1, "location": 2, "message": 3, }],
"background": {
"activeOnStart": true,
"beginsPattern": "^Container demo-tenant-proxy-1$",
"endsPattern": "^Container demo-traction-db-1$",
}
},
]
},
]
}
83 changes: 83 additions & 0 deletions plugins/demo/configs/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
label: acapy-traction-plugins

# Admin
admin: [0.0.0.0, 3001]
admin-insecure-mode: false
admin-api-key: change-me
jwt-secret: change-me


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

# webhook: http://host.docker.internal:3000

# enable-undelivered-queue: true

# plugins
plugin:
- aries_cloudagent.messaging.jsonld
- traction_innkeeper.v1_0
- basicmessage_storage.v1_0
- connection_update.v1_0
- multitenant_provider.v1_0

# block-plugin:


plugin-config-value:
# - multitenant_provider.manager.class_name="traction_plugins.multitenant_provider.v1_0.manager.BasicMultitokenMultitenantManager"
- multitenant_provider.manager.class_name="multitenant_provider.v1_0.manager.AskarMultitokenMultitenantManager"
- multitenant_provider.manager.always_check_provided_wallet_key=true
- multitenant_provider.errors.on_unneeded_wallet_key=false
- multitenant_provider.token_expiry.units=days
- multitenant_provider.token_expiry.amount=1
- traction_innkeeper.innkeeper_wallet.tenant_id=innkeeper
- traction_innkeeper.innkeeper_wallet.wallet_name=traction_innkeeper
- traction_innkeeper.innkeeper_wallet.wallet_key=change-me
- traction_innkeeper.innkeeper_wallet.print_key=true
- traction_innkeeper.innkeeper_wallet.print_token=true
- traction_innkeeper.reservation.expiry_minutes=2880

# invite: true
# invite-label: ACA-Py (Traction Plugins)

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

# wallet-type: indy
wallet-type: askar
wallet-name: traction-wallet
wallet-key: 'insecure-change-me'
wallet-storage-type: postgres_storage
wallet-storage-config: '{"url":"host.docker.internal:5432","max_connections":5,"wallet_scheme":"DatabasePerWallet"}'
wallet-storage-creds: '{"account":"postgres","password":"postgresPass","admin_account":"postgres","admin_password":"postgresPass"}'
multitenancy-config: '{"wallet-type":"askar-profile","wallet-name":"askar-wallet"}'

log-level: info

multitenant: true
multitenant-admin: true

emit-new-didcomm-prefix: true
emit-new-didcomm-mime-type: true

auto-accept-invites: true
auto-accept-requests: true
auto-respond-messages: false
auto-respond-credential-proposal: true
auto-respond-credential-offer: true
auto-respond-credential-request: true
auto-respond-presentation-proposal: true
auto-respond-presentation-request: true
auto-store-credential: true
auto-verify-presentation: true
auto-ping-connection: true
auto-provision: true
monitor-ping: true
public-invites: true
31 changes: 31 additions & 0 deletions plugins/demo/docker-compose.devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.9"
services:
traction-db:
image: "postgres:12"
environment:
- POSTGRES_PASSWORD=postgresPass
ports:
- 5432:5432
volumes:
- traction-wallet:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5

tenant-proxy:
build:
context: ..
dockerfile: ./docker/Dockerfile.tenant-proxy
restart: unless-stopped
environment:
- ACAPY_ADMIN_URL=http://host.docker.internal:3001
- ACAPY_ADMIN_URL_API_KEY=change-me
ports:
- 8032:8080
extra_hosts:
- host.docker.internal:host-gateway

volumes:
traction-wallet:
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
"name": "tenant-ui",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-20",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers-contrib/features/vue-cli:2": {}
},
"customizations": {
"vscode": {
"extensions": [
"Vue.volar",
"esbenp.prettier-vscode"
]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"forwardPorts": [
8080
],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
"postCreateCommand": "bash ./.devcontainer/post-install.sh"

// Configure tool-specific properties.
// "customizations": {},
Expand Down
Loading

0 comments on commit 8baf3bf

Please sign in to comment.