-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
45 lines (37 loc) · 1.1 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
# Base
FROM node:21-alpine as base
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
# Dependencies
FROM base as dependencies
WORKDIR /app
RUN npm ci --ignore-scripts
COPY src src
COPY .storybook .storybook
COPY public public
COPY eslint.config.js eslint.config.js
COPY vite.config.ts vite.config.ts
# Build
FROM dependencies as builder
WORKDIR /app
RUN npm run build-storybook
# STAGE 2 => SETUP NGINX and Run
FROM nginxinc/nginx-unprivileged:alpine
USER 0
# Clear default nginx html file
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/storybook-static /usr/share/nginx/html
COPY proxy/nginx.conf /etc/nginx/conf.d/default.conf.template
COPY proxy/securityheaders.conf /etc/nginx/securityheaders.conf
# Copy .env file and shell script to container to handle
# runtime environment variables
WORKDIR /usr/share/nginx/html
COPY ./secrets.sh .
RUN chown -R nginx /etc/nginx/conf.d \
&& chown -R nginx /usr/share/nginx/html \
&& chmod +x ./secrets.sh
# Add bash shell
RUN apk update && apk add --no-cache bash~=5.2.26
USER 101
CMD ["/bin/bash", "-c", "./secrets.sh && nginx -g \"daemon off;\""]