Compare commits

...

2 Commits

Author SHA1 Message Date
philipcheung d3adfa5cb2 update docker 2025-03-16 14:14:06 +08:00
philipcheung 48c8f46781 update the dockerfile 2025-03-16 14:13:13 +08:00
2 changed files with 30 additions and 19 deletions

View File

@ -1,25 +1,36 @@
FROM node:18-alpine
RUN mkdir -p /app
FROM node:18-alpine AS build
WORKDIR /app
COPY package.json ./
# Copy package files first for better layer caching
COPY package.json package-lock.json* ./
RUN npm install
RUN npm install --save-dev
COPY . /app
# Build the Next.js app
RUN npm run build
# Expose the port the app will run on
EXPOSE 3000
# Install dependencies
RUN npm ci
# Copy the rest of the application
COPY . .
CMD ["npm", "run", "dev"]
# Build the application
RUN npm run build
# Production stage
FROM node:18-alpine AS production
WORKDIR /app
# Copy only the built assets and necessary files from the build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/package.json ./
# Install only production dependencies
RUN npm ci --omit=dev
# Expose the port Vite uses by default
EXPOSE 5173
# Use a static file server for production builds
RUN npm install -g serve
# Serve the built application
CMD ["serve", "-s", "dist", "-l", "5173"]

View File

@ -6,7 +6,7 @@ services:
container_name: healthy-oil
ports:
- "3005:3000"
- "3005:5173"
volumes:
- .:/app
- /app/node_modules