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

feat: mediator configuration #17

Merged
merged 1 commit into from
Apr 12, 2022
Merged
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
26 changes: 15 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
FROM bcgovimages/von-image:py36-1.16-1
FROM bcgovimages/von-image:py36-1.16-1 AS base

# Install and configure poetry
USER root
ENV POETRY_HOME=/opt/poetry \
VENV=/usr/src/app/.venv
ENV PATH="$POETRY_HOME/bin:$VENV/bin:$PATH"

RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
RUN poetry config virtualenvs.create true; poetry config virtualenvs.in-project true
ENV POETRY_VERSION=1.1.11
ENV POETRY_HOME=/opt/poetry
RUN curl -sSL https://install.python-poetry.org | python -

RUN mkdir acapy_plugin_pickup && touch acapy_plugin_pickup/__init__.py
COPY README.md setup.py pyproject.toml poetry.lock ./
ENV PATH="/opt/poetry/bin:$PATH"
RUN poetry config virtualenvs.in-project true

# Setup project
RUN mkdir acapy_plugin_pickup && touch acapy_plugin_pickup/__init__.py
COPY pyproject.toml poetry.lock README.md ./
RUN poetry install --no-dev -E indy
USER $user

# Make site packages location more accessible (for use with volumes)
RUN ln -s $(poetry env info -p)/lib/python3.6/site-packages site-packages
FROM bcgovimages/von-image:py36-1.16-1
COPY --from=base /home/indy/.venv /home/indy/.venv
ENV PATH="/home/indy/.venv/bin:$PATH"
EXPOSE 80

COPY docker/default.yml .
COPY acapy_plugin_pickup/ acapy_plugin_pickup/

ENTRYPOINT ["/bin/bash", "-c", "poetry run aca-py \"$@\"", "--"]
ENTRYPOINT ["/bin/bash", "-c", "aca-py \"$@\"", "--"]
CMD ["start", "--arg-file", "default.yml"]
14 changes: 14 additions & 0 deletions docker/acapy-endpoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

TUNNEL_ENDPOINT=${TUNNEL_ENDPOINT:-http://tunnel:4040}

while [[ "$(curl -s -o /dev/null -w '%{http_code}' "${TUNNEL_ENDPOINT}/status")" != "200" ]]; do
echo "Waiting for tunnel..."
sleep 1
done
ACAPY_ENDPOINT=$(curl --silent "${TUNNEL_ENDPOINT}/start" | python -c "import sys, json; print(json.load(sys.stdin)['url'])")
echo "fetched end point [$ACAPY_ENDPOINT]"

export ACAPY_ENDPOINT="[$ACAPY_ENDPOINT, ${ACAPY_ENDPOINT/http/ws}/ws]"
#export ACAPY_ENDPOINT="$ACAPY_ENDPOINT"
exec "$@"
1 change: 1 addition & 0 deletions docker/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugin:
# Transport
inbound-transport:
- [http, 0.0.0.0, 3000]
- [ws, 0.0.0.0, 3002]
outbound-transport: http
endpoint:
- http://localhost:3000
Expand Down
30 changes: 30 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3"
services:
tunnel:
image: dbluhm/agent-tunnel
command: -s reverse-proxy:80 -p 4040 -h ${AGENT_TUNNEL_HOST}
ports:
- 4040:4040
agent:
image: acapy-pickup-mediator
build:
context: ..
dockerfile: ./docker/Dockerfile
volumes:
- ./acapy-endpoint.sh:/acapy-endpoint.sh:ro,z
environment:
TUNNEL_ENDPOINT: http://tunnel:4040
entrypoint: >
/bin/sh -c '/acapy-endpoint.sh aca-py "$$@"' --
command: >
start --arg-file default.yml
reverse-proxy:
image: nginx:alpine
restart: unless-stopped
environment:
AGENT_HTTP: "http://agent:3000"
AGENT_WS: "http://agent:3002"
ports:
- 80:80
volumes:
- ./mediator.conf.template:/etc/nginx/templates/default.conf.template:z
15 changes: 15 additions & 0 deletions docker/mediator.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
client_max_body_size 10M;
listen 80;

location / {
proxy_pass ${AGENT_HTTP};
}

location /ws {
proxy_pass ${AGENT_WS}/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}