Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Dockerise Colouring London #780

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
more docker experimenting (not working yet)
edwardchalstrey1 committed Mar 25, 2022
commit 709433d5c9c782a0242d188fc9bb0b22f4a1952a
33 changes: 33 additions & 0 deletions PostgresDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ubuntu/postgres:12-20.04_beta

RUN apt-get update -y
RUN apt-get upgrade -y

RUN apt-get install -y postgresql-contrib libpq-dev
RUN apt-get install -y postgis
RUN apt-get install -y postgresql-12-postgis-3
RUN apt-get install -y gdal-bin libspatialindex-dev libgeos-dev libproj-dev

RUN apt-get install -y python3 python3-pip python3-dev

RUN psql -d colouringlondon -U dockeruser -c "create extension postgis;"
RUN psql -d colouringlondon -U dockeruser -c "create extension pgcrypto;"
RUN psql -d colouringlondon -U dockeruser -c "create extension pg_trgm;"

# RUN mkdir /colouring-london
# COPY app /colouring-london/app
# COPY migrations /colouring-london/migrations
# COPY etl /colouring-london/etl

# RUN ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;

# RUN pip install --upgrade pip
# RUN pip install --upgrade setuptools wheel
# RUN pip install -r ./colouring-london/etl/requirements.txt

# RUN python ./colouring-london/etl/get_test_polygons.py
# RUN ./colouring-london/etl/load_geometries_cl.sh ./
# RUN psql -d colouringlondon -U dockeruser < ./colouring-london/app/migrations/002.index-geometries.up.sql
# RUN ./create_building_records_cl.sh
# RUN psql -d colouringlondon -U dockeruser < ./colouring-london/app/migrations/003.index-buildings.up.sql
# RUN ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -16,14 +16,19 @@ services:
- "8080:8080"
db:
container_name: postgres-colouring-london
# build:
# context: .
# dockerfile: PostgresDockerfile
image: ubuntu/postgres:12-20.04_beta
# image: postgis/postgis:12-3.2-alpine
ports:
- "5432:5432"
volumes:
- ./postgresdata:/var/lib/postgresql/data
- ./migrations:/colouring-london/migrations
- ./etl:/colouring-london/etl
# - ./migrations:/colouring-london/migrations
# - ./etl:/colouring-london/etl
- ./init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh
# - ./migrations/001.core.up.sql:/docker-entrypoint-initdb.d/001.core.up.sql
restart: always
environment:
POSTGRES_USER: dockeruser
13 changes: 5 additions & 8 deletions init-user-db.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -12,19 +12,16 @@ apt-get install -y python3 python3-pip python3-dev
# psql -d colouringlondon -U dockeruser -c "SELECT 1 FROM pg_user WHERE usename = 'dockeruser';" | grep -q 1 || psql -d colouringlondon -U dockeruser -c "CREATE ROLE dockeruser SUPERUSER LOGIN PASSWORD 'postgres';"
# psql -d colouringlondon -U dockeruser -c "SELECT 1 FROM pg_database WHERE datname = 'colouringlondon';" | grep -q 1 || -u postgres createdb -E UTF8 -T template0 --locale=en_US.utf8 -O dockeruser colouringlondon

psql -d colouringlondon -U dockeruser -c "create extension postgis;"
psql -d colouringlondon -U dockeruser -c "create extension pgcrypto;"
psql -d colouringlondon -U dockeruser -c "create extension pg_trgm;"
psql -c "create extension postgis;"
psql -c "create extension pgcrypto;"
psql -c "create extension pg_trgm;"

ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;
ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql < $migration; done;

pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r ./colouring-london/etl/requirements.txt

python ./colouring-london/etl/get_test_polygons.py
./colouring-london/etl/load_geometries_cl.sh ./
psql -d colouringlondon -U dockeruser < ./colouring-london/app/migrations/002.index-geometries.up.sql
./create_building_records_cl.sh
psql -d colouringlondon -U dockeruser < ./colouring-london/app/migrations/003.index-buildings.up.sql
ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;
./colouring-london/etl/create_building_records_cl.sh