Skip to content

Commit

Permalink
refactor: updated nginx configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-komlyk committed Mar 11, 2024
1 parent 323afd6 commit e067ff4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ data
seed

# Docker
nginx
docker-compose.local.yml
1 change: 1 addition & 0 deletions apps/server/.env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ APP_API=api
APP_TRPC=trpc
APP_SWAGER=api-docs
APP_STATIC_ASSETS=public
APP_SSL_FOLDER=
APP_BASE_URL=http://185.65.244.84:3000
APP_ADMIN_URL=http://185.65.244.84:3002

Expand Down
18 changes: 18 additions & 0 deletions apps/server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { readFileSync } from 'fs';
import { resolve } from 'path';

import { TrpcRouter } from '@domain/trpc/trpc.router';
import { useContainer } from 'class-validator';
Expand All @@ -10,7 +12,23 @@ import { AppModule } from '@domain/app.module';
import { PREFIX, PUBLIC_FOLDER } from '@constants/routes.constants';

(async (): Promise<void> => {
const httpsOptions = {
key: readFileSync(
resolve(
process.cwd(),
`../../nginx/data/custom_ssl/${process.env.APP_SSL_FOLDER}/privkey.pem`,
),
),
cert: readFileSync(
resolve(
process.cwd(),
`../../nginx/data/custom_ssl/${process.env.APP_SSL_FOLDER}/fullchain.pem`,
),
),
};

const app = await NestFactory.create<NestExpressApplication>(AppModule, {
httpsOptions,
rawBody: true,
});

Expand Down
8 changes: 6 additions & 2 deletions docker-compose.local.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ services:

app:
image: "jc21/nginx-proxy-manager:latest"
container_name: nginx
restart: unless-stopped
ports:
- "80:80"
- "81:81"
- "443:443"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- ./nginx/data:/data
- ./nginx/letsencrypt:/etc/letsencrypt
networks:
- backend

server:
build:
Expand All @@ -70,6 +73,7 @@ services:
- JWT_REFRESH_TOKEN_KEY=
volumes:
- ./apps/server/public:/app/apps/server/public
- ./nginx/data:/app/nginx/data
- /app/node_modules
- /app/apps/server/node_modules

Expand Down
7 changes: 5 additions & 2 deletions docker-compose.prod-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ services:
- "81:81"
- "443:443"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- ./nginx/data:/data
- ./nginx/letsencrypt:/etc/letsencrypt
networks:
- backend

server:
image: ghcr.io/dmytro-komlyk/prod-fixlab-server:latest
Expand All @@ -74,6 +76,7 @@ services:
- NODE_ENV=production
volumes:
- ./server/public/:/app/server/public
- ./nginx/data:/app/nginx/data
ports:
- 3000:3000
networks:
Expand Down

0 comments on commit e067ff4

Please sign in to comment.