-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
85 lines (76 loc) · 2.62 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ARG BASE
FROM siose-innova/gdal:3.0.2 AS etl
ARG VERSION
ENV EXTENSION_VERSION=$VERSION
COPY ./src /usr/src/pg_runoff
RUN set -ex \
\
&& cd /usr/src/pg_runoff \
&& ogr2ogr -f "PGDUMP" --config PG_USE_COPY NO \
-sql "SELECT CAST(icn52 AS smallint), CAST(siose AS smallint) FROM hydro2siose" \
-nln hydro2siose \
-lco SCHEMA=@extschema@ \
-lco CREATE_SCHEMA=OFF \
-lco CREATE_TABLE=OFF \
-lco DROP_TABLE=OFF \
hydro2siose.sql hydro2siose.csv \
&& sed -i 's/"\@extschema\@"/\@extschema\@/' hydro2siose.sql \
&& sed -i -e '/^BEGIN/d' -e '/^COMMIT/d' hydro2siose.sql \
&& ogr2ogr -f "PGDUMP" --config PG_USE_COPY NO \
-sql "SELECT CAST(siose AS smallint), CAST(n AS float) FROM manning" \
-nln manning \
-lco SCHEMA=@extschema@ \
-lco CREATE_SCHEMA=OFF \
-lco CREATE_TABLE=OFF \
-lco DROP_TABLE=OFF \
manning.sql manning.csv \
&& sed -i 's/"\@extschema\@"/\@extschema\@/' manning.sql \
&& sed -i -e '/^BEGIN/d' -e '/^COMMIT/d' manning.sql \
&& ogr2ogr -f "PGDUMP" --config PG_USE_COPY NO \
-sql "SELECT CAST(icn52 AS smallint), CAST(slope_mod AS smallint), CAST(soil_mod AS smallint), CAST(p0 AS float) FROM p0" \
-nln p0 \
-lco SCHEMA=@extschema@ \
-lco CREATE_SCHEMA=OFF \
-lco CREATE_TABLE=OFF \
-lco DROP_TABLE=OFF \
p0.sql p0.csv \
&& sed -i 's/"\@extschema\@"/\@extschema\@/' p0.sql \
&& sed -i -e '/^BEGIN/d' -e '/^COMMIT/d' p0.sql \
&& cat hydro2siose.sql manning.sql p0.sql >> pg_runoff--${EXTENSION_VERSION}.sql.template
FROM golang:1.12.14-alpine3.9 AS builder
COPY ./go/src /go/src
RUN set -ex \
\
&& apk add --no-cache \
gcc \
libc-dev \
&& cd /go/src/runoff \
&& GOOS=linux GARCH=amd64 go build \
-ldflags "-linkmode external -extldflags -static" \
-installsuffix cgo \
-o runoff \
-a \
main.go
FROM $BASE
ARG VERSION
ENV EXTENSION_VERSION=$VERSION
ARG DB
ENV SIOSE_DB=$DB
ARG SCHEMA
ENV SIOSE_SCHEMA=$SCHEMA
ARG XNSCHEMA
ENV RUNOFF_SCHEMA=$XNSCHEMA
COPY --from=etl /usr/src/pg_runoff /usr/src/pg_runoff/.
COPY --from=builder /go/src/runoff/runoff /usr/local/bin/.
RUN set -ex \
\
&& apk add --no-cache --virtual .build-deps \
make \
&& cd /usr/src/pg_runoff \
&& make \
&& make install \
&& cd / \
&& rm -rf /usr/src/pg_runoff \
&& apk del .build-deps \
&& mkdir /data
VOLUME ["/data"]