Skip to content

Commit

Permalink
single compose file for all containers
Browse files Browse the repository at this point in the history
  • Loading branch information
yatharthagoenka committed Mar 30, 2023
1 parent 89063bf commit 59ffe7f
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
3 changes: 0 additions & 3 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ ADD . /app

ENV NODE_ENV=dev

EXPOSE 3001
EXPOSE 3002

CMD ["npm", "run", "start"]

10 changes: 10 additions & 0 deletions server/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM nginx:latest

RUN rm /etc/nginx/conf.d/default.conf

COPY nginx.conf /etc/nginx/conf.d/

EXPOSE 3000

CMD ["nginx", "-g", "daemon off;"]

13 changes: 13 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,18 @@ services:
- db
networks:
- bcloud-net
nginx:
build:
context: .
dockerfile: Dockerfile.nginx
ports:
- "3000:3000"
networks:
- bcloud-net
depends_on:
- app1
- app2
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
volumes:
mongo-data:
19 changes: 19 additions & 0 deletions server/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events {
worker_connections 1024;
}

http {
upstream app_servers {
server app_1:3001;
server app_2:3002;
}

server {

listen 3000;

location / {
proxy_pass http://app_servers;
}
}
}
2 changes: 1 addition & 1 deletion server/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AppController {

@Get()
getHello(): string {
this.loggerService.info("Successfully called getHello!")
console.log("debug: Successfully called getHello!")
return this.appService.getHello();
}
}
2 changes: 1 addition & 1 deletion server/src/files/files.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { FileInterceptor } from '@nestjs/platform-express';
import { WinstonLoggerService } from 'src/winston-logger.service';
// import { CheckUserRole } from './role.decorator';


@Controller('files')
export class FilesController {

Expand Down Expand Up @@ -37,6 +36,7 @@ export class FilesController {
async downloadFile(@Res() res, @Query('fileID', new ValidateObjectId()) fileID) {
try {
const file = await this.filesService.downloadFile(fileID);
this.loggerService.debug(file)
return res.download(file);
} catch (error) {
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({ message: 'Error downloading file' });
Expand Down
1 change: 0 additions & 1 deletion server/src/files/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class FilesService {
async combineFiles(fileName, originalname) : Promise<string> {
const folderPath = path.join(__dirname, '..', '..', 'uploads', fileName);
const fileGems = await fs.promises.readdir(folderPath);
this.loggerService.debug(fileGems.toString())
const outputFilePath = path.join(folderPath, `${originalname}`);

fileGems.sort((a, b) => Number(a.split('-').shift()) - Number(b.split('-').shift()));
Expand Down

0 comments on commit 59ffe7f

Please sign in to comment.