-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
71 lines (51 loc) · 1.83 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
# --- Multi-stage Docker build ---
# 1. Build runtime environment (see runtime/README.md)
# 2. Compile better-sqlite3 module
# 3. Run unit tests to confirm everything is ok
# 4. Produce a minimally sized image for distribution
# 1. ------------------------------------------------
FROM pelias/spatial:runtime_ubuntu_bionic as runtime
# 2. ------------------------------------------------
FROM pelias/baseimage as better_sqlite3
# we require clang++ for compiling better-sqlite3
# this adds ~400MB to the image, so we build in a
# separate image and only copy the files we need.
RUN apt-get update -y
RUN apt-get install -y clang python3 make
# copy runtime
COPY --from=runtime /opt/spatial /opt/spatial
# copy better-sqlite install script
COPY bin/compile_better_sqlite3 /code/bin/
# install better-sqlite3
WORKDIR /code
RUN bin/compile_better_sqlite3
# 3. ------------------------------------------------
FROM pelias/baseimage as testing
# copy runtime
COPY --from=runtime /opt/spatial /opt/spatial
# copy pre-installed better_sqlite3 from image above
COPY --from=better_sqlite3 /code/node_modules/better-sqlite3 /code/node_modules/better-sqlite3
# working directory
WORKDIR /code
# install npm dependencies
COPY package.json /code/
RUN npm i --ignore-scripts
# copy source files
COPY . /code
# run tests
RUN npm run env_check && npm t
# 4. ------------------------------------------------
FROM pelias/baseimage
# copy runtime
COPY --from=runtime /opt/spatial /opt/spatial
# copy pre-installed better_sqlite3 from image above
COPY --from=better_sqlite3 /code/node_modules/better-sqlite3 /code/node_modules/better-sqlite3
# working directory
WORKDIR /code
# install npm dependencies (production mode)
COPY package.json /code/
RUN npm i --production --ignore-scripts
# copy source files
COPY . /code
# entrypoint
ENTRYPOINT ["node", "bin/spatial.js"]