unable to convert uid/gid chown string to host mapping: can't find uid for user nextjs: no such user: nextjs
I try to build a Dockerfile with AutoDevOps (default configuration)
When I build it locally, everything works fine, how can I build it with Gitlab-CI?
ERROR:
[Step 16/25 : COPY --from=builder /app/public ./public
---> c0414ef82249
Step 17/25 : COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
unable to convert uid/gid chown string to host mapping: can't find uid for user nextjs: no such user: nextjs
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1
This is my whole Dockerfile, how can I get this build? I didn't found anything in the docs about
# Install dependencies only when needed
FROM node:alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild the source code only when needed
FROM node:alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build
# Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
####################################
####### THIS SECTION FAILS: ########
####################################
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
RUN chown -R nextjs:nodejs /app/.next
USER nextjs
EXPOSE 3000
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1
CMD ["npm", "run", "start"]