Files
portfolio-2/Dockerfile
Ahmed Al-Taiar 6af75088af
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 5s
Fix EACCES on /app/package.json in Docker
2025-12-10 12:46:29 -05:00

45 lines
1.0 KiB
Docker

FROM node:lts-alpine AS builder
ARG APP_VERSION=dev
ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION
WORKDIR /app
RUN corepack enable
RUN corepack prepare yarn@4.12.0 --activate
COPY package.json yarn.lock .yarnrc.yml ./
RUN yarn install --immutable
COPY . .
RUN yarn build
FROM node:lts-alpine AS runner
ARG APP_VERSION=dev
ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION \
APP_VERSION=$APP_VERSION \
NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
LABEL org.opencontainers.image.version=$APP_VERSION
WORKDIR /app
RUN corepack enable
RUN corepack prepare yarn@4.12.0 --activate
RUN addgroup -S nodejs -g 1001
RUN adduser -S nextjs -u 1001
COPY --from=builder /app/yarn.lock ./yarn.lock
COPY --from=builder /app/.yarnrc.yml ./.yarnrc.yml
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
RUN mkdir -p /app/.yarn /app/.next/cache/images
RUN chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3000
CMD ["yarn", "start"]