Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellol77 committed Sep 25, 2024
1 parent 619ffa0 commit a08ebee
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backend-prod-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
port: ${{ secrets.SSH_PORT }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull ${{ secrets.DOCKER_USERNAME }}/siso-backend:latest
docker stop siso-backend || true
docker rm siso-backend || true
docker run -d --env-file /home/ubuntu/env/backend.env -p 80:80 --name siso-backend ${{ secrets.DOCKER_USERNAME }}/siso-backend:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/siso-backend:latest
docker run -d -p 80:80 -p 443:443 --env-file /home/ubuntu/env/backend.env --name siso-backend -v /etc/letsencrypt:/etc/letsencrypt ${{ secrets.DOCKER_USERNAME }}/siso-backend:latest
82 changes: 78 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,82 @@
FROM node:18
RUN mkdir -p /var/app
WORKDIR /var/app
# FROM node:18
# RUN mkdir -p /var/app
# WORKDIR /var/app
# COPY . .
# RUN npm install
# RUN npm run build
# EXPOSE 80
# CMD [ "node", "dist/main.js" ]


# FROM node:19-alpine AS builder

# WORKDIR /usr/src/app

# COPY . .

# RUN npm install
# RUN npm run build

# FROM node:19-alpine AS Release

# WORKDIR /app

# COPY --from=builder /usr/src/app/dist /app/dist

# FROM nginx:latest

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

# COPY ./nginx.conf /etc/nginx/conf.d/default.conf

# RUN rm -rf ./usr/share/nginx/html/*

# COPY --from=Release /app/dist ./usr/share/nginx/html/

# EXPOSE 80
# EXPOSE 443

# ENTRYPOINT ["nginx", "-g", "daemon off;"]

# Node.js 빌드를 위한 스테이지
FROM node:19-alpine AS builder

WORKDIR /usr/src/app

COPY . .

RUN npm install
RUN npm run build

# Node.js 서버 실행을 위한 스테이지
FROM node:19-alpine AS release

WORKDIR /app

COPY --from=builder /usr/src/app /app

# Nginx 설정을 위한 스테이지
FROM nginx:latest

# 기존의 기본 Nginx 설정 제거
RUN rm /etc/nginx/conf.d/default.conf

# 새로운 Nginx 설정 복사
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

# 정적 파일을 제공하는 폴더를 비우기
RUN rm -rf /usr/share/nginx/html/*

# 정적 파일을 제공하는 폴더에 빌드된 파일 복사
COPY --from=release /app/dist /usr/share/nginx/html/

# Nginx가 80 및 443 포트를 노출하도록 설정
EXPOSE 80
CMD [ "node", "dist/main.js" ]
EXPOSE 443

# Node.js 애플리케이션을 백그라운드에서 실행하기 위한 명령 추가
# CMD를 사용하여 Node.js 서버를 백그라운드에서 실행
CMD ["node", "/app/dist/main.js"] &

# Nginx를 포그라운드에서 실행
ENTRYPOINT ["nginx", "-g", "daemon off;"]
24 changes: 24 additions & 0 deletions backend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {
listen 80;
server_name api.siso-balance-game.com;

location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name api.siso-balance-game.com;

ssl_certificate /etc/letsencrypt/live/api.siso-balance-game.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.siso-balance-game.com/privkey.pem;

location / {
proxy_pass http://localhost; # Assuming your NestJS app runs on port 3000
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
2 changes: 1 addition & 1 deletion backend/src/game/game.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class GameController {
async findGamesByUserId(
@Req() req: Request,
@Query('page') page: number = 1, // 페이지 번호
@Query('limit') limit: number = 10, // 페이지당 항목
@Query('limit') limit: number = 10, // 페이지당 아이템
): Promise<GameDto[]> {
const kakaoId = req.user.kakaoId;
return this.gameService.findGamesByUserId(kakaoId, page, limit);
Expand Down

0 comments on commit a08ebee

Please sign in to comment.