-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
58 lines (39 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
FROM node:20.18.0-alpine As deps
WORKDIR /usr/src/app
COPY --chown=root:root ./yarn.lock ./
COPY --chown=root:root ./package.json ./
COPY --chown=root:root ./node-red-contrib-c8y-client/package.json ./node-red-contrib-c8y-client/
COPY --chown=root:root ./node-red-c8y-storage-plugin/package.json ./node-red-c8y-storage-plugin/
RUN yarn install --frozen-lockfile --immutable --non-interactive --prefer-offline
USER root
FROM node:20.18.0-alpine As build
WORKDIR /usr/src/app
COPY --chown=root:root ./ ./
#COPY --chown=root:root --from=deps /usr/src/app/node-red-contrib-c8y-client/node_modules/ ./node-red-contrib-c8y-client/node_modules/
#COPY --chown=root:root --from=deps /usr/src/app/node-red-c8y-storage-plugin/node_modules/ ./node-red-c8y-storage-plugin/node_modules/
COPY --chown=root:root --from=deps /usr/src/app/node_modules/ ./node_modules/
RUN yarn run build
USER root
FROM node:20.18.0-alpine As prodDeps
WORKDIR /usr/src/app
COPY --chown=root:root ./yarn.lock ./
COPY --chown=root:root ./package.json ./
COPY --chown=root:root ./node-red-contrib-c8y-client/package.json ./node-red-contrib-c8y-client/
COPY --chown=root:root ./node-red-c8y-storage-plugin/package.json ./node-red-c8y-storage-plugin/
ENV NODE_ENV production
ENV NO_COLOR true
RUN yarn install --frozen-lockfile --immutable --non-interactive --prefer-offline --production && yarn cache clean --force
USER root
FROM node:20.18.0-alpine As prod
WORKDIR /usr/src/app
COPY --chown=root:root --from=prodDeps /usr/src/app/ ./
COPY --chown=root:root ./ ./
#COPY --chown=root:root --from=build /usr/src/app/node-red-contrib-c8y-client/dist/ ./node-red-contrib-c8y-client/dist/
COPY --chown=root:root --from=build /usr/src/app/node-red-c8y-storage-plugin/lib/ ./node-red-c8y-storage-plugin/lib/
ENV NODE_ENV production
ENV NO_COLOR true
# https://github.com/npm/cli/issues/4095
RUN chown -R root:root /usr/src/app
USER root
CMD [ "yarn", "start" ]
EXPOSE 80