ARG NODE_IMAGE="node"
ARG NODE_VERSION="16.17.1-slim"

FROM ${NODE_IMAGE}:${NODE_VERSION}

WORKDIR /project

COPY package.json package-lock.json /project/

RUN npm ci --no-audit --no-fund

COPY --chown=node:node . /project/

RUN chown node:node /project -R && \
    find /project -type d -exec chmod 0750 {} \; && \
    find /project -type f -exec chmod 0650 {} \; && \
    ls -la /project && \
    find /project ! -path '/project/node_modules/*' 

# Run as node (user id 1000)
USER node

CMD ["node", "/project/app.js"]
