feat(config): add docker

This commit is contained in:
Anthony 2022-07-25 02:14:37 +01:00
parent c06d880f56
commit a38db17468
4 changed files with 51 additions and 1 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
.idea
dist
node_modules
tsconfig.tsbuildinfo
npm-debug.log

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM node:18-buster
WORKDIR /opt/app
COPY --chown=node:node package.json .
COPY --chown=node:node package-lock.json .
COPY --chown=node:node tsconfig.json .
COPY --chown=node:node prisma ./prisma/
RUN npm install
COPY . .
RUN npm run build
RUN chown node:node /opt/app/
USER node
CMD [ "npm", "run", "start:migrate"]

24
docker-compose.yml Normal file
View File

@ -0,0 +1,24 @@
services:
postgres:
image: postgres:14
container_name: postgres
restart: always
ports:
- 5432:5432
env_file:
- .env
volumes:
- postgres:/var/lib/postgresql/data
node:
build:
context: .
dockerfile: Dockerfile
depends_on:
- postgres
env_file:
- .env
volumes:
postgres:
name: arabot-db

View File

@ -6,7 +6,8 @@
"scripts": {
"build": "tsc",
"cleanBuild": "rm -rf ./dist && tsc",
"start": "node dist/index.js"
"start": "node dist/index.js",
"start:migrate": "prisma migrate deploy && npm run start"
},
"repository": {
"type": "git",