FROM node:18-alpine
LABEL maintainer="Fabian Stamm <dev@fabianstamm.de>"

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# COPY ["package.json", "yarn.lock", ".yarnrc.yml", "/usr/src/app/"]
# COPY .yarn /usr/src/app/.yarn
# COPY Backend /usr/src/app/Backend
# COPY Frontend /usr/src/app/Frontend
# COPY FrontendLegacy /usr/src/app/FrontendLegacy

COPY . /usr/src/app

# RUN rm -rf /usr/src/app/Backend/node_modules &&\
#    rm -rf /usr/src/app/Frontend/node_modules &&\
#    rm -rf /usr/src/app/FrontendLegacy/node_modules &&\
#    rm -rf /usr/src/app/Backend/logs &&\
#    rm -rf /usr/src/app/Backend/keys

RUN yarn install
RUN yarn build

RUN ln -s /usr/src/app/logs /usr/src/app/Backend/logs && ln -s /usr/src/app/keys /usr/src/app/Backend/keys

VOLUME [ "/usr/src/app/logs", "/usr/src/app/keys"]

EXPOSE 3004/tcp

WORKDIR /usr/src/app/Backend
CMD ["npm", "run", "start"]
