# Install dependencies only when needed
FROM node:16.14.0-alpine3.14 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat

ENV NODE_ENV production

ADD docker-entrypoint.sh /

RUN addgroup -g 5353 -S nodejs
RUN adduser -S nextjs -u 5353

RUN ["chmod", "+x", "/docker-entrypoint.sh"]
RUN ["chown", "5353:5353", "/docker-entrypoint.sh"]

USER nextjs

EXPOSE 3000

CMD /docker-entrypoint.sh