Skip to content
Snippets Groups Projects
Commit e3bfa536 authored by Lukáš Kratochvíl's avatar Lukáš Kratochvíl
Browse files

Merge branch 'backend-setup' into main

parents 62c312e0 4637867d
No related branches found
No related tags found
No related merge requests found
# Node
node_modules/
# JetBrains IDEA
.idea/
# .env files
.env
# Database
database-storage
# Database
database-storage
# compiled output
/dist
/node_modules
......
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
ConfigModule.forRoot({
envFilePath: '../.env',
}),
],
imports: [],
controllers: [AppController],
providers: [AppService],
})
......
......@@ -5,8 +5,9 @@ import { AppModule } from './app.module';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create(AppModule);
const configService = new ConfigService();
const port = configService.get('SERVER_PORT');
const port = configService.get('PORT');
console.log(`NestJS server is listening on: http://localhost:${port}`);
await app.listen(port);
}
bootstrap();
......@@ -8,16 +8,17 @@ services:
context: ./backend
dockerfile: Dockerfile
command: npm run start:debug
env_file: .env
ports:
- 127.0.0.1:${SERVER_PORT}:${SERVER_PORT}
networks:
- backend-network
volumes:
# changes in host's ./backend directory will be propagated to the container
- ./backend:/usr/src/app
# this prevents our host files from overriding container's node_modules
- exclude-server:/usr/src/app/node_modules/
networks:
- backend-network
environment:
- PORT=${SERVER_PORT}
restart: always
depends_on:
- postgres
......@@ -25,11 +26,10 @@ services:
postgres:
container_name: postgres
image: postgres:14.3-alpine
env_file: .env
volumes:
- ./backend/database-storage:/var/lib/postgresql/data
networks:
- backend-network
volumes:
- ./backend/database-storage:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
......@@ -39,7 +39,6 @@ services:
adminer:
container_name: adminer
image: adminer:4.8.1
env_file: .env
ports:
- 127.0.0.1:${ADMINER_PORT}:${ADMINER_PORT}
networks:
......@@ -53,14 +52,14 @@ services:
nginx:
container_name: nginx
image: nginx:1.21.6-alpine
env_file: .env
ports:
- 127.0.0.1:${NGINX_PORT}:${NGINX_PORT}
networks:
- backend-network
- frontend-network
volumes:
- ./nginx/templates:/etc/nginx/templates
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
networks:
- backend-network
environment:
- NGINX_PORT=${NGINX_PORT}
- SERVER_PORT=${SERVER_PORT}
......@@ -75,20 +74,26 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile
env_file: .env
ports:
- 127.0.0.1:${CLIENT_PORT}:${CLIENT_PORT}
networks:
- frontend-network
volumes:
# changes in host's ./frontend directory will be propagated to the container
- ./frontend:/usr/src/app
# this prevents our host files from overriding container's node_modules
- exclude-client:/usr/src/app/node_modules/
environment:
- PORT=${CLIENT_PORT}
# all the traffic goes through Nginx server
- SERVER_PORT=${NGINX_PORT}
restart: always
networks:
backend-network:
frontend-network:
volumes:
database-storage:
exclude-server:
exclude-client:
networks:
backend-network:
......@@ -2,16 +2,12 @@ import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = {...process.env, ...loadEnv(mode, `../${process.cwd()}`, '')};
return defineConfig({
plugins: [react()],
server: {
watch: {
usePolling: true
},
port: +process.env.CLIENT_PORT
}
});
}
export default defineConfig({
plugins: [react()],
server: {
watch: {
usePolling: true
},
port: +process.env.PORT
}
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment