ssh-action icon indicating copy to clipboard operation
ssh-action copied to clipboard

Docker build stuck

Open eneszv opened this issue 3 years ago • 1 comments

Hi, I'm trying to create the following deployment logic that will build and run a docker container on the AWS EC2 instance.

name: scp files
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Pull changes and run docker
      uses: fifsky/ssh-action@master
      with:
        command: |
          cd test_ec2_deployment
          git pull
          sudo docker build --network host -f Dockerfile -t test .
          sudo docker run -d --env-file=/home/ubuntu/.env -ti test
        host: ${{ secrets.HOST }}
        user: ubuntu
        key: ${{ secrets.SSH_KEY }}
        args: "-tt"

The problem is that at the end of the docker build it is stuck and doesn't run sudo docker run... command. This is the last output:

Step 12/13 : RUN /usr/bin/crontab /etc/cron.d/cron-job
 ---> Running in 52a5a0174958
Removing intermediate container 52a5a0174958
 ---> badf6fdaf774
Step 13/13 : CMD printenv > /etc/environment && cron -f
 ---> Running in 0e9fd12db4f7
Removing intermediate container 0e9fd12db4f7
 ---> 888a2a9e5910
Successfully built 888a2a9e5910
Successfully tagged test:latest

Any suggestions would be appreciated.

eneszv avatar Jun 26 '22 16:06 eneszv

I've managed to run the docker image by creating a separate deploy.sh file

#!/bin/bash
sudo docker build -f Dockerfile -t test .
sudo docker run -d --env-file=/home/ubuntu/.env -ti test

and updating action commands

...
command: |
    cd test_ec2_deployment
    git pull
    bash deploy.sh
...

but it is still stuck at the end of the bash script.

Step 13/13 : CMD printenv > /etc/environment && cron -f
 ---> Running in c5b23bcd4984
Removing intermediate container c5b23bcd4984
 ---> 249ca866ca31
Successfully built 249ca866ca31
Successfully tagged test:latest
64740418a0f38c7c23a10a5e572be2258640f8dadd0f4d9e717da5ab022192aa

Tried to add commands like printf "\033c" and sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' at the end of the script but didn't solve the problem.

eneszv avatar Jun 26 '22 18:06 eneszv