FROM balenalib/%%BALENA_ARCH%%-alpine-node:18-latest-build as build

# Install node dependencies
COPY package*.json ./
RUN npm install --production && npm cache clean --force && rm -rf /tmp/*


FROM balenalib/%%BALENA_ARCH%%-alpine-node:18-latest-run as run
# pathname specific to distro
ENV AWS_ROOT_CA_PATH="/etc/ssl/certs/ca-cert-Amazon_Root_CA_1.pem"

WORKDIR /app
COPY --from=build ./node_modules ./node_modules
COPY index.js package.json ./
COPY lib/ ./lib

# Start the container
CMD ["npm", "start"]
