From 3dfb16658b890ae274a2ade5fe5557801be23fad Mon Sep 17 00:00:00 2001 From: Mohammed Hawamdeh Date: Mon, 7 Jun 2021 14:17:26 +0300 Subject: [PATCH] initial commit --- nextjs-static-ngnix/.dockerignore | 10 +++++++++ nextjs-static-ngnix/dockerfile | 34 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 nextjs-static-ngnix/.dockerignore create mode 100644 nextjs-static-ngnix/dockerfile diff --git a/nextjs-static-ngnix/.dockerignore b/nextjs-static-ngnix/.dockerignore new file mode 100644 index 000000000..48183fa58 --- /dev/null +++ b/nextjs-static-ngnix/.dockerignore @@ -0,0 +1,10 @@ +.git +node_modules +out +.next +.vscode +.prettier* +/eslintrc* +TODO +.editorconfig +**.log \ No newline at end of file diff --git a/nextjs-static-ngnix/dockerfile b/nextjs-static-ngnix/dockerfile new file mode 100644 index 000000000..038854cf3 --- /dev/null +++ b/nextjs-static-ngnix/dockerfile @@ -0,0 +1,34 @@ +# Statically build nextjs, deploy on ngnix +# To build: +# docker build -t nextjs-static -f ./dockerfile . + +# To run: +# docker run --rm -e 'PORT=80' -p 80:80 -d --name nextjs-static nextjs-static:latest + +FROM node:latest as builder + +WORKDIR /app +# install deps +COPY package.json yarn.lock ./ +RUN yarn --production --frozen-lockfile + +#copy the directory after install is done + + +COPY . . + +#export +RUN yarn next build && yarn next export + +#stage2 +FROM nginx:alpine + +COPY nginx /etc/nginx/ + +# ## Remove default nginx index page +RUN rm -rf /usr/share/nginx/html/* + +# # Copy static files from the builder +COPY --from=builder /app/out /usr/share/nginx/html + +ENTRYPOINT ["nginx", "-g", "daemon off;"] \ No newline at end of file