blob: bd1278a114008f78fdf06dca7c9330880aba2f6a (
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
58
59
60
61
62
63
64
65
66
67
68
69
|
# 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 |
| docker-compose | 1.21.2 |
## Setup local test
install python packages
```bash
pipenv sync --dev
```
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
```
## Docker compose
Start all the containers with docker-compose
```bash
docker-compose up
```
this boots up rabbitmq, the snekbox and a webinterface on port 5000
`http://localhost:5000`
|