feat: add docker files

This commit is contained in:
2026-07-07 17:59:12 +03:30
parent 7b44542ce7
commit 03ba4ceabe
7 changed files with 118 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
node_modules
dist
.git
.gitignore
Dockerfile
docker-compose.yml
+5
View File
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
+27
View File
@@ -0,0 +1,27 @@
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY .env.production .env
EXPOSE 8000
CMD ["node","dist/main.js"]
+49
View File
@@ -0,0 +1,49 @@
version: "3.9"
services:
postgres:
image: postgres:17
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USER}"]
interval: 10s
timeout: 5s
retries: 5
container_name: postgres
restart: unless-stopped
env_file:
- .env.production
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASS}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- postgres_data:/var/lib/postgresql/data
app:
build: .
container_name: nest-app
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
env_file:
- .env.production
ports:
- "8000:8000"
volumes:
postgres_data:
+15 -4
View File
@@ -21,6 +21,7 @@
"bcrypt": "^6.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.3",
"dotenv": "^17.4.2",
"ioredis": "^5.10.1",
"joi": "^18.0.2",
"nestjs-i18n": "^10.6.0",
@@ -2250,6 +2251,17 @@
"rxjs": "^7.1.0"
}
},
"node_modules/@nestjs/config/node_modules/dotenv": {
"version": "17.2.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/@nestjs/core": {
"version": "11.1.14",
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.1.14.tgz",
@@ -4885,10 +4897,9 @@
}
},
"node_modules/dotenv": {
"version": "17.2.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
"license": "BSD-2-Clause",
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
"integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==",
"engines": {
"node": ">=12"
},
+1
View File
@@ -32,6 +32,7 @@
"bcrypt": "^6.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.3",
"dotenv": "^17.4.2",
"ioredis": "^5.10.1",
"joi": "^18.0.2",
"nestjs-i18n": "^10.6.0",
+15
View File
@@ -0,0 +1,15 @@
import { DataSource } from 'typeorm';
import * as dotenv from 'dotenv';
const ENV = process.env.NODE_ENV;
dotenv.config({
path: !ENV ? '.env' : `.env.${ENV}`,
});
export default new DataSource({
type: 'postgres',
host: process.env.DATABASE_HOST,
port: Number(process.env.DATABASE_PORT),
username: process.env.DATABASE_USER,
});