fix docker again

This commit is contained in:
hippoz 2022-04-28 03:22:20 +03:00
parent 851d2d683f
commit 9c114a0ef0
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 20 additions and 16 deletions

View file

@ -1,21 +1,28 @@
FROM node:16 FROM node:16 as backend-ts-compiler
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
COPY tsconfig*.json ./
RUN npm i RUN npm install
COPY . . COPY . .
RUN npm run build RUN npm run build
FROM node:16 as frontend-compiler
WORKDIR /app/frontend WORKDIR /app/frontend
COPY --from=backend-ts-compiler /app/frontend/package*.json ./
RUN npm i RUN npm install
COPY --from=backend-ts-compiler /app/frontend/ ./
RUN npm run build RUN npm run build
FROM node:16 as strip-dev-deps
WORKDIR /app WORKDIR /app
COPY --from=backend-ts-compiler /app/package*.json ./
COPY --from=backend-ts-compiler /app/dist ./
RUN npm install --only=production
CMD [ "/bin/sh", "-c", "npm run ream && npm run start" ] 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" ]

View file

@ -12,10 +12,7 @@ services:
build: . build: .
ports: ports:
- "5002:3000" - "5002:3000"
volumes:
- .:/app
environment: environment:
- JWT_SECRET=__jwtsecretgoeshere__
- PGUSER=waffle - PGUSER=waffle
- PGHOST=waffle-postgres - PGHOST=waffle-postgres
- PGPASSWORD=supersecretpassword11 - PGPASSWORD=supersecretpassword11

View file

@ -6,8 +6,8 @@
"target": "esnext", "target": "esnext",
"module": "commonjs", "module": "commonjs",
"esModuleInterop": true, "esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true, "strict": true,
"outDir": "./dist" "outDir": "./dist",
"rootDir": "./src"
} }
} }