FROM node:16-alpine

RUN apk add --no-cache tini

RUN yarn global add lerna

WORKDIR /opt/wonders-server
COPY packages/ketchup-common/package.json packages/ketchup-common/
COPY packages/ketchup-server/package.json packages/ketchup-server/
COPY packages/wonders-common/package.json packages/wonders-common/
COPY packages/wonders-server/package.json packages/wonders-server/
COPY package.json yarn.lock lerna.json ./
RUN lerna bootstrap

COPY . ./
RUN lerna run build-lib
RUN lerna run build

ENTRYPOINT ["tini", "--"]
CMD ["node", "packages/wonders-server"]
EXPOSE 80
