Skip to content

Commit

Permalink
add docker installation & docker-compose up in ec2 deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
matbragan committed May 4, 2024
1 parent 4db1635 commit 5d60ed7
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,41 @@ jobs:
- name: Checkout the files
uses: actions/checkout@v3

- name: Check if Docker is installed
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Proceeding with installation."
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
else
echo "Docker is already installed."
fi
- name: Copy files with SSH
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{secrets.EC2_SSH_KEY}}
REMOTE_HOST: ${{secrets.EC2_HOST}}
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
REMOTE_HOST: ${{ secrets.EC2_HOST }}
REMOTE_USER: "ubuntu"
SOURCE: "./"
TARGET: "/home/ubuntu/ancine-database"
ARGS: "-rltgoDzvO --delete"
EXCLUDE: "/.git/, /.github/, /venv/, /downloads/, /__pycache__/"
EXCLUDE: "/.git/, /.github/, /venv/, /downloads/, **.env, /__pycache__/"
SCRIPT_AFTER: |
echo "Orchestration deployed"
cd /home/ubuntu/ancine-database && docker-compose up -d --build

0 comments on commit 5d60ed7

Please sign in to comment.