update dockerfile

This commit is contained in:
hippoz 2023-08-08 21:24:24 +03:00
parent d902cf16cc
commit add3197d65
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

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