-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows to quickly setup a database for an development setup
- Loading branch information
1 parent
6693fee
commit 800b7d3
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ARG POSTGRES_VERSION=13 | ||
FROM postgres:${POSTGRES_VERSION}-bookworm | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
ARG POSTGRES_VERSION | ||
ARG POSTGIS_VERSION=3 | ||
|
||
# Postgres password | ||
ENV POSTGRES_PASSWORD secret | ||
#DB name | ||
ENV DB_NAME fisumwelt | ||
#AUIK user and password | ||
ENV USERNAME auikadmin | ||
ENV USER_PW secret | ||
|
||
RUN apt-get update && apt-get install -y postgresql-${POSTGRES_VERSION}-postgis-${POSTGIS_VERSION} | ||
|
||
USER postgres | ||
|
||
#Copy init script | ||
COPY docker/init_db.sh /docker-entrypoint-initdb.d/ | ||
|
||
ADD data/db /opt/auik_db/ | ||
WORKDIR /opt/auik_db/ | ||
|
||
CMD ["/usr/local/bin/docker-entrypoint.sh","postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh -e | ||
echo "###Setting up database###" | ||
|
||
schema_dir=/opt/auik_db | ||
schema_file=$schema_dir/version1_0_schema.sql | ||
update_file_1_1_0=$schema_dir/updateTo_1_1_0.sql | ||
import_script=$schema_dir/import_csv.sql | ||
|
||
psql --command "CREATE DATABASE $DB_NAME;" >> /dev/null | ||
psql -d $DB_NAME --command "CREATE EXTENSION postgis;" >> /dev/null | ||
#Create user and assign roles | ||
psql -d $DB_NAME --command "CREATE USER ${USERNAME} with password '${USER_PW}';" >> /dev/null | ||
psql -d $DB_NAME --command "ALTER USER ${USERNAME} with superuser;" >> /dev/null | ||
|
||
echo "Database: $DB_NAME" | ||
echo "Example user(password): ${USERNAME}(${USER_PW})" | ||
|
||
echo "Applying schema" | ||
psql -d $DB_NAME -f $schema_file >> /dev/null | ||
psql -d $DB_NAME -f $update_file_1_1_0 >> /dev/null | ||
psql -d $DB_NAME -f $import_script | ||
|