diff --git a/backend/right_tree/settings.py b/backend/right_tree/settings.py index 4af7ea3..40ad1a8 100644 --- a/backend/right_tree/settings.py +++ b/backend/right_tree/settings.py @@ -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, } } diff --git a/default.env b/default.env new file mode 100644 index 0000000..aea3f76 --- /dev/null +++ b/default.env @@ -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 diff --git a/default.env b/default.env deleted file mode 100644 index 50a0a18..0000000 --- a/default.env +++ /dev/null @@ -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 \ No newline at end of file diff --git a/dev b/dev index c5ae9ec..a9b526c 100755 --- a/dev +++ b/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 } diff --git a/docker-compose.production copy.yaml b/docker-compose.production copy.yaml deleted file mode 100644 index f10be43..0000000 --- a/docker-compose.production copy.yaml +++ /dev/null @@ -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} - diff --git a/docker-compose.production.yaml b/docker-compose.production.yaml index 8f7181b..b742d1d 100644 --- a/docker-compose.production.yaml +++ b/docker-compose.production.yaml @@ -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