FROM node:lts
WORKDIR /usr/src/app
# Use Corepack to lock yarn version from repo to ensure consistent installs if possible
RUN corepack enable && corepack prepare yarn@1.22.19 --activate
# Copy package manifests first to leverage Docker cache
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install
# Copy the rest of the project
COPY . .
# Build the project (if build script defined)
RUN yarn build || echo 'no build script defined'
# Entrypoint script to provide a friendly container startup and passthrough for commands
COPY run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
ENTRYPOINT ["/usr/local/bin/run.sh"]