irongit

now prebuild with postgres

huncholanehuncholaneauthored
parent ee6d780commit 9a46fbaca3da0fd1ffd364e5a971a393c0061cdeBrowse files

7 files changed, +47 -9

+6-1.env
@@ -1,2 +1,7 @@
11 NGINX_HOST=localhost
2-DOMAIN=localhost
2+DOMAIN=localhost
3+POSTGRES_DB=postgres
4+POSTGRES_USER=postgres
5+POSTGRES_PASSWORD=postgres
6+POSTGRES_HOST=postgres
7+POSTGRES_PORT=5432
+2-1.gitignore
@@ -1 +1,2 @@
1-venv
1+venv
2+postgres
+4-3.vscode/settings.json
@@ -3,7 +3,8 @@
33 {
44 "splitTerminals": [
55 {
6- "name": "root"
6+ "name": "root",
7+ "commands": ["source venv/Scripts/activate"]
78 }
89 ]
910 },
@@ -23,11 +24,11 @@
2324 "splitTerminals": [
2425 {
2526 "name": "frontend",
26- "commands": ["cd rango/frontend"]
27+ "commands": ["source venv/Scripts/activate", "cd rango/frontend"]
2728 },
2829 {
2930 "name": "backend",
30- "commands": ["cd rango/backend"]
31+ "commands": ["source venv/Scripts/activate", "cd rango/backend"]
3132 }
3233 ]
3334 }
+10-2dev
@@ -7,6 +7,11 @@ if [ ! -d "venv" ]; then
77 # add NGINX_HOST and DOMAIN to venv/Scripts/activate
88 echo "export NGINX_HOST=localhost" >> venv/Scripts/activate
99 echo "export DOMAIN=localhost" >> venv/Scripts/activate
10+ echo "export POSTGRES_USER=postgres" >> venv/Scripts/activate
11+ echo "export POSTGRES_PASSWORD=postgres" >> venv/Scripts/activate
12+ echo "export POSTGRES_DB=postgres" >> venv/Scripts/activate
13+ echo "export POSTGRES_HOST=postgres" >> venv/Scripts/activate
14+ echo "export POSTGRES_PORT=5821" >> venv/Scripts/activate
1015 fi
1116
1217 # if first arg is var, add a variable to venv/Scripts/activate
@@ -25,10 +30,13 @@ if [ "$1" = "back" ]; then
2530 # build the frontend
2631 cd rango/frontend
2732 npm run build
28- cd ..
33+ cd ../..
34+
35+ # compose up the dev compose file
36+ docker compose -f dev-compose.yml up -d
2937
3038 # create secret key
31- cd backend
39+ cd rango/backend
3240 python manage.py createsecret
3341
3442 # migrate database
+9-0dev-compose.yml
@@ -0,0 +1,9 @@
1+services:
2+ postgres:
3+ image: postgres:14.6-alpine
4+ ports:
5+ - "5821:5432"
6+ volumes:
7+ - ./postgres/data:/var/lib/postgresql/data
8+ env_file:
9+ - .env
+10-0docker-compose.yml
@@ -1,9 +1,12 @@
11 services:
22 rango:
33 build: rango
4+ restart: always
45 volumes:
56 - assets:/rango/assets
67 - media:/rango/media
8+ depends_on:
9+ - db
710
811 nginx:
912 image: nginx:1.23.3-alpine
@@ -20,6 +23,13 @@ services:
2023 env_file:
2124 - .env
2225
26+ postgres:
27+ image: postgres:14.6-alpine
28+ volumes:
29+ - ./postgres/data:/var/lib/postgresql/data
30+ env_file:
31+ - .env
32+
2333 volumes:
2434 assets:
2535 name: rango_assets
+6-2rango/backend/backend/settings.py
@@ -87,8 +87,12 @@ WSGI_APPLICATION = 'backend.wsgi.application'
8787
8888 DATABASES = {
8989 'default': {
90- 'ENGINE': 'django.db.backends.sqlite3',
91- 'NAME': BASE_DIR / 'db.sqlite3',
90+ 'ENGINE': 'django.db.backends.postgresql',
91+ 'NAME': os.environ.get('POSTGRES_DB'),
92+ 'USER': os.environ.get('POSTGRES_USER'),
93+ 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
94+ 'HOST': os.environ.get('POSTGRES_HOST'),
95+ 'PORT': os.environ.get('POSTGRES_PORT'),
9296 }
9397 }
9498