waffle/Dockerfile
2023-08-08 23:30:27 +03:00

27 lines
761 B
Docker

FROM node:18 as backend-ts-compiler
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:18 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:18 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:18
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
CMD [ "/bin/sh", "-c", "node index.js" ]