Skip to content

Commit f355f37

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents f1acc4a + b1305a0 commit f355f37

File tree

5 files changed

+65
-59
lines changed

5 files changed

+65
-59
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fabric.properties
7878
config.cfg
7979
.DS_Store
8080
*.iml
81+
data/postgres/
8182

8283
parsed/
8384
rlreplays/

Dockerfile-python

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.6-alpine
2+
3+
WORKDIR /app
4+
5+
ENV DOCKERIZE_VERSION v0.6.1
6+
7+
ADD requirements.txt .
8+
9+
RUN apk --no-cache --update-cache add \
10+
build-base \
11+
freetype-dev \
12+
gcc \
13+
libpng-dev \
14+
musl-dev \
15+
postgresql-dev
16+
RUN pip install --no-cache-dir -r requirements.txt
17+
18+
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
19+
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
20+
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

README.md

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -47,68 +47,20 @@ The structure of the server is split into different directories:
4747

4848
### Basic Dependencies
4949

50-
- Install Python 3.6/pip
51-
- (Recommended) Create a virtual environment. todo(kcolton): finish + Pipfile
5250
- [Docker Community Edition (Stable)](https://docs.docker.com/install/)
5351

54-
Docker will run Postgres and Redis inside linux based "Containers" on most platforms.
55-
Download and install Docker for your platform:
52+
Docker will run Postgres, Redis, Flask, Celery, and Node inside linux based "Containers" on most platforms.
53+
Download and install Docker and Docker Compose for your platform:
5654
- [Mac/Windows: Docker Desktop](https://www.docker.com/products/docker-desktop)
5755
- [Ubuntu/Debian-ish: Docker CLI](https://docs.docker.com/install/linux/docker-ce/debian/#install-docker-ce)
58-
- Start Postgres and Redis containers:
59-
60-
```bash
61-
# Start Postgres and Redis. Anytime ran will automatically download latest versions.
62-
# Should be in project root directory (where docker-compose.yml is)
63-
docker-compose up
64-
65-
# See your containers running
66-
docker ps
67-
```
68-
69-
todo(kcolton): extended Docker docs
70-
- Install [NodeJS](https://nodejs.org/en/) - 8 LTS Recommended (10 likely works as well).
71-
72-
73-
### Python Requirements
74-
75-
- (Recommended) Activate virtual environment. todo(kcolton): finish
76-
- Install python requirements
77-
78-
```bash
79-
pip3 install -r requirements.txt
80-
```
81-
82-
### React Webapp requirements via `npm` (Node Package Manager)
8356

57+
### Run Everything
8458
```bash
85-
cd webapp
86-
# if not found, upgrade npm or use: npm install
87-
npm ci
88-
```
59+
# Start containers. Should be in project root directory (where docker-compose.yml is)
60+
docker-compose up
8961

90-
### Start Application
91-
92-
todo(kcolton): alternative start methods
93-
94-
- Flask (Web framework for Backend API)
95-
96-
```bash
97-
# inside activated virtual environment if cerated
98-
python3 RLBotServer.py
99-
```
100-
101-
- Celery (Background workers required for parsing replays and other tasks)
102-
103-
```bash
104-
# inside activated virtual environment if created
105-
celery -A backend.tasks.celery_tasks.celery worker --loglevel=INFO
106-
```
107-
108-
- React Web Frontend (Run on separate port, make calls to Backend API for data)
109-
110-
```bash
111-
cd webapp
112-
npm run start
113-
```
62+
# See your containers running
63+
docker ps
64+
```
11465

66+
Now go to `localhost:3000` and the site should be running.

docker-compose.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,51 @@ services:
77
restart: always
88
environment:
99
POSTGRES_PASSWORD: postgres
10+
network_mode: service:flask
1011
volumes:
1112
- "./data/postgres:/var/lib/postgresql/data"
12-
ports:
13-
- 5432:5432
1413

1514
redis:
1615
image: redis:4-alpine
1716
container_name: ccgg-redis4
1817
restart: always
18+
network_mode: service:flask
1919
volumes:
2020
- "./.data/redis:/data"
21+
22+
flask:
23+
build:
24+
context: .
25+
dockerfile: Dockerfile-python
26+
image: distributed-replays-python
27+
# The sleep is less than ideal but there seems to be a delay between
28+
# when dockerize can connect to postgres and when our backend can
29+
command: sh -c "dockerize -timeout 30s -wait tcp://localhost:5432 -wait tcp://localhost:6379 && sleep 3 && python ./RLBotServer.py"
30+
volumes:
31+
- ./:/app:rw
2132
ports:
33+
# This container handles exporting the ports for every other container
34+
# Those other containers link to this one
35+
- 3000:3000
36+
- 5432:5432
2237
- 6379:6379
38+
- 8000:8000
39+
40+
celery:
41+
image: distributed-replays-python
42+
command: sh -c "dockerize -wait tcp://localhost:6379 celery -A backend.tasks.celery_tasks.celery worker --loglevel=INFO"
43+
network_mode: service:flask
44+
volumes:
45+
- ./:/app:rw
46+
depends_on:
47+
- redis
48+
49+
webapp:
50+
image: node:10-alpine
51+
command: sh -c "cd /app && npm install && npm run start"
52+
network_mode: service:flask
53+
volumes:
54+
- ./webapp/:/app:rw
2355

2456
# rabbitmq:
2557
# image: rabbitmq:3-alpine

0 commit comments

Comments
 (0)