FROM {{ DOCKER_URL }}/nodejs:latest

WORKDIR /app

ENV NODE_ENV=production

# Install
COPY package*.json ./
RUN --mount=type=secret,id=npmrc,target=/app/.npmrc npm install

# Copy
COPY . .

# Build
RUN npm run build

# Run optional post-build script if present
RUN if [ -f Dockerfile.sh ]; then chmod +x Dockerfile.sh && ./Dockerfile.sh; fi

EXPOSE 3000

CMD ["node", "./index.js"]