Skip to content

Commit

Permalink
Use a SMALLINT for the postcode column in the DB, to save a bit of sp…
Browse files Browse the repository at this point in the history
…ace (#270)

* Use SMALLINT for postcode

* Use named build stages
  • Loading branch information
lyricnz authored Sep 22, 2023
1 parent 25e514b commit e158890
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions extra/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# STAGE 1: import the DB dump files then export a cutdown CSV file
FROM postgis/postgis:16-3.4-alpine
FROM postgis/postgis:16-3.4-alpine as import
ENV POSTGRES_HOST_AUTH_METHOD=trust

RUN mkdir -p /data
Expand All @@ -16,12 +16,12 @@ RUN bash -x /usr/local/bin/docker-entrypoint.sh postgres


# STAGE 2: load the CSV file from previous stage into right DB version (no PostGIS)
FROM postgres:16-alpine
FROM postgres:16-alpine as load
ENV POSTGRES_HOST_AUTH_METHOD=trust

RUN mkdir -p /data
WORKDIR /data
COPY --from=0 --chown=postgres /tmp/address_principals.csv.gz /data/
COPY --from=import --chown=postgres /tmp/address_principals.csv.gz /data/
ADD --chown=postgres create-table.sql /data/
ADD 20_import_csv.sh /docker-entrypoint-initdb.d/

Expand All @@ -31,8 +31,8 @@ RUN bash -x /usr/local/bin/docker-entrypoint.sh postgres


# STAGE 3: just use the data from the previous stage
FROM postgres:16-alpine
FROM postgres:16-alpine as final
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=password

COPY --from=1 --chown=postgres /var/lib/postgresql/data /var/lib/postgresql/data
COPY --from=load --chown=postgres /var/lib/postgresql/data /var/lib/postgresql/data
2 changes: 1 addition & 1 deletion extra/db/create-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE gnaf_cutdown.address_principals
gnaf_pid text NOT NULL,
address text NOT NULL,
locality_name text NOT NULL,
postcode text NULL,
postcode SMALLINT NULL,
state text NOT NULL,
latitude numeric(10,8) NOT NULL,
longitude numeric(11,8) NOT NULL
Expand Down

0 comments on commit e158890

Please sign in to comment.