waffle/Dockerfile
2023-08-08 22:32:30 +03:00

31 lines
869 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
USER node
USER root
RUN mkdir -p /var/lib/waffle/uploads && chown -R node /var/lib/waffle/uploads
USER node
CMD [ "/bin/sh", "-c", "node index.js" ]