Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplfied dockerfile added ignore file #314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web_app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/bin
**/obj
**/node_modules
.git
57 changes: 16 additions & 41 deletions web_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
FROM node:18-alpine AS base
RUN apk add --no-cache g++ make py3-pip libc6-compat
WORKDIR /app
COPY package*.json ./
EXPOSE 3000
# Dockerfile for NextJS applications

FROM base AS builder
WORKDIR /app
COPY . .
RUN npm run build
# Use the official Node.js image as base
FROM node:18-alpine

FROM base AS production
# Set the working directory inside the container
WORKDIR /app

# ENV NODE_ENV production
RUN npm ci --ignore-scripts

RUN addgroup -g 1003 -S nodegroup
RUN adduser -S nextuser -u 1003
USER nextuser

COPY --from=builder /app/.next ./.next
RUN chown nextuser:nodegroup ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/public ./public

CMD npm start

FROM base AS dev
RUN npm install
# Copy package.json and package-lock.json to the container
COPY package*.json ./

COPY package.json .
COPY package-lock.json .
COPY /node_modules ./node_modules
COPY /src ./src
COPY /public ./public
COPY next.config.mjs .
COPY next-env.d.ts .
COPY tsconfig.json .
COPY .eslintrc.json .
# Install dependencies
RUN npm install

RUN addgroup -g 1003 -S nodegroup
RUN adduser -S nextuser -u 1003
# Copy the rest of the application code to the container
COPY . .

RUN chown -R nextuser:nodegroup /app
# Build the Next.js application
RUN npm run build

USER nextuser
# Expose the port that your Next.js app runs on
EXPOSE 3000

CMD npm run dev
# Command to run the application
CMD ["npm", "start"]