blob: 3fed9cff8b8c7345eb1c0447446b00e3160dfec0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# snekbox
Python sandbox runners for executing code in isolation
# Dependencies
| dep | version (or greater) |
|--------|----------------------|
| python | 3.6.5 |
| pip | 10.0.1 |
| pipenv | 2018.05.18 |
| docker | 18.03.1-ce |
## Setup local test
install python packages
```bash
pipenv sync
```
Start a rabbitmq instance and get the container IP
```bash
docker run --name rmq -d rabbitmq:3.7.5-alpine
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' rmq
# expected output with default setting: 172.17.0.2
# If not, change the runner/config.py file to match
```
## Test the code
use two terminals!
```bash
#terminal 1
pipenv run python runner/consume.py
#terminal 2
pipenv run python runner/publish.py
```
The publish will put a message on the message queue
and the consumer will pick it up and do stuff
## Build and run the consumer in a container
```bash
docker build -t snekbox:latest -f docker/Dockerfile .
#terminal 1
docker run --name snekbox -d snekbox:latest
docker logs snekbox -f
#terminal 2
pipenv run python runner/publish.py
```
|