-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (50 loc) · 1.82 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (50 loc) · 1.82 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
# ===============================================
FROM helsinki.azurecr.io/ubi9/nodejs-24-pnpm-builder-base AS appbase
# ===============================================
# Set environment
ARG PORT=3000
ENV PORT=$PORT
WORKDIR /app
# Set npm log verbosity level
ENV NPM_CONFIG_LOGLEVEL=warn
# Global npm dependencies in a non-root user directory
ENV NPM_CONFIG_PREFIX=/app/.npm-global
ENV PATH=$PATH:/app/.npm-global/bin
# Set NODE_ENV to development in the development container
ARG NODE_ENV=development
ENV NODE_ENV=$NODE_ENV
# Copy package.json and pnpm-lock.yaml files
COPY --chown=default:root package*.json pnpm-lock.yaml ./
# Make scripts in dependencies available through path
ENV PATH=/app/node_modules/.bin:$PATH
# Install dependencies including storybook addons
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune
# =============================
FROM appbase AS development
# =============================
# Copy all files
COPY --chown=default:root . .
# Start command for development
CMD ["pnpm", "run", "dev:no-open"]
# =============================
FROM appbase AS staticbuilder
# =============================
# Set NODE_ENV to production for build
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
# Copy all files, including .mdx stories
COPY --chown=default:root . .
# Build Storybook
RUN pnpm run build-storybook --loglevel error
# =============================
FROM appbase AS production
# =============================
# Set NODE_ENV to production in the production container
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
# Copy build folder
COPY --from=staticbuilder --chown=default:root /app/storybook-static/ /app/storybook-static/
# Copy server folder
COPY --from=staticbuilder --chown=default:root /app/storybook-server/ /app/storybook-server/
# Start server
CMD ["node", "./storybook-server/index.js"]