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

feat: User Server 배포 #14

Open
Hong-Study opened this issue Feb 16, 2024 · 3 comments
Open

feat: User Server 배포 #14

Hong-Study opened this issue Feb 16, 2024 · 3 comments
Assignees

Comments

@Hong-Study
Copy link
Collaborator

유저 서버를 배포

  • GCP에 유저 서버 배포하기
  • MSSQL, Redis 배포
  • 배포한 서버 연동
@Hong-Study
Copy link
Collaborator Author

Hong-Study commented Feb 16, 2024

Jenkins 파이프라인 설정

pipeline {
    agent any
    tools {
        gradle 'gradle'
    }
    stages {
        stage('Github') {
            steps {
                checkout scmGit(
                    branches: [[name: 'BE/hjh']],
                    extensions: [submodule(parentCredentials: true, trackingSubmodules: true)],
                    userRemoteConfigs: [[credentialsId: 'moon-token', url: 'https://github.com/sgdevcamp2023/remember']]
                    )
            }
        }
    
        
        stage('Restore') {
            steps {
                dir('src/backend/user-service') {
                    // NuGet 패키지 복원
                    sh 'dotnet restore'
                }
            }
        }
        
        stage('Build') {
            steps {
                dir('src/backend/user-service') {
                    // 프로젝트 빌드
                    sh 'dotnet build -c Release'
                }
            }
        }
        
        stage('Publish') {
            steps {
                dir('src/backend/user-service') {
                    // 프로젝트 publish
                    sh 'dotnet publish -c Release -o ./publish'
                }
            }
        }

        stage('Deploy') {
                        steps {        
                sshagent (credentials: ['harmony-ssh']) {
                sh """
                    scp -r /var/jenkins_home/workspace/user-service/src/backend/user-service/publish harmony@10.178.0.3:/home/harmony/
                """
                sh """
                    ssh -o StrictHostKeyChecking=no ${TARGET_HOST} '
                    make down-user
                    make up-user
                    '
                """
                }
            }
        }
    }
    environment {
        TARGET_HOST = "harmony@10.178.0.3"
    }
}

@Hong-Study
Copy link
Collaborator Author

도커 파일 구현

FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 5000

ENV ASPNETCORE_URLS=http://*:5000

RUN chmod 777 /var/log
RUN chmod 777 /var

COPY publish .
ENTRYPOINT ["dotnet", "user-service.dll"]

@Hong-Study
Copy link
Collaborator Author

또한, IP의 경우 0.0.0.0으로 설정함

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants