# Build stage FROM node:20 as builder WORKDIR /app # Copy package files COPY package*.json ./ # Copy yarn.lock if it exists COPY yarn.lock* ./ # Install dependencies RUN yarn install # Copy the rest of the application COPY . . # Build Storybook RUN yarn build-storybook # Production stage FROM nginx:alpine WORKDIR /usr/share/nginx/html # Copy built Storybook files COPY --from=builder /app/storybook-static . # Create nginx configuration RUN echo 'server { \ listen 6006; \ root /usr/share/nginx/html; \ index index.html; \ location / { \ try_files $uri $uri/ /index.html; \ expires 30d; \ add_header Cache-Control "public, no-transform"; \ } \ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { \ expires 30d; \ add_header Cache-Control "public, no-transform"; \ } \ location ~ /\. { \ deny all; \ } \ error_page 404 /index.html; \ }' > /etc/nginx/conf.d/default.conf # Set up permissions RUN chown -R nginx:nginx /usr/share/nginx/html \ && chown -R nginx:nginx /var/log/nginx EXPOSE 6006