forked from compdemocracy/polis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (33 loc) · 1.18 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
# To build locally, for example:
# docker build -t polis-server:local .
# To run locally, for example:
# docker run --rm --name polis-server --env-file .env --network polis-dev_polis-net \
# -p 5000:5000 --target dev polis-server:local
#
# For a dev build, use `--target dev`.
# Should default to prod build, but you can also explicitly use `--target prod`
FROM docker.io/node:18-alpine as base
ARG NODE_ENV
WORKDIR /app
# This package is needed at runtime
RUN apk add libpq-dev
RUN apk add --no-cache --virtual .build \
g++ make python3
COPY package*.json ./
EXPOSE 5000
# Define the development build
FROM base as dev
# Set default NODE_ENV to development unless overridden at build time with --build-arg NODE_ENV=production
ENV NODE_ENV ${NODE_ENV:-development}
COPY . .
CMD npm run dev
# Define the production build
FROM base as prod
# Set default NODE_ENV to production unless overridden at build time with --build-arg NODE_ENV=development
ENV NODE_ENV ${NODE_ENV:-production}
RUN npm ci --production=false
# For prod builds, to minimize the image size, remove the dependencies tagged with `--virtual .build` above.
RUN apk del .build
COPY . .
RUN npm run build
CMD npm run serve