now prebuild with postgres
7 files changed, +47 -9
+6-1.env
| @@ -1,2 +1,7 @@ | ||
| 1 | 1 | 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 @@ | ||
| 3 | 3 | { |
| 4 | 4 | "splitTerminals": [ |
| 5 | 5 | { |
| 6 | - "name": "root" | |
| 6 | + "name": "root", | |
| 7 | + "commands": ["source venv/Scripts/activate"] | |
| 7 | 8 | } |
| 8 | 9 | ] |
| 9 | 10 | }, |
| @@ -23,11 +24,11 @@ | ||
| 23 | 24 | "splitTerminals": [ |
| 24 | 25 | { |
| 25 | 26 | "name": "frontend", |
| 26 | - "commands": ["cd rango/frontend"] | |
| 27 | + "commands": ["source venv/Scripts/activate", "cd rango/frontend"] | |
| 27 | 28 | }, |
| 28 | 29 | { |
| 29 | 30 | "name": "backend", |
| 30 | - "commands": ["cd rango/backend"] | |
| 31 | + "commands": ["source venv/Scripts/activate", "cd rango/backend"] | |
| 31 | 32 | } |
| 32 | 33 | ] |
| 33 | 34 | } |
+10-2dev
| @@ -7,6 +7,11 @@ if [ ! -d "venv" ]; then | ||
| 7 | 7 | # add NGINX_HOST and DOMAIN to venv/Scripts/activate |
| 8 | 8 | echo "export NGINX_HOST=localhost" >> venv/Scripts/activate |
| 9 | 9 | 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 | |
| 10 | 15 | fi |
| 11 | 16 | |
| 12 | 17 | # if first arg is var, add a variable to venv/Scripts/activate |
| @@ -25,10 +30,13 @@ if [ "$1" = "back" ]; then | ||
| 25 | 30 | # build the frontend |
| 26 | 31 | cd rango/frontend |
| 27 | 32 | npm run build |
| 28 | - cd .. | |
| 33 | + cd ../.. | |
| 34 | + | |
| 35 | + # compose up the dev compose file | |
| 36 | + docker compose -f dev-compose.yml up -d | |
| 29 | 37 | |
| 30 | 38 | # create secret key |
| 31 | - cd backend | |
| 39 | + cd rango/backend | |
| 32 | 40 | python manage.py createsecret |
| 33 | 41 | |
| 34 | 42 | # 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 @@ | ||
| 1 | 1 | services: |
| 2 | 2 | rango: |
| 3 | 3 | build: rango |
| 4 | + restart: always | |
| 4 | 5 | volumes: |
| 5 | 6 | - assets:/rango/assets |
| 6 | 7 | - media:/rango/media |
| 8 | + depends_on: | |
| 9 | + - db | |
| 7 | 10 | |
| 8 | 11 | nginx: |
| 9 | 12 | image: nginx:1.23.3-alpine |
| @@ -20,6 +23,13 @@ services: | ||
| 20 | 23 | env_file: |
| 21 | 24 | - .env |
| 22 | 25 | |
| 26 | + postgres: | |
| 27 | + image: postgres:14.6-alpine | |
| 28 | + volumes: | |
| 29 | + - ./postgres/data:/var/lib/postgresql/data | |
| 30 | + env_file: | |
| 31 | + - .env | |
| 32 | + | |
| 23 | 33 | volumes: |
| 24 | 34 | assets: |
| 25 | 35 | name: rango_assets |
+6-2rango/backend/backend/settings.py
| @@ -87,8 +87,12 @@ WSGI_APPLICATION = 'backend.wsgi.application' | ||
| 87 | 87 | |
| 88 | 88 | DATABASES = { |
| 89 | 89 | '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'), | |
| 92 | 96 | } |
| 93 | 97 | } |
| 94 | 98 |