Skip to content

Commit 892f687

Browse files
committed
Added some information about run proxy spawn via docker-compose
1 parent 3ef2779 commit 892f687

File tree

3 files changed

+69
-14
lines changed

3 files changed

+69
-14
lines changed

Makefile

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Variables
22
PYTHONPATH := $(shell pwd)
33

4-
linter: format
5-
poetry run bandit . && poetry run flake8 . && poetry run black --check .
6-
7-
format:
8-
poetry run isort . && poetry run black .
9-
104
build:
115
poetry build
126

@@ -16,7 +10,7 @@ install:
1610
poetry install
1711

1812
test: clean
19-
@PYTHONPATH="${PYTHONPATH}" ENVIRONMENT=unittest poetry run -vvv coverage run -vvv -m pytest
13+
@PYTHONPATH="${PYTHONPATH}" ENVIRONMENT=unittest poetry run -vvv -m pytest
2014

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

3023
clean:
3124
@find . | egrep '.pyc|.pyo|pycache' | xargs rm -rf
@@ -37,3 +30,12 @@ clean:
3730
@rm -rf ./.mypy_cache
3831
@find . -name 'unit_test.db' -exec rm -r -f {} +
3932
@find . -name '.coverage' -exec rm -r -f {} +
33+
34+
run:
35+
poetry run python3 example/spawn_example.py
36+
37+
run-dependencies:
38+
docker-compose up -d && docker-compose logs -f
39+
40+
stop-dependencies:
41+
docker-compose down

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,55 @@ Then:
147147
poetry run python3 spawn_py_demo/main.py
148148
```
149149

150+
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.
151+
152+
```docker-compose
153+
version: "3.8"
154+
services:
155+
mariadb:
156+
image: mariadb
157+
environment:
158+
MYSQL_ROOT_PASSWORD: admin
159+
MYSQL_DATABASE: eigr-functions-db
160+
MYSQL_USER: admin
161+
MYSQL_PASSWORD: admin
162+
volumes:
163+
- mariadb:/var/lib/mysql
164+
ports:
165+
- "3307:3306"
166+
nats:
167+
image: nats:0.8.0
168+
entrypoint: "/gnatsd -DV"
169+
ports:
170+
- "8222:8222"
171+
- "4222:4222"
172+
spawn-proxy:
173+
build:
174+
context: https://github.com/eigr/spawn.git#main
175+
dockerfile: ./Dockerfile-proxy
176+
restart: always
177+
network_mode: "host"
178+
environment:
179+
SPAWN_USE_INTERNAL_NATS: "true"
180+
SPAWN_PUBSUB_ADAPTER: nats
181+
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE=
182+
PROXY_APP_NAME: spawn
183+
PROXY_CLUSTER_STRATEGY: gossip
184+
PROXY_DATABASE_PORT: 3307
185+
PROXY_DATABASE_TYPE: mariadb
186+
PROXY_HTTP_PORT: 9003
187+
USER_FUNCTION_PORT: 8091
188+
depends_on:
189+
- mariadb
190+
- nats
191+
networks:
192+
mysql-compose-network:
193+
driver: bridge
194+
volumes:
195+
mariadb:
196+
197+
```
198+
150199
And this is it to start! Now that you know the basics of local development, we can go a little further.
151200

152201
## Advanced Use Cases

docker-compose.yaml

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,24 @@ services:
2121
- "4222:4222"
2222

2323
spawn-proxy:
24-
image: eigr/spawn-proxy:1.0.0-rc.18
24+
build:
25+
context: https://github.com/eigr/spawn.git#main
26+
dockerfile: ./Dockerfile-proxy
2527
restart: always
28+
network_mode: "host"
2629
environment:
30+
SPAWN_USE_INTERNAL_NATS: "true"
31+
SPAWN_PUBSUB_ADAPTER: nats
32+
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE=
2733
PROXY_APP_NAME: spawn
2834
PROXY_CLUSTER_STRATEGY: gossip
29-
SPAWN_USE_INTERNAL_NATS: true
30-
SPAWN_PUBSUB_ADAPTER: nats
3135
PROXY_DATABASE_PORT: 3307
3236
PROXY_DATABASE_TYPE: mariadb
3337
PROXY_HTTP_PORT: 9003
3438
USER_FUNCTION_PORT: 8091
35-
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex
36-
ports:
37-
- "9003:9003"
39+
# depends_on:
40+
# - mariadb
41+
# - nats
3842

3943
networks:
4044
mysql-compose-network:

0 commit comments

Comments
 (0)