Skip to content

Instantly share code, notes, and snippets.

@koolkishan
Last active October 1, 2023 05:37
Show Gist options
  • Save koolkishan/b7037d252b784f48b2bb262d52ce80fa to your computer and use it in GitHub Desktop.
Save koolkishan/b7037d252b784f48b2bb262d52ce80fa to your computer and use it in GitHub Desktop.
Next.js Amazon Clone Docker Files
# Development Dockerfile
# This Dockerfile is intended for development use and includes development dependencies and tools.
# Use a Node.js base image with development tools
FROM node:16.0.0 AS development
# Create a directory where the application will be built
WORKDIR /app
# Copy over the dependency manifests, both the package.json
# and the package-lock.json are copied over
COPY package*.json ./
# Install packages and their dependencies
RUN npm install
# Copy over the prisma schema
COPY prisma/schema.prisma ./prisma/
# Generate the prisma client based on the schema
RUN npm run prisma:generate
# Copy over the code base
COPY . .
RUN npx prisma db push
# Create the bundle of the application
RUN npm run build
# Expose a specific port on the Docker container for development purposes
ENV PORT=3000
EXPOSE ${PORT}
# Start the development server using the previously built application
CMD ["npm", "start"]
# Use an official Node.js runtime as the base image
FROM node:18
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of your app's source code
COPY . .
# Build the production version of the app
RUN npm run build
# Expose the port your Next.js app will run on
EXPOSE 3000
# Start your Next.js app
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment