waffle/Dockerfile
2022-04-28 03:22:20 +03:00

28 lines
796 B
Docker

FROM node:16 as backend-ts-compiler
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:16 as frontend-compiler
WORKDIR /app/frontend
COPY --from=backend-ts-compiler /app/frontend/package*.json ./
RUN npm install
COPY --from=backend-ts-compiler /app/frontend/ ./
RUN npm run build
FROM node:16 as strip-dev-deps
WORKDIR /app
COPY --from=backend-ts-compiler /app/package*.json ./
COPY --from=backend-ts-compiler /app/dist ./
RUN npm install --only=production
FROM node:16
WORKDIR /app
COPY --from=strip-dev-deps /app ./
COPY --from=frontend-compiler /app/frontend/public ./frontend/public
RUN echo "JWT_SECRET=$(openssl rand -base64 256 | tr -d '\n')" > .env
USER node
CMD [ "/bin/sh", "-c", "node index.js db-init && node index.js" ]