From 11f68e28016707e1860ff18a59ff7295c5178f0b Mon Sep 17 00:00:00 2001 From: Pedro Rezende Date: Tue, 1 Aug 2023 17:48:14 +0200 Subject: [PATCH] feat: replacing spa-to-http by nginx --- Dockerfile | 15 +++++---------- nginx.conf | 12 ++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 583f47fd..894d1deb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,19 +22,14 @@ ENV NEXT_TELEMETRY_DISABLED 1 RUN npm run build:${TARGET} # Production image, copy all the files and run next -FROM devforth/spa-to-http:latest +FROM nginx:alpine ARG TARGET - -WORKDIR /app - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - +COPY nginx.conf /etc/nginx/conf.d/default.conf +WORKDIR /usr/share/nginx/html +RUN rm -rf ./* COPY --from=builder /app/packages/${TARGET}/out . -USER nextjs - EXPOSE 3000 -ENV PORT 3000 \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..d18c5a34 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,12 @@ +server { + listen 3000; + root /usr/share/nginx/html; + location /_next/static { + # Provides caching for static assets, to improve server performance + add_header Cache-Control "max-age=31536000"; + } + location / { + try_files $uri.html $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } + } \ No newline at end of file