Skip to content

Commit fd8f75f

Browse files
Merge pull request #107 from geoCML/config-file
Configure geoCML with scripts
2 parents 3dabc79 + dd8358f commit fd8f75f

File tree

10 files changed

+51
-10
lines changed

10 files changed

+51
-10
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export GEOCML_POSTGRES_PASSWORD=XXXXXXX
2+
export GEOCML_POSTGRES_ADMIN_PASSWORD=XXXXXXX
3+
export GEOCML_DESKTOP_PASSWORD=XXXXXXX
4+
export DRGON_HOST=XXXXXXX # Optional; only required if you are registering your deployment publicly on a DRGON instance
5+
export DRGON_API_KEY=XXXXXXX # Optional; only required if you are registering your deployment publicly on a DRGON instance
6+
export GEOCML_DEPLOYMENT_HOST=XXXXXXX # Optional; only required if you are hosting your deployment publicly

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ persistence-layer/*
33
!persistence-layer/geocml-project.qgz
44
!persistence-layer/portal-config.yaml
55
!persistence-layer/DBBackups
6-
**/__pycache__/**
6+
**/__pycache__/**
7+
.env

Dockerfiles/Dockerfile.geocml-postgres

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM ubuntu:22.04
22
USER root
33

4+
ARG GEOCML_POSTGRES_PASSWORD="geocml"
5+
ARG GEOCML_POSTGRES_ADMIN_PASSWORD="admin"
46
RUN apt update
57

68
# Install sudo (required by Ansible)
@@ -32,4 +34,4 @@ RUN pip uninstall -y psycopg2-binary && apt remove -y python3-pip
3234
# Remove install cache
3335
RUN apt clean autoclean && apt autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/
3436

35-
CMD service postgresql start && tail -f /dev/null
37+
CMD service postgresql start && tail -f /dev/null

ansible-playbooks/geocml-postgres-playbook.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
create: yes
2222
- name: Set postgres' password
2323
become_user: postgres
24-
community.postgresql.postgresql_query:
25-
query: ALTER USER postgres PASSWORD 'admin';
24+
community.postgresql.postgresql_user:
25+
name: postgres
26+
password: "{{ lookup('env', 'GEOCML_POSTGRES_ADMIN_PASSWORD') }}"
2627
- name: Create new Postgres user
2728
become_user: postgres
2829
community.postgresql.postgresql_user:
2930
name: geocml
30-
password: geocml
31+
password: "{{ lookup('env', 'GEOCML_POSTGRES_PASSWORD') }}"
3132
role_attr_flags: "CREATEDB,NOSUPERUSER"
3233
- name: Create new Postgres database
3334
become_user: postgres

build-resources/geocml-task-scheduler/geocml-task-scheduler/backup_geocml_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def backup_geocml_db():
1212
try:
1313
conn = psycopg2.connect(dbname="geocml_db",
1414
user="postgres",
15-
password="admin",
15+
password=os.environ["GEOCML_POSTGRES_ADMIN_PASSWORD"],
1616
host="geocml-postgres",
1717
port=5432)
1818
except psycopg2.OperationalError:
@@ -26,7 +26,7 @@ def backup_geocml_db():
2626

2727
# Write table schemata to .tabor file
2828
out = subprocess.run(["tabor", "write", "--db", "geocml_db",
29-
"--username", "geocml", "--password", "geocml",
29+
"--username", "geocml", "--password", os.environ["GEOCML_POSTGRES_PASSWORD"],
3030
"--host", "geocml-postgres",
3131
"--file", os.path.join(path_to_backup_dir, "geocml_db.tabor")],
3232
capture_output=True)

build-resources/geocml-task-scheduler/geocml-task-scheduler/restore_geocml_db_from_backups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def restore_geocml_db_from_backups():
1010
try:
1111
conn = psycopg2.connect(dbname="geocml_db",
1212
user="postgres",
13-
password="admin",
13+
password=os.environ["GEOCML_POSTGRES_ADMIN_PASSWORD"],
1414
host="geocml-postgres",
1515
port=5432)
1616
except psycopg2.OperationalError:
@@ -39,7 +39,7 @@ def restore_geocml_db_from_backups():
3939

4040
# Rebuild tables from .tabor file
4141

42-
out = subprocess.run(["tabor", "load", "--file", os.path.join(most_recent_backup, "geocml_db.tabor"), "--db", "geocml_db", "--host", "geocml-postgres", "--username", "postgres", "--password", "admin"], capture_output=True)
42+
out = subprocess.run(["tabor", "load", "--file", os.path.join(most_recent_backup, "geocml_db.tabor"), "--db", "geocml_db", "--host", "geocml-postgres", "--username", "postgres", "--password", os.environ["GEOCML_POSTGRES_ADMIN_PASSWORD"]], capture_output=True)
4343
if out.stderr:
4444
log("Failed to load tables from .tabor file")
4545
return 0

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
echo "Starting up geoCML... this should only take a few minutes."
2+
sh .env
3+
4+
command -v docker | export DOCKER_INSTALLED=$?
5+
6+
if [[ $DOCKER_INSTALLED -ne 0 ]]; then
7+
echo "Error: Docker is not installed on this machine."
8+
exit 1
9+
fi
10+
11+
docker compose build --build-arg GEOCML_POSTGRES_PASSWORD --build-arg GEOCML_POSTGRES_ADMIN_PASSWORD
12+
13+
echo "Done! You can start your geoCML instance by running the 'start.sh' script."
14+
exit 0
15+

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ services:
1212
DRGON_API_KEY: ${DRGON_API_KEY}
1313
DRGON_HOST: ${DRGON_HOST}
1414
GEOCML_DEPLOYMENT_HOST: ${GEOCML_DEPLOYMENT_HOST}
15+
GEOCML_POSTGRES_PASSWORD: ${GEOCML_POSTGRES_PASSWORD}
16+
GEOCML_POSTGRES_ADMIN_PASSWORD: ${GEOCML_POSTGRES_ADMIN_PASSWORD}
1517
networks:
1618
- geocml-network
1719
volumes:

persistence-layer/_README

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ DBBackups is used to store sql backup files from geocml_db
44

55
geocml-project.qgz is the default project configured with this deployment. Remember that geoCML deployments, by design, only host a single project/dataset. For multiple projects, it is very strongly recommended that you deploy multiple geoCML instances.
66

7-
Use portal-config.yaml to configure your geoCML Server Portal.

start.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
echo "Starting up geoCML... this should only take a moment."
2+
sh .env
3+
4+
command -v docker | export DOCKER_INSTALLED=$?
5+
6+
if [[ $DOCKER_INSTALLED -ne 0 ]]; then
7+
echo "Error: Docker is not installed on this machine."
8+
exit 1
9+
fi
10+
11+
docker compose up -d
12+
13+
echo "Done! You can stop your geoCML instance at any time with 'docker compose down'."
14+
exit 0
15+

0 commit comments

Comments
 (0)