Skip to content

Commit 5be17d8

Browse files
committed
feat: working Terrastories with auto-migration on first run
1 parent 3df20a7 commit 5be17d8

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

docker/demo/.env.example

-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ SYNC_INSTALLERS_NAME=INSTALLERS-edt
2222
# Terrastories ENV
2323
MAPBOX_STYLE=mapbox://styles/mapbox/light-v10
2424
MAPBOX_ACCESS_TOKEN=your pk token here
25-
DB_USER_PASSWORD=postgres

docker/demo/docker-compose.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,20 @@ services:
106106
ports:
107107
- 5432:5432
108108
environment:
109-
POSTGRES_PASSWORD: ${DB_USER_PASSWORD}
109+
POSTGRES_USER: postgres
110+
POSTGRES_PASSWORD: postgres
111+
POSTGRES_DB: terrastories
110112
volumes:
111113
- "postgres_data:/var/lib/postgresql/data"
112114
restart: unless-stopped
113115
terrastories:
114-
image: terrastories/terrastories
116+
build: ../../services/terrastories
115117
ports:
116118
- 8083:3000
117119
depends_on:
118120
- db
119121
environment:
120-
DB_USER_PASSWORD: ${DB_USER_PASSWORD}
122+
DATABASE_URL: postgres://postgres:postgres@db:5432/terrastories
121123
RAILS_ENV: offline
122124
CHOKIDAR_USEPOLLING: 'true'
123125
USE_LOCAL_MAP_SERVER: 'true'

services/terrastories/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM terrastories/terrastories:latest
2+
COPY start.sh /srv
3+
ENTRYPOINT ["sh", "/srv/start.sh"]

services/terrastories/start.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
file=firstboot
4+
5+
if [ ! -e "$file" ] ; then
6+
echo "First run!"
7+
echo "================================"
8+
echo "Running migration"
9+
bin/rails db:migrate db:seed
10+
yarn
11+
touch "$file"
12+
fi
13+
14+
if [ ! -w "$file" ] ; then
15+
echo "Migration already happened!"
16+
exit 1
17+
fi
18+
scripts/server

0 commit comments

Comments
 (0)