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

Docker build stuck #30

Open
eneszv opened this issue Jun 26, 2022 · 1 comment
Open

Docker build stuck #30

eneszv opened this issue Jun 26, 2022 · 1 comment

Comments

@eneszv
Copy link

eneszv commented Jun 26, 2022

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
Copy link
Author

eneszv commented Jun 26, 2022

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.

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

1 participant