Skip to content

Commit e5bfbf2

Browse files
committed
Add docker-compose file to start backend/frontend
1 parent 6e66f00 commit e5bfbf2

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

docker-compose.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: "3"
2+
services:
3+
postgres:
4+
image: postgres:9.6
5+
environment:
6+
POSTGRES_DB: cargo_registry
7+
POSTRES_USER: postgres
8+
POSTGRES_PASSWORD: password
9+
ports:
10+
- 5432:5432
11+
volumes:
12+
- postgres-data:/var/lib/postgresql/data
13+
backend:
14+
build:
15+
context: .
16+
dockerfile: backend.Dockerfile
17+
environment:
18+
DATABASE_URL: postgres://postgres:password@postgres/cargo_registry
19+
SESSION_KEY: badkeyabcdefghijklmnopqrstuvwxyzabcdef
20+
GIT_REPO_URL: file://./tmp/index-bare
21+
GIT_REPO_CHECKOUT: ./tmp/index-co
22+
GH_CLIENT_ID: ""
23+
GH_CLIENT_SECRET: ""
24+
links:
25+
- postgres
26+
ports:
27+
- 8888:8888
28+
volumes:
29+
# Mount the src/ directory so we don't have to rebuild the Docker image
30+
# when we want to change some code
31+
- ./src:/app/src
32+
- index:/app/tmp
33+
- cargo-cache:/app/target
34+
frontend:
35+
build:
36+
context: .
37+
dockerfile: frontend.Dockerfile
38+
entrypoint: yarn run start --proxy http://backend:8888
39+
links:
40+
- backend
41+
ports:
42+
- 4200:4200
43+
volumes:
44+
# Mount the app/ directory so live reload works
45+
- ./app:/app/app
46+
47+
volumes:
48+
postgres-data:
49+
cargo-cache:
50+
index:

docker_entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/sh
22

3-
diesel migration run
3+
# If the backend is started before postgres is ready, the migrations will fail
4+
until diesel migration run; do
5+
echo "Migrations failed, retrying in 5 seconds..."
6+
sleep 5
7+
done
8+
49
./script/init-local-index.sh
510

611
cargo run --bin server

0 commit comments

Comments
 (0)