Skip to content

Commit

Permalink
new group membership
Browse files Browse the repository at this point in the history
  • Loading branch information
tanquangduong committed Sep 18, 2024
1 parent 770f593 commit 5fe2ec6
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/cd-docker-ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,22 @@ jobs:
# Add the user to the docker group
sudo usermod -aG docker $USER
# Apply the new group membership
newgrp docker <<EONG
# Apply the new group membership and run Docker commands in a subshell
sudo su - $USER -c "
# Log in to Docker
echo "${{ secrets.DOCKERHUB_TOKEN }}" | sudo docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
# Log in to Docker
echo "${{ secrets.DOCKERHUB_TOKEN }}" | sudo docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
# Verify Docker login
docker info
# Verify Docker login
docker info
# Free up disk space
docker system prune -a -f
# Pull the Docker image and run the container
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest
docker stop ${{ env.DOCKERHUB_REPO }}-container || true
docker rm ${{ env.DOCKERHUB_REPO }}-container || true
docker run --name ${{ env.DOCKERHUB_REPO }}-container -d -p 8501:8501 ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest
EONG
# Free up disk space
docker system prune -a -f
# Pull the Docker image and run the container
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest
docker stop ${{ env.DOCKERHUB_REPO }}-container || true
docker rm ${{ env.DOCKERHUB_REPO }}-container || true
docker run --name ${{ env.DOCKERHUB_REPO }}-container -d -p 8501:8501 ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest
"
EOF

0 comments on commit 5fe2ec6

Please sign in to comment.