From 199dcca2c1a2a40c824a2e82009cb8234f43c276 Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Tue, 12 Mar 2024 15:48:17 +0100 Subject: [PATCH] build(react-spa-authorization-code-flow): add dockerfile --- .../.nginx/nginx.conf | 16 ++++++++++ .../Dockerfile | 30 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/react-spa-authorization-code-flow/.nginx/nginx.conf create mode 100644 examples/react-spa-authorization-code-flow/Dockerfile diff --git a/examples/react-spa-authorization-code-flow/.nginx/nginx.conf b/examples/react-spa-authorization-code-flow/.nginx/nginx.conf new file mode 100644 index 0000000..be7a25e --- /dev/null +++ b/examples/react-spa-authorization-code-flow/.nginx/nginx.conf @@ -0,0 +1,16 @@ +server { + + listen 80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri /index.html =404; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/examples/react-spa-authorization-code-flow/Dockerfile b/examples/react-spa-authorization-code-flow/Dockerfile new file mode 100644 index 0000000..9ca0628 --- /dev/null +++ b/examples/react-spa-authorization-code-flow/Dockerfile @@ -0,0 +1,30 @@ +FROM node:20 as development + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY . . + +ENV CI=true +ENV PORT=3000 + +CMD [ "npm", "start" ] + +FROM development as builder + +RUN npm run build + +FROM nginx:alpine + +# Copy config nginx +COPY --from=builder /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf + +WORKDIR /usr/share/nginx/html + +# Remove default nginx static assets +RUN rm -rf ./* + +# Copy static assets from builder stage +COPY --from=builder /app/dist .