-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile
75 lines (45 loc) · 1.9 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
FROM alpine/git AS sources
# TODO - update the tag here
RUN git clone --branch=v2.1.1-rc3 https://github.com/onaio/express-server.git /usr/src/express-server
FROM node:16.18-alpine as build
COPY ./ /project
WORKDIR /project
ENV PATH /project/node_modules/.bin:$PATH
ENV NODE_OPTIONS --max_old_space_size=4096
RUN chown -R node .
USER node
RUN cp /project/app/.env.sample /project/app/.env \
&& yarn
USER root
RUN chown -R node .
USER node
RUN yarn lerna run build
FROM node:20-alpine as nodejsbuild
RUN corepack enable
COPY --from=sources /usr/src/express-server /usr/src/express-server
WORKDIR /usr/src/express-server
RUN yarn && yarn tsc && npm prune -production --legacy-peer-deps
# Remove unused dependencies
RUN rm -rf ./node_modules/typescript
FROM nikolaik/python-nodejs:python3.12-nodejs20-alpine as final
RUN corepack enable
# Use tini for NodeJS application https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals
RUN apk add --no-cache tini curl libmagic
# confd
RUN curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 \
&& chmod +x /usr/local/bin/confd
COPY ./docker/confd_env.toml /etc/confd/conf.d/appconfig.toml
COPY ./docker/config.js.tmpl /etc/confd/templates/config.js.tmpl
COPY ./docker/app.sh /usr/local/bin/app.sh
RUN chmod +x /usr/local/bin/app.sh
WORKDIR /usr/src/web
COPY --from=build /project/node_modules /usr/src/web/node_modules
COPY --from=build /project/app/build /usr/src/web
WORKDIR /usr/src/app
COPY --from=nodejsbuild /usr/src/express-server/build /usr/src/app
COPY --from=nodejsbuild /usr/src/express-server/node_modules /usr/src/app/node_modules
RUN pip install -r /usr/src/app/importer/requirements.txt
ENV EXPRESS_REACT_BUILD_PATH /usr/src/web/
EXPOSE 3000
CMD [ "/bin/sh", "-c", "/usr/local/bin/app.sh && node /usr/src/app/dist" ]
ENTRYPOINT ["/sbin/tini", "--"]