diff --git a/.github/workflows/BackEnd_CD.yml b/.github/workflows/BackEnd_CD.yml
index 2169da54..0ee9ddef 100644
--- a/.github/workflows/BackEnd_CD.yml
+++ b/.github/workflows/BackEnd_CD.yml
@@ -27,19 +27,52 @@ jobs:
file: ./BackEnd/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
+name: BackEnd-CD
- - name: SSH to Internal Server and Deploy
- uses: appleboy/ssh-action@master
+on:
+ push:
+ branches:
+ - develop
+ paths:
+ - 'BackEnd/**'
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: docker/setup-buildx-action@v2
+
+ - uses: docker/login-action@v2
+ with:
+ registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
+ username: ${{ secrets.NCP_ACCESS_KEY }}
+ password: ${{ secrets.NCP_SECRET_KEY }}
+
+ - uses: docker/build-push-action@v3
with:
- host: ${{ secrets.BASTION_HOST }}
- username: ${{ secrets.BASTION_USER }}
- password: ${{ secrets.BASTION_PASSWORD }}
- port: 22
- script: |
- sshpass -p ${{ secrets.SERVER_PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.INTERNAL_SERVER_IP }} -p 22 '
- docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
+ context: .
+ file: ./BackEnd/Dockerfile
+ push: true
+ tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
+
+ - name: SSH to Internal Server and Deploy
+ env:
+ BASTION_HOST: ${{ secrets.BASTION_HOST }}
+ BASTION_USER: ${{ secrets.BASTION_USER }}
+ BASTION_PASSWORD: ${{ secrets.BASTION_PASSWORD }}
+ SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
+ SERVER_USER: ${{ secrets.SERVER_USER }}
+ INTERNAL_SERVER_IP: ${{ secrets.INTERNAL_SERVER_IP }}
+ CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }}
+ run: |
+ sshpass -p $BASTION_PASSWORD ssh -o StrictHostKeyChecking=no $BASTION_USER@$BASTION_HOST -tt << EOF
+ sshpass -p $SERVER_PASSWORD ssh -o StrictHostKeyChecking=no $SERVER_USER@$INTERNAL_SERVER_IP -tt << 'ENDSSH'
+ docker pull $CONTAINER_REGISTRY/my-app:latest
docker stop my-app || true
docker rm my-app || true
- docker run --name my-app -d -p 443:3000 -p 80:3000 ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
+ docker run --name my-app -d -p 443:3000 -p 80:3000 $CONTAINER_REGISTRY/my-app:latest
docker cp /var/env/.env my-app:/app/.env
- '
+ ENDSSH
+ EOF
\ No newline at end of file
diff --git a/BackEnd/public/index.html b/BackEnd/public/index.html
new file mode 100644
index 00000000..2121d7b4
--- /dev/null
+++ b/BackEnd/public/index.html
@@ -0,0 +1,90 @@
+
+
+
+
+
+ We-Tri Triathlon App Download
+
+
+
+
+ We-Tri: 트라이 애슬론을 우리와 함께해요
+
+
+
+
+ 이 곳은 데모 앱 설치 화면이에요. 등록되지 않은 분들은 설치할 수
+ 없어요.
+
+
+
+
+
+
+
diff --git a/BackEnd/src/app.controller.spec.ts b/BackEnd/src/app.controller.spec.ts
old mode 100755
new mode 100644
index d22f3890..9bb2d61b
--- a/BackEnd/src/app.controller.spec.ts
+++ b/BackEnd/src/app.controller.spec.ts
@@ -1,22 +1,27 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
-import { AppService } from './app.service';
+import { Response } from 'express';
describe('AppController', () => {
let appController: AppController;
+ let mockResponse: Response;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
- providers: [AppService],
}).compile();
appController = app.get(AppController);
+ mockResponse = {
+ sendFile: jest.fn(),
+ } as unknown as Response;
});
- describe('root', () => {
- it('should return "Hello World!"', () => {
- expect(appController.getHello()).toBe('Hello World!');
+ describe('indexHTML', () => {
+ it('should call sendFile', () => {
+ appController.indexHTML(mockResponse);
+ expect(mockResponse.sendFile).toHaveBeenCalled();
});
});
});
+
diff --git a/BackEnd/src/app.controller.ts b/BackEnd/src/app.controller.ts
index cce879ee..e92da980 100755
--- a/BackEnd/src/app.controller.ts
+++ b/BackEnd/src/app.controller.ts
@@ -1,12 +1,11 @@
-import { Controller, Get } from '@nestjs/common';
-import { AppService } from './app.service';
+import { Controller, Get, Res } from '@nestjs/common';
+import { Response } from 'express';
+import { join } from 'path';
@Controller()
export class AppController {
- constructor(private readonly appService: AppService) {}
-
@Get()
- getHello(): string {
- return this.appService.getHello();
+ indexHTML(@Res() response: Response): void {
+ response.sendFile(join(__dirname, '..', 'public', 'index.html'));
}
}
diff --git a/BackEnd/src/app.module.ts b/BackEnd/src/app.module.ts
index 5c3c7863..5e43b58d 100755
--- a/BackEnd/src/app.module.ts
+++ b/BackEnd/src/app.module.ts
@@ -1,6 +1,5 @@
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller';
-import { AppService } from './app.service';
import { typeOrmConfig } from './config/typeorm.config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { LoggerMiddleware } from './middlewares/logger.middleware';
@@ -16,7 +15,6 @@ import { ProfilesModule } from './profiles/profiles.module';
ProfilesModule,
],
controllers: [AppController],
- providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
diff --git a/BackEnd/src/app.service.ts b/BackEnd/src/app.service.ts
deleted file mode 100755
index 927d7cca..00000000
--- a/BackEnd/src/app.service.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Injectable } from '@nestjs/common';
-
-@Injectable()
-export class AppService {
- getHello(): string {
- return 'Hello World!';
- }
-}
diff --git a/BackEnd/src/main.ts b/BackEnd/src/main.ts
index 5f2cb273..cfec1c88 100755
--- a/BackEnd/src/main.ts
+++ b/BackEnd/src/main.ts
@@ -5,6 +5,7 @@ import { winstonLogger } from './config/winston.config';
import { ValidationPipe } from '@nestjs/common';
import { ResponseTransformInterceptor } from './common/Interceptors/responseTransform. Interceptor';
import { HttpExceptionFilter } from './common/exceptionFilters/httpException.filter';
+import * as express from 'express';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
@@ -13,6 +14,7 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalInterceptors(new ResponseTransformInterceptor());
+ app.use('/static', express.static('public'));
SwaggerSetting(app);
await app.listen(3000);
}