Skip to content

Commit

Permalink
Merge pull request #402 from bcgov/feature/nginx-config-for-production
Browse files Browse the repository at this point in the history
Storybook Nginx configuration for production deployment
  • Loading branch information
ty2k authored Jul 22, 2024
2 parents 599b718 + 8f9be90 commit 0c30caa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/react-components/Dockerfile.storybook
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------
# Build stage
# -----------
FROM node:lts-alpine as build-stage
FROM node:lts-alpine AS build-stage
ARG GITHUB_SHA
ENV GITHUB_SHA=$GITHUB_SHA

Expand All @@ -30,7 +30,7 @@ RUN STORYBOOK_GITHUB_SHA=$GITHUB_SHA npm run storybook-build
# -----------
# Serve stage
# -----------
FROM nginxinc/nginx-unprivileged:alpine as serve-stage
FROM nginxinc/nginx-unprivileged:alpine AS serve-stage

# Copy nginx configuration
COPY ./nginx.storybook.conf /etc/nginx/nginx.conf
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/Dockerfile.vite
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------
# Build stage
# -----------
FROM node:lts-alpine as build-stage
FROM node:lts-alpine AS build-stage

# Copy package.json and package-lock.json
WORKDIR /app
Expand All @@ -28,7 +28,7 @@ RUN npm run vite-build
# -----------
# Serve stage
# -----------
FROM nginxinc/nginx-unprivileged:alpine as serve-stage
FROM nginxinc/nginx-unprivileged:alpine AS serve-stage

# Copy nginx configuration
COPY ./nginx.vite.conf /etc/nginx/nginx.conf
Expand Down
21 changes: 18 additions & 3 deletions packages/react-components/nginx.storybook.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,24 @@ http {
error_log /tmp/error.log;
access_log /tmp/access.log;

location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
# Redirect requests for root to gov.bc.ca B.C. Design System landing page
# Perma-link: https://www2.gov.bc.ca/gov/content?id=67906B3698E44F4592AD4C6DC375B8F1
location = / {
return 301 https://gov.bc.ca/designsystem;
}

# Requests within /react-components/ path get served the Storybook app
location /react-components/ {
alias /usr/share/nginx/html/;
try_files $uri $uri/ /index.html;
}

# Redirect /react-components to /react-components/
location = /react-components {
return 301 /react-components/;
}

# Redirect 404 errors to the Design System landing page
error_page 404 =301 https://gov.bc.ca/designsystem;
}
}

0 comments on commit 0c30caa

Please sign in to comment.