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

Implement Automatic EC2 Deployment on Main Branch Updates #4

Open
4 of 5 tasks
SverreNystad opened this issue Dec 30, 2023 · 8 comments · Fixed by #5
Open
4 of 5 tasks

Implement Automatic EC2 Deployment on Main Branch Updates #4

SverreNystad opened this issue Dec 30, 2023 · 8 comments · Fixed by #5
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@SverreNystad
Copy link
Collaborator

SverreNystad commented Dec 30, 2023

The Cogito Backend needs to have a CI/CD pipeline to make sure everything works and to automatically deploy changes. The application is hosted on an AWS EC2 instance and the codebase is stored on GitHub. I want to automate the deployment process so that any new commits pushed to the main branch automatically trigger an update on the EC2 instance.

Acceptance Criteria:

@SverreNystad
Copy link
Collaborator Author

SverreNystad commented Dec 31, 2023

@sandviklee I need you to set secrete EC2_SSH_PRIVATE_KEY of the SSH key, i also need EC2_HOST name and EC2_USERNAME for the CD pipeline

name: Deploy to EC2
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Setup SSH
      run: |
        mkdir -p ~/.ssh
        echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
        chmod 600 ~/.ssh/id_rsa
        ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts

    - name: Deploy to EC2
      env:
        EC2_HOST: ${{ secrets.EC2_HOST }}
        EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
      run: |
        ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST 'bash -s' < ./deploy_to_ec2.sh

@SverreNystad
Copy link
Collaborator Author

This video shows how to create CD:
https://www.youtube.com/watch?v=zCz6xEFqOXE

@sandviklee
Copy link
Member

@SverreNystad
Copy link
Collaborator Author

As we dockerize the container the process of automatically updating production on commits on the main branch will be easier #22

@SverreNystad
Copy link
Collaborator Author

For using Portianer we need to things:

  • Portainer with HTTPS.
    • NGINX proxy manager can do it, and it pretty simple

@SverreNystad
Copy link
Collaborator Author

Portainer.io has an automatic update feature so it can update the server from github repo. It also have good support for stacks of containers making it much easier to connect all the depolyed systems to the backend without using ssh.

@SverreNystad
Copy link
Collaborator Author

This option seems better for security and scalability according Eduard

@SverreNystad
Copy link
Collaborator Author

As the EC2 instance does not have space for portainer or much more any new projects of moderate size. Portainer can not be taken in use. We need to find a way to get more storage.

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

Successfully merging a pull request may close this issue.

2 participants