-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker support for API documentation with build and deployment co…
…nfiguration
- Loading branch information
1 parent
bbae761
commit d2f2937
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# # # # # # # # # | ||
|
||
FROM node:22.6-alpine3.20 AS base | ||
|
||
# # # # # # # # # | ||
|
||
|
||
# PHASE 1 | ||
# Install dependencies only when needed. | ||
|
||
FROM base AS dependencies | ||
|
||
RUN apk add --no-cache libc6-compat | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
|
||
RUN npm install --omit-dev --force \ | ||
&& npm cache clean --force | ||
|
||
|
||
# # # # # # # # # | ||
|
||
|
||
# PHASE 2 | ||
# Rebuild the source code only when needed. | ||
|
||
FROM base AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=dependencies /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN npx @helperkits/bumper bump | ||
|
||
RUN npm run build | ||
|
||
|
||
# # # # # # # # # | ||
|
||
|
||
# PHASE 3 | ||
# Setup the final Docker image with only the required files. | ||
|
||
FROM base AS runner | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
ENV PORT=3000 | ||
ENV HOSTNAME=0.0.0.0 | ||
|
||
CMD ["node", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters