Production config fixes
- Deletes redundant files - Adds right-tree db env vars to default.env - Updates port mapping for docker-compose.production.yaml - Adjusts production methods in dev
This commit is contained in:
parent
e99cf44312
commit
ecc6e9eabe
6 changed files with 41 additions and 67 deletions
|
@ -85,10 +85,10 @@ WSGI_APPLICATION = 'right_tree.wsgi.application'
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||
'NAME': 'right_tree',
|
||||
'USER': os.getenv("POSTGRES_DB", "postgres"),
|
||||
'PASSWORD': os.getenv("POSTGRES_USER", "postgres"),
|
||||
'HOST': os.getenv("POSTGRES_PASSWORD", "postgres"),
|
||||
'NAME': os.getenv("RIGHTTREE_DB", "postgres"),
|
||||
'USER': os.getenv("RIGHTTREE_DB_USER", "postgres"),
|
||||
'PASSWORD': os.getenv("RIGHTTREE_DB_PASSWORD", "postgres"),
|
||||
'HOST': os.getenv("POSTGRES_DB", "postgres"),
|
||||
'PORT': 5432,
|
||||
}
|
||||
}
|
||||
|
|
21
default.env
Normal file
21
default.env
Normal file
|
@ -0,0 +1,21 @@
|
|||
# POSTGRES CONFIG
|
||||
# ---------------------------------
|
||||
POSTGRES_DB=postgres
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
|
||||
|
||||
# RIGHTTREE DATABASE CONFIG (for production)
|
||||
# ---------------------------------
|
||||
# RIGHTTREE_DB=righttree
|
||||
# RIGHTTREE_DB_USER=righttree_admin
|
||||
# RIGHTTREE_DB_PASSWORD=[YOUR_PASSWORD]
|
||||
|
||||
|
||||
# DJANGO BACKEND CONFIG (uncomment out the config below for production)
|
||||
# ---------------------------------
|
||||
LINZ_API_KEY=[YOUR_API_KEY]
|
||||
# FRONTEND_BASE_URL=righttree.maps.net.nz
|
||||
# DJANGO_DEBUG_MODE=False
|
||||
# DJANGO_SECRET_KEY=[YOUR_SECRETKEY]
|
||||
# BASE_URL=righttree.maps.net.nz
|
12
default.env
12
default.env
|
@ -1,12 +0,0 @@
|
|||
# POSTGRES CONFIG
|
||||
POSTGRES_DB=postgres
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
|
||||
# DJANGO BACKEND CONFIG
|
||||
LINZ_API_KEY=YOUR_API_KEY
|
||||
FRONTEND_BASE_URL=http://localhost:9000
|
||||
DJANGO_DEBUG_MODE=False
|
||||
DJANGO_SECRET_KEY=YOUR_DJANGO_SECRET_KEY
|
||||
|
||||
BASE_URL=localhost:9000
|
20
dev
20
dev
|
@ -40,7 +40,7 @@ cmd_load_shapefiles() {
|
|||
|
||||
cmd_create_plant_fixtures() {
|
||||
echo "Creates fixtures for plants using spreadsheet."
|
||||
docker-compose exec django-backend python manage.py createplantfixtures
|
||||
docker-compose exec backend python manage.py createplantfixtures
|
||||
}
|
||||
|
||||
cmd_reset_plants() {
|
||||
|
@ -94,14 +94,24 @@ cmd_start() {
|
|||
docker-compose up --remove-orphans
|
||||
}
|
||||
|
||||
cmd_create_staticfiles() {
|
||||
cmd_collectstatic() {
|
||||
docker-compose -f docker-compose.production.yaml build
|
||||
docker-compose run backend python manage.py collectstatic --no-input
|
||||
docker-compose run frontend npm run-script build
|
||||
docker-compose -f docker-compose.production.yaml run backend python manage.py collectstatic --no-input
|
||||
}
|
||||
|
||||
cmd_build_frontend() {
|
||||
docker run -v $PWD/frontend:/app -w /app node:16-alpine3.11 npm install
|
||||
docker run -v $PWD/frontend:/app -w /app node:16-alpine3.11 mkdir -p node_modules/.cache
|
||||
docker run -v $PWD/frontend:/app -w /app node:16-alpine3.11 chmod -R 777 node_modules/.cache
|
||||
docker run -v $PWD/frontend:/app -w /app node:16-alpine3.11 npm run build
|
||||
}
|
||||
|
||||
cmd_create_staticfiles() {
|
||||
cmd_collectstatic
|
||||
cmd_build_frontend
|
||||
}
|
||||
|
||||
cmd_build_production() {
|
||||
cmd_create_staticfiles
|
||||
docker-compose -f docker-compose.production.yaml build
|
||||
}
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
version: "3.8"
|
||||
|
||||
volumes:
|
||||
righttree-postgres-data:
|
||||
name: righttree-postgres-data
|
||||
|
||||
services:
|
||||
backend:
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: backend
|
||||
dockerfile: Dockerfile
|
||||
container_name: righttree-backend
|
||||
depends_on:
|
||||
- postgres
|
||||
env_file: .env
|
||||
ports:
|
||||
- "8000:8000"
|
||||
command: bash -c "gunicorn --bind 0.0.0.0:8000 right_tree.wsgi"
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: frontend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
container_name: righttree-frontend
|
||||
ports:
|
||||
- "3000:3000"
|
||||
working_dir: /app
|
||||
command: sh -c "serve -s build"
|
||||
|
||||
postgres:
|
||||
image: postgis/postgis:13-3.0
|
||||
restart: unless-stopped
|
||||
container_name: postgres
|
||||
volumes:
|
||||
- righttree-postgres-data:/var/lib/postgresql/data
|
||||
- ./create_database.sql:/docker-entrypoint-initdb.d/create_database.sql
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
|
@ -30,7 +30,7 @@ services:
|
|||
- ./frontend/build:/etc/nginx/html/build
|
||||
- ./keys:/etc/ssl/private/nginx
|
||||
ports:
|
||||
- "9000:80"
|
||||
- "80:80"
|
||||
|
||||
postgres:
|
||||
image: postgis/postgis:13-3.0
|
||||
|
|
Loading…
Reference in a new issue