Skip to content

Commit

Permalink
Added some information about run proxy spawn via docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Aug 24, 2023
1 parent 3ef2779 commit 892f687
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 14 deletions.
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Variables
PYTHONPATH := $(shell pwd)

linter: format
poetry run bandit . && poetry run flake8 . && poetry run black --check .

format:
poetry run isort . && poetry run black .

build:
poetry build

Expand All @@ -16,7 +10,7 @@ install:
poetry install

test: clean
@PYTHONPATH="${PYTHONPATH}" ENVIRONMENT=unittest poetry run -vvv coverage run -vvv -m pytest
@PYTHONPATH="${PYTHONPATH}" ENVIRONMENT=unittest poetry run -vvv -m pytest

test-all:
@PYTHONPATH="${PYTHONPATH}" ENVIRONMENT=local python -m pytest tests
Expand All @@ -25,7 +19,6 @@ update-poetry-and-all-dependencies:
poetry self update
poetry self add poetry-plugin-up
poetry up --latest
opentelemetry-bootstrap -a install

clean:
@find . | egrep '.pyc|.pyo|pycache' | xargs rm -rf
Expand All @@ -37,3 +30,12 @@ clean:
@rm -rf ./.mypy_cache
@find . -name 'unit_test.db' -exec rm -r -f {} +
@find . -name '.coverage' -exec rm -r -f {} +

run:
poetry run python3 example/spawn_example.py

run-dependencies:
docker-compose up -d && docker-compose logs -f

stop-dependencies:
docker-compose down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,55 @@ Then:
poetry run python3 spawn_py_demo/main.py
```

But of course you will need to locally run the our Elixir proxy which will actually provide all the functionality for your Python application. One way to do this is to create a docker-compose file containing all the services that your application depends on, in this case, in addition to the Spawn proxy, it also has a database and possibly a nats broker if you want access to more advanced Spawn features.

```docker-compose
version: "3.8"
services:
mariadb:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: eigr-functions-db
MYSQL_USER: admin
MYSQL_PASSWORD: admin
volumes:
- mariadb:/var/lib/mysql
ports:
- "3307:3306"
nats:
image: nats:0.8.0
entrypoint: "/gnatsd -DV"
ports:
- "8222:8222"
- "4222:4222"
spawn-proxy:
build:
context: https://github.com/eigr/spawn.git#main
dockerfile: ./Dockerfile-proxy
restart: always
network_mode: "host"
environment:
SPAWN_USE_INTERNAL_NATS: "true"
SPAWN_PUBSUB_ADAPTER: nats
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE=
PROXY_APP_NAME: spawn
PROXY_CLUSTER_STRATEGY: gossip
PROXY_DATABASE_PORT: 3307
PROXY_DATABASE_TYPE: mariadb
PROXY_HTTP_PORT: 9003
USER_FUNCTION_PORT: 8091
depends_on:
- mariadb
- nats
networks:
mysql-compose-network:
driver: bridge
volumes:
mariadb:
```

And this is it to start! Now that you know the basics of local development, we can go a little further.

## Advanced Use Cases
Expand Down
16 changes: 10 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ services:
- "4222:4222"

spawn-proxy:
image: eigr/spawn-proxy:1.0.0-rc.18
build:
context: https://github.com/eigr/spawn.git#main
dockerfile: ./Dockerfile-proxy
restart: always
network_mode: "host"
environment:
SPAWN_USE_INTERNAL_NATS: "true"
SPAWN_PUBSUB_ADAPTER: nats
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE=
PROXY_APP_NAME: spawn
PROXY_CLUSTER_STRATEGY: gossip
SPAWN_USE_INTERNAL_NATS: true
SPAWN_PUBSUB_ADAPTER: nats
PROXY_DATABASE_PORT: 3307
PROXY_DATABASE_TYPE: mariadb
PROXY_HTTP_PORT: 9003
USER_FUNCTION_PORT: 8091
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex
ports:
- "9003:9003"
# depends_on:
# - mariadb
# - nats

networks:
mysql-compose-network:
Expand Down

0 comments on commit 892f687

Please sign in to comment.