microblog/Dockerfile
Kasper Juul Hermansen ff4e1e626e
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Update harbor.server.kjuulh.io/kjuulh/git-log Docker tag to v1683275780732
2023-05-05 09:07:04 +00:00

55 lines
1.4 KiB
Docker

FROM harbor.server.kjuulh.io/kjuulh/git-log:1683275780732 as git-log
FROM harbor.server.kjuulh.io/docker-proxy/library/node:20-alpine AS deps
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
FROM harbor.server.kjuulh.io/docker-proxy/library/node:20-alpine AS builder
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
FROM harbor.server.kjuulh.io/docker-proxy/library/node:20-alpine AS runner
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
COPY --from=builder --chown=nextjs:nodejs /app/ ./
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["yarn", "start"]