Сборка Docker image

This commit is contained in:
2025-03-02 17:22:48 +04:00
parent 6734bb1321
commit a70d2f442d
8 changed files with 13197 additions and 16 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
scripts
README.md

8
.gitignore vendored
View File

@@ -55,9 +55,5 @@ pids
# Diagnostic reports (https://nodejs.org/api/report.html) # Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# HTTPS cerificates # development files
/cert/ /secrets/
*.pem
# K8S test files
/k8s/

15
Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:current-alpine3.19
LABEL authors="n08i40k"
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm i --omit=dev
RUN npm i prisma
COPY . ./
RUN npm run build
ENTRYPOINT ["sh", "-c", "/scripts/start.sh"]
CMD ["npm", "run", "start:prod"]

13162
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
"private": true, "private": true,
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {
"build": "nest build", "build": "nest build && npx prisma generate",
"format": "prettier --write \"src/**/*.ts\"", "format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"precommit": "npm run format && npm run lint", "precommit": "npm run format && npm run lint",

11
scripts/start.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
DATABASE_URL="mongodb://$(cat "$MONGO_PROJECTDB_USERNAME_FILE"):$(cat "$MONGO_PROJECTDB_PASSWORD_FILE")@$MONGO_DOMAIN:$MONGO_PORT/$MONGO_INITDB_DATABASE?authMechanism=SCRAM-SHA-1"
export DATABASE_URL
JWT_SECRET=$(cat "$JWT_TOKEN_FILE")
export JWT_SECRET
npx prisma db push
exec "$@"

View File

@@ -27,11 +27,6 @@ export const jwtConstants = {
secret: process.env.JWT_SECRET, secret: process.env.JWT_SECRET,
}; };
export const httpsConstants = {
certPath: process.env.CERT_PEM_PATH,
keyPath: process.env.KEY_PEM_PATH,
};
export const apiConstants = { export const apiConstants = {
port: +(process.env.API_PORT ?? 5050), port: +(process.env.API_PORT ?? 5050),
version: process.env.SERVER_VERSION, version: process.env.SERVER_VERSION,

View File

@@ -42,14 +42,14 @@ async function bootstrap() {
}); });
swaggerDocument.servers = [ swaggerDocument.servers = [
{
url: "https://polytechnic-dev.n08i40k.ru",
description: "Сервер для разработки и тестирования",
},
{ {
url: "https://polytechnic.n08i40k.ru", url: "https://polytechnic.n08i40k.ru",
description: "Сервер для продакшн окружения", description: "Сервер для продакшн окружения",
}, },
{
url: "https://polytechnic-dev.n08i40k.ru",
description: "Сервер для разработки и тестирования",
},
]; ];
SwaggerModule.setup("api-docs", app, swaggerDocument, {}); SwaggerModule.setup("api-docs", app, swaggerDocument, {});