Skip to content

Commit

Permalink
ci: docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxtuneLee committed Jul 17, 2024
1 parent b5d1893 commit 7be1ac0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM node:20-slim AS base
WORKDIR /app
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm config set registry https://registry.npmmirror.com
RUN npm i -g pnpm

# Install dependencies and build the application
FROM base AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
ENV NEXT_TELEMETRY_DISABLED 1
ENV OUTPUT_STANDALONE 1
# Use the npm mirror to speed up the installation
RUN pnpm config set registry https://registry.npmmirror.com && pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build

# Install production dependencies only
RUN pnpm install --prod --ignore-scripts --prefer-offline

# Use alpine for the final image to reduce the image size
FROM node:20-alpine AS runner
WORKDIR /app


COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

# Set environment variables
ENV NODE_ENV production
ENV PORT 3000

EXPOSE 3000

# Just pass HOSTNAME to node server.js
CMD HOSTNAME="0.0.0.0" node server.js
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const nextConfig = {
},
],
},
output: "standalone",
};

export default nextConfig;

0 comments on commit 7be1ac0

Please sign in to comment.