-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (44 loc) · 2.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FROM osgeo/gdal:alpine-small-3.4.1 as gdal
WORKDIR /processing
COPY original_files /original_files
RUN ogr2ogr -f GeoJSON texas_counties.json -t_srs EPSG:4326 /original_files/texas_counties/texas_counties.shp
RUN ogr2ogr -f GeoJSON texas_census_tracts.json -t_srs EPSG:4326 /original_files/texas_census_tracts/census_tracts_2019.shp
RUN ogr2ogr -f GeoJSON dfps_regions.json -t_srs EPSG:4326 /original_files/texas_dfps_regions_2019/dfps_regions.shp
FROM morlov/tippecanoe:1.35.0 as tippecanoe
WORKDIR /result
COPY --from=gdal /processing/ /jsons
RUN mkdir -p county
RUN /usr/bin/tippecanoe --no-tile-compression --coalesce-densest-as-needed --maximum-tile-bytes=250000 --include GEO_ID -e /result/county/2019 -l singleLayer -n "county" /jsons/texas_counties.json
RUN mkdir -p tract
RUN /usr/bin/tippecanoe --no-tile-compression --coalesce-densest-as-needed --maximum-tile-bytes=250000 --include GEOID -e /result/tract/2019 -l singleLayer -n "tract" /jsons/texas_census_tracts.json
RUN mkdir -p dfps_region
RUN /usr/bin/tippecanoe --no-tile-compression --coalesce-densest-as-needed --maximum-tile-bytes=250000 --include Sheet1__Re -e /result/dfps_region/2019 -l singleLayer -n "dfps_region" /jsons/dfps_regions.json
FROM postgis/postgis:13-3.2 as postgis-data-builder
RUN apt update
RUN apt install -y postgis
RUN which shp2pgsql
WORKDIR /postgis_data
COPY original_files/ /original_files
RUN shp2pgsql -I -s 4326 /original_files/texas_counties/texas_counties.shp > counties.sql
RUN shp2pgsql -I -s 4326 /original_files/texas_census_tracts/census_tracts_2019.shp > census_tracts.sql
RUN shp2pgsql -I -s 4326 /original_files/texas_dfps_regions_2019/dfps_regions.shp > dfps_regions.sql
# Preload database (see https://cadu.dev/creating-a-docker-image-with-database-preloaded/)
FROM postgis/postgis:13-3.2 as postgis-init
# Add data for database init
COPY --from=postgis-data-builder /postgis_data/*.sql /docker-entrypoint-initdb.d/
# ensure posgres daemon will not start as we just want to load the data
RUN ["sed", "-i", "s/exec \"$@\"/echo \"skipping...\"/", "/usr/local/bin/docker-entrypoint.sh"]
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres
ENV POSTGRES_DB=postgres
ENV PGDATA=/data
# run postgres and load the data
RUN ["/usr/local/bin/docker-entrypoint.sh", "postgres"]
FROM postgis/postgis:13-3.2
WORKDIR /data
# Add the pre-loaded database
COPY --from=postgis-init /data $PGDATA
# Add uncompressed vector tiles that we created via tippecanoe/gdal
COPY --from=tippecanoe /result /data/vector
# Add non-processed outline of texas
ADD original_files/Texas_State_Boundary.geojson .