forked from ohmyform/ohmyform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (37 loc) · 1.15 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
## Build API
FROM node:12-alpine as api
WORKDIR /usr/src/app
COPY ui/ .
RUN yarn install --frozen-lockfile
RUN yarn export
## Build APP
FROM node:12-alpine as app
LABEL maintainer="OhMyForm <[email protected]>"
WORKDIR /usr/src/app
RUN apk update && apk add curl bash && rm -rf /var/cache/apk/*
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
COPY api/ .
COPY --from=api /usr/src/app/out /usr/src/app/public
RUN yarn install --frozen-lockfile
RUN yarn build
# remove development dependencies
RUN npm prune --production
# run node prune
RUN /usr/local/bin/node-prune
## Glue
RUN touch /usr/src/app/src/schema.gql && chown 9999:9999 /usr/src/app/src/schema.gql
## Production Image.
FROM node:12-alpine
WORKDIR /usr/src/app
COPY --from=app /usr/src/app /usr/src/app
RUN addgroup --gid 9999 ohmyform && adduser -D --uid 9999 -G ohmyform ohmyform
ENV PORT=3000 \
SECRET_KEY=ChangeMe \
CREATE_ADMIN=FALSE \
ADMIN_USERNAME=root \
ADMIN_PASSWORD=root
EXPOSE 3000
USER ohmyform
CMD [ "yarn", "start:prod" ]