Skip to content

Commit

Permalink
Use custom Postgres password
Browse files Browse the repository at this point in the history
  • Loading branch information
frafra committed Feb 18, 2019
1 parent 518ce09 commit b6c75f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions scripts/spcgeonode/.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ADMIN_USERNAME=super
ADMIN_PASSWORD=duper
ADMIN_EMAIL=admin@example.com

# PostgreSQL superuser password
POSTGRES_PASSWORD=

# Django secret key (replace this by any complex and random string)
SECRET_KEY=1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ

Expand Down
5 changes: 4 additions & 1 deletion scripts/spcgeonode/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ x-common-django:
# hardcoded
- DEBUG=False
- DJANGO_SETTINGS_MODULE=geonode.settings
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres
- BROKER_URL=amqp://rabbitmq:5672
- STATIC_ROOT=/spcgeonode-static/
- MEDIA_ROOT=/spcgeonode-media/
Expand Down Expand Up @@ -109,6 +109,7 @@ services:
- HTTP_PORT=${HTTP_PORT}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres
volumes:
- geodatadir:/spcgeonode-geodatadir/
restart: on-failure
Expand Down Expand Up @@ -150,6 +151,8 @@ services:
# PostGIS database.
postgres:
image: mdillon/postgis:9.6-alpine
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- database:/var/lib/postgresql/data/
restart: on-failure
Expand Down
6 changes: 3 additions & 3 deletions scripts/spcgeonode/geoserver/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ echo "3. Wait for PostgreSQL to be ready and initialized"
# Wait for PostgreSQL
set +e
for i in $(seq 60); do
psql -h postgres -U postgres -c "SLECT client_id FROM oauth2_provider_application" &>/dev/null && break
psql "$DATABASE_URL" -c "ON_ERROR_STOP=1; SELECT client_id FROM oauth2_provider_application" &>/dev/null && break
sleep 1
done
if [ $? != 0 ]; then
Expand Down Expand Up @@ -102,8 +102,8 @@ set -e
# Edit /spcgeonode-geodatadir/security/filter/geonode-oauth2/config.xml

# Getting oauth keys and secrets from the database
CLIENT_ID=$(psql -h postgres -U postgres -c "SELECT client_id FROM oauth2_provider_application WHERE name='GeoServer'" -t | tr -d '[:space:]')
CLIENT_SECRET=$(psql -h postgres -U postgres -c "SELECT client_secret FROM oauth2_provider_application WHERE name='GeoServer'" -t | tr -d '[:space:]')
CLIENT_ID=$(psql "$DATABASE_URL" -c "SELECT client_id FROM oauth2_provider_application WHERE name='GeoServer'" -t | tr -d '[:space:]')
CLIENT_SECRET=$(psql "$DATABASE_URL" -c "SELECT client_secret FROM oauth2_provider_application WHERE name='GeoServer'" -t | tr -d '[:space:]')
if [ -z "$CLIENT_ID" ] || [ -z "$CLIENT_SECRET" ]; then
echo "Could not get OAuth2 ID and SECRET from database. Make sure Postgres container is started and Django has finished it's migrations."
exit 1
Expand Down

0 comments on commit b6c75f7

Please sign in to comment.