forked from Maintainerr/Maintainerr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
101 lines (69 loc) · 3 KB
/
Dockerfile
File metadata and controls
101 lines (69 loc) · 3 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
FROM node:24.14.0-alpine3.22@sha256:76db75ca7e7da9148ae42c92d9be12d12a8d7b03e171f18339355d8078d644a0 AS base
LABEL Description="Contains the Maintainerr Docker image"
FROM base AS builder
WORKDIR /app
RUN corepack enable
# Copy only files needed to resolve/install dependencies first (better Docker layer caching)
COPY package.json yarn.lock .yarnrc.yml turbo.json ./
RUN corepack install
COPY .yarn/releases ./.yarn/releases
COPY apps/server/package.json ./apps/server/package.json
COPY apps/ui/package.json ./apps/ui/package.json
COPY packages/contracts/package.json ./packages/contracts/package.json
RUN yarn install --network-timeout 99999999
# Copy the rest of the repository after deps are installed
COPY . .
RUN <<EOF cat >> ./apps/ui/.env
VITE_BASE_PATH=/__PATH_PREFIX__
EOF
RUN yarn turbo build
# Only install production dependencies to reduce image size
RUN yarn workspaces focus --all --production
# When all packages are hoisted, there is no node_modules folder. Ensure these folders always have a node_modules folder to COPY later on.
RUN mkdir -p ./packages/contracts/node_modules
RUN mkdir -p ./apps/server/node_modules
FROM base AS runner
WORKDIR /opt/app
# copy root node_modules
COPY --from=builder --chmod=777 --chown=node:node /app/node_modules ./node_modules
# Copy standalone server
COPY --from=builder --chmod=777 --chown=node:node /app/apps/server/dist ./apps/server/dist
COPY --from=builder --chmod=777 --chown=node:node /app/apps/server/package.json ./apps/server/package.json
COPY --from=builder --chmod=777 --chown=node:node /app/apps/server/node_modules ./apps/server/node_modules
# copy UI output to API to be served statically
COPY --from=builder --chmod=777 --chown=node:node /app/apps/ui/dist ./apps/server/dist/ui
# Copy packages/contracts
COPY --from=builder --chmod=777 --chown=node:node /app/packages/contracts/dist ./packages/contracts/dist
COPY --from=builder --chmod=777 --chown=node:node /app/packages/contracts/package.json ./packages/contracts/package.json
COPY --from=builder --chmod=777 --chown=node:node /app/packages/contracts/node_modules ./packages/contracts/node_modules
COPY --chmod=777 --chown=node:node docker/start.sh /opt/app/start.sh
# Create required directories
RUN mkdir -m 777 /opt/data && \
mkdir -m 777 /opt/data/logs && \
chown -R node:node /opt/data
# This is required for docker user directive to work
RUN chmod 777 /opt/app/start.sh
RUN apk --update --no-cache add curl
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
ARG DEBUG=false
ENV DEBUG=${DEBUG}
ARG UI_PORT=6246
ENV UI_PORT=${UI_PORT}
ARG UI_HOSTNAME=0.0.0.0
ENV UI_HOSTNAME=${UI_HOSTNAME}
# Hash of the last GIT commit
ARG GIT_SHA
ENV GIT_SHA=$GIT_SHA
ENV DATA_DIR=/opt/data
# container version type. develop, stable, edge,.. a release=stable
ARG VERSION_TAG=develop
ENV VERSION_TAG=$VERSION_TAG
ARG BASE_PATH
ENV BASE_PATH=${BASE_PATH}
# Temporary workaround for https://github.com/libuv/libuv/pull/4141
ENV UV_USE_IO_URING=0
USER node
EXPOSE 6246
VOLUME [ "/opt/data" ]
ENTRYPOINT ["/opt/app/start.sh"]