diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 009798c..4ffbd12 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -3,35 +3,26 @@ name: CD-Sonar Metrics Collector on: workflow_dispatch: push: - branches: - - main + branches: + - main jobs: build: + name: Deploy-ssh runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Node.js - uses: actions/setup-node@v2 + - name: Executing remote ssh commands + uses: appleboy/ssh-action@v1.0.0 with: - node-version: '18.x' - - - name: NPM install and build - run: | - npm install - npm run build - - - name: Deploy-ssh - run: | - ssh-keyscan -t rsa -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts - ssh -i ${{ secrets.SSH_PRIVATE_KEY }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} ' + host: ${{ secrets.SSH_HOST }} + port: ${{ secrets.SSH_PORT }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | cd db1-projects/sonar-metrics-collector/; - docker container stop sonar-metrics-collector || true; - docker rm sonar-metrics-collector || true; + docker container stop sonar-metrics-collector; + docker rm sonar-metrics-collector; git pull origin main; - docker rmi sonar-metrics-collector || true; + docker rmi sonar-metrics-collector; docker build -t sonar-metrics-collector .; - docker run -d -t -i -e npm run start:prod -p 5100:5100 --name sonar-metrics-collector sonar-metrics-collector; + docker run -d -t -i -p 5100:5100 --net metrics-collector --name sonar-metrics-collector sonar-metrics-collector:latest npm run start:prod diff --git a/Dockerfile b/Dockerfile index b0efe99..5610382 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,14 +13,14 @@ RUN npm install pm2 -g RUN npm install # Copia o código fonte -COPY .env.prod .env +## COPY .env.prod .env COPY . . # Compila o TypeScript RUN npm run build # Define a porta em que o servidor irá escutar -EXPOSE 3030 +EXPOSE 5100 # Comando para iniciar o servidor -CMD ["pm2", "start" , "dist/main.js", "--no-daemon"] \ No newline at end of file +CMD ["pm2", "start" , "dist/main.js", "--no-daemon"] diff --git a/ecosystem.config.js b/ecosystem.config.js index 7f17669..e57ffe4 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -7,7 +7,7 @@ module.exports = { exec_mode: 'cluster', env: { NODE_ENV: 'production', - PORT: 3030, + PORT: 5100, }, }, ],