Skip to content

Commit

Permalink
feat: replacing spa-to-http by nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrorezende committed Aug 1, 2023
1 parent 0d7d2b1 commit 11f68e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD ["nginx", "-g", "daemon off;"]
12 changes: 12 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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";
}
}

0 comments on commit 11f68e2

Please sign in to comment.