microblog/Dockerfile

55 lines
1.4 KiB
Docker
Raw Normal View History

FROM harbor.server.kjuulh.io/kjuulh/git-log:1681669752119 as git-log
2022-11-06 22:52:29 +01:00
2022-11-07 09:32:08 +01:00
FROM harbor.server.kjuulh.io/docker-proxy/library/node:19-alpine AS deps
2022-11-06 22:52:29 +01:00
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
2022-11-07 09:32:08 +01:00
FROM harbor.server.kjuulh.io/docker-proxy/library/node:19-alpine AS builder
2022-11-06 22:52:29 +01:00
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn tailwind
RUN yarn build
# Production image, copy all the files and run next
2022-11-07 09:32:08 +01:00
FROM harbor.server.kjuulh.io/docker-proxy/library/node:19-alpine AS runner
2022-11-06 22:52:29 +01:00
RUN apk add git
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=git-log --chown=nextjs:nodejs /usr/bin/git-log /usr/bin/git-log
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
2022-11-06 23:17:51 +01:00
COPY --from=builder --chown=nextjs:nodejs /app/ ./
2022-11-06 22:52:29 +01:00
USER nextjs
EXPOSE 3000
ENV PORT 3000
2022-11-06 23:17:51 +01:00
CMD ["yarn", "start"]