Skip to content
Snippets Groups Projects
Commit 9ed1d689 authored by Sam Roberts's avatar Sam Roberts
Browse files

remove unneeded postgres setup in docker compose (sqlite is fine)

parent 245742a8
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,7 @@ logging = true
[database]
# Either "mysql", "postgres" or "sqlite3", it's your choice
type = postgres
host = postgres
type = sqlite3
name = grafana
user = grafana
password = grafana
......
......@@ -10,17 +10,4 @@ services:
- ./config:/etc/grafana/
environment:
- GF_INSTALL_PLUGINS=grafana-simple-json-datasource
postgres:
restart: always
build:
context: .
args:
DBUSER: grafana
DBPASS: grafana
DBNAME: grafana
hostname: postgres
ports:
- "5432:5432"
volumes:
- ./postgresdata:/var/lib/postgresql:z
#!/bin/sh
# Entrypoint for the containerized database
# Ensures the required setup is performed on the share before
# starting the database
if [ "$PGDATA" = "" ]
then
echo "Environment variable PGDATA is not set"
exit 1
fi
if [ ! -d "$PGDATA" ]
then
echo "Directory $PGDATA does not exist - no volume mounted?"
exit 2
fi
# Postgres will refuse to work on a non-empty folder when initializing and the
# mount point might have a dotfile
PGDATA="$PGDATA/9.6"
echo $PGDATA
echo $DBNAME
echo $DBUSER
if [ ! -d "$PGDATA" ]
then
echo "Database seems to be uninitialized - doing so"
mkdir $PGDATA
initdb --pgdata=$PGDATA && \
pg_ctl start && \
sleep 4 && \
createuser -d -l -s $DBUSER && \
createdb -O $DBUSER $DBNAME && \
psql -c "ALTER ROLE $DBUSER WITH PASSWORD '$DBPASS'" && \
psql -a $DBNAME -c 'CREATE EXTENSION "uuid-ossp" WITH SCHEMA pg_catalog' && \
echo "host all all all md5" >> $PGDATA/pg_hba.conf && \
echo "listen_addresses = '0.0.0.0'" >> $PGDATA/postgresql.conf && \
pg_ctl stop
fi
exec /usr/bin/postgres
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment