-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdockerfile
More file actions
76 lines (68 loc) · 2.4 KB
/
dockerfile
File metadata and controls
76 lines (68 loc) · 2.4 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
FROM node:22 AS base
WORKDIR /usr/src/app
# @todo use upcoming exclude option to filter out stuff we don't need
# ideally we want to at least strip `apps` so that sub target build
# their own scope.
COPY package*.json ./
COPY packages ./packages
COPY config ./config
COPY lerna.json ./
COPY nx.json ./
RUN npm ci
# We will work with the monorepo entirely since
# we have sub packages that need to be built
FROM node:22 AS api
WORKDIR /usr/src/app
# @todo use exclude to remove lot of stuff
COPY --from=base /usr/src/app .
COPY apps/api ./apps/api
# should only install missing packages from API
RUN npm ci
RUN npx lerna run build --scope=@oboku/api
WORKDIR /usr/src/app/apps/api
CMD ["node", "dist/main"]
FROM node:22 AS admin-build
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
COPY apps/admin ./apps/admin
RUN npm ci
RUN npx lerna run build --scope=@oboku/admin
WORKDIR /usr/src/app/apps/admin
FROM nginx:alpine AS admin
WORKDIR /usr/src/app
# Copy the runtime injection script into the container
COPY apps/admin/env.sh /docker-entrypoint.d/env.sh
RUN dos2unix /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh
COPY --from=admin-build /usr/src/app/apps/admin/dist /usr/share/nginx/html
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
FROM node:22 AS web-build
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
COPY apps/web ./apps/web
RUN npm ci
RUN npx lerna run build --scope=@oboku/web
WORKDIR /usr/src/app/apps/web
FROM nginx:alpine AS web
WORKDIR /usr/src/app
COPY apps/web/nginx.default.conf /etc/nginx/conf.d/default.conf
COPY --from=web-build /usr/src/app/apps/web/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
FROM couchdb:3.5.1 AS couchdb
COPY ./apps/couchdb/config/default.ini /opt/couchdb/etc/default.d/oboku.ini
COPY ./apps/couchdb/update-secrets.sh /usr/local/bin/
# Create a custom entrypoint wrapper script
RUN echo '#!/bin/sh\n\
# Run your custom script first\n\
if [ -f /usr/local/bin/update-secrets.sh ]; then\n\
echo "Running update-secrets.sh..."\n\
/usr/local/bin/update-secrets.sh || { status=$?; echo "ERROR: update-secrets.sh exited with non-zero status: ${status}"; exit "${status}"; }\n\
fi\n\
\n\
# Then execute the original entrypoint with all arguments\n\
echo "Starting CouchDB..."\n\
exec /docker-entrypoint.sh "$@"' > /custom-entrypoint.sh && \
chmod +x /custom-entrypoint.sh
ENTRYPOINT ["/custom-entrypoint.sh"]
CMD ["/opt/couchdb/bin/couchdb"]