Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWL-66] ipa 파일을 Object 스토리지에 저장후 API 메인에서 다운 받을 수 있도록 구현, CD 수정 #88

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 44 additions & 11 deletions .github/workflows/BackEnd_CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
90 changes: 90 additions & 0 deletions BackEnd/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>We-Tri Triathlon App Download</title>
<style>
body, html {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
font-family: 'Arial', sans-serif;
background-color: #F6F6FE;
color: #555;
}

header {
background-color: #5F5FF9; /* Main-03 color */
color: white;
padding: 20px 0;
text-align: center;
}

main {
display: flex;
flex-direction: column;
flex: 1;
justify-content: center;
align-items: center;
text-align: center;
}

.app-info {
margin-bottom: 30px;
}

.downloads .download-button {
background-color: #E1E1FA; /* Main-02 color */
color: #333;
padding: 10px 15px;
margin: 10px;
text-decoration: none;
display: inline-block;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

footer {
display: flex;
background-color: #333;
color: white;
padding: 10px 0;
align-items: center;
justify-content: center;
text-align: center;
}

.download-button:hover {
background-color: #5F5FF9; /* Main-01 color */
}
</style>
</head>
<body>
<header>
<h1>We-Tri: 트라이 애슬론을 우리와 함께해요</h1>
</header>
<main>
<section class="app-info">
<p>
이 곳은 데모 앱 설치 화면이에요. 등록되지 않은 분들은 설치할 수
없어요.
</p>
</section>
<section class="downloads">
<a
href="itms-services://?action=download-manifest&amp;url=https://kr.object.ncloudstorage.com/wetri-ios-ipa/iOS/manifest.plist"
class="download-button week-2"
>Download Week 2 App</a
>
<a href="#" class="download-button week-3">Download Week 3 App</a>
</section>
</main>
<footer>
<p>&copy; 2023 We-Tri. All rights reserved.</p>
</footer>
</body>
</html>
11 changes: 5 additions & 6 deletions BackEnd/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -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'));
}
}
2 changes: 0 additions & 2 deletions BackEnd/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -16,7 +15,6 @@ import { ProfilesModule } from './profiles/profiles.module';
ProfilesModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
Expand Down
8 changes: 0 additions & 8 deletions BackEnd/src/app.service.ts

This file was deleted.

2 changes: 2 additions & 0 deletions BackEnd/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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);
}
Expand Down
Loading