FROM node:20.16-alpine

COPY .npmrc package.json /tmp/
COPY common /tmp/common

RUN set -ex \
  && apk add --no-cache \
	curl \
	ca-certificates \
	build-base \
	&& cd /tmp \
	&& yarn config set network-timeout 300000 \
	&& yarn install \
	&& rm -f /tmp/.npmrc \
	&& mkdir -p /home/app \
	&& cp -a /tmp/node_modules /home/app/ \
	&& cp -a /tmp/common /home/app/common \
	&& rm -Rf /tmp/*

WORKDIR /home/app

# Copy the rest of the files to the container workdir
ADD . /home/app

ENV PORT=3000
EXPOSE ${PORT}

CMD [ "yarn", "start" ]