forked from seokho-son/cb-mapui
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (55 loc) · 2.01 KB
/
Dockerfile
File metadata and controls
71 lines (55 loc) · 2.01 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
#############################################################
## Stage 1 - Build static files
#############################################################
FROM node:18-alpine AS builder
WORKDIR /app
# Copy only package files first for better caching
COPY ./package.json ./package-lock.json ./
# Install dependencies with optimized settings and BuildKit cache
RUN --mount=type=cache,target=/root/.npm \
npm config set fetch-retries 5 \
&& npm config set fetch-retry-mintimeout 20000 \
&& npm config set fetch-retry-maxtimeout 120000 \
&& npm ci --silent --no-audit --prefer-offline
# Copy only necessary source files
COPY ./index.html ./
COPY ./index.js ./
COPY ./resource-graph.js ./
COPY ./dashboard.html ./
COPY ./dashboard.js ./
COPY ./favicon.svg ./
COPY ./redoc-swagger.html ./
COPY ./swagger.html ./
COPY ./scalar.html ./
COPY ./img ./img
# Build with Parcel cache
RUN --mount=type=cache,target=/app/.parcel-cache \
npm run build || true
# Ensure dist directory exists (even if build failed)
RUN mkdir -p dist
# Prune dev dependencies
RUN npm prune --production
#############################################################
## Stage 2 - Production Runtime
#############################################################
FROM node:18-alpine AS prod
WORKDIR /app
# Copy necessary files from builder
COPY --from=builder /app/index.html ./
COPY --from=builder /app/index.js ./
COPY --from=builder /app/resource-graph.js ./
COPY --from=builder /app/dashboard.html ./
COPY --from=builder /app/dashboard.js ./
COPY --from=builder /app/favicon.svg ./
COPY --from=builder /app/redoc-swagger.html ./
COPY --from=builder /app/swagger.html ./
COPY --from=builder /app/scalar.html ./
COPY --from=builder /app/img ./img
# Copy dependencies and configs
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/package-lock.json ./
# Copy dist directory (created during build or as empty dir)
COPY --from=builder /app/dist ./dist
EXPOSE 1324
ENTRYPOINT ["npm", "start"]