Changed docker-compose and Dockerfile to be
production ready.
This commit is contained in:
parent
9ebcca56d5
commit
64f7a2942a
31
Dockerfile
31
Dockerfile
@ -1,14 +1,29 @@
|
||||
FROM node:16-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
# Build stage
|
||||
FROM node:16-alpine AS build-stage
|
||||
|
||||
COPY next.config.js ./next.config.js
|
||||
COPY tailwind.config.js ./tailwind.config.js
|
||||
COPY postcss.config.js ./postcss.config.js
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json ./
|
||||
COPY package-lock.json ./
|
||||
RUN npm ci --production
|
||||
|
||||
COPY next.config.js ./
|
||||
COPY tailwind.config.js ./
|
||||
COPY postcss.config.js ./
|
||||
COPY components ./components
|
||||
COPY pages ./pages
|
||||
COPY public ./public
|
||||
COPY styles ./styles
|
||||
|
||||
CMD ["npm","run","dev"]
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:16-alpine AS production-stage
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build-stage /app/.next ./.next
|
||||
COPY --from=build-stage /app/public ./public
|
||||
COPY --from=build-stage /app/node_modules ./node_modules
|
||||
|
||||
CMD ["npm", "start"]
|
@ -2,12 +2,8 @@ version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: docker-nextjs-dev
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- 8443:8443
|
||||
volumes:
|
||||
- ./pages:/app/pages
|
||||
- ./public:/app/public
|
||||
- ./styles:/app/styles
|
||||
- ./components:/app/components
|
||||
- 80:3000
|
||||
|
Reference in New Issue
Block a user