From b0abaaa3c528a22699662257b53553e7ce03bd26 Mon Sep 17 00:00:00 2001 From: MinusFour Date: Fri, 25 Sep 2020 11:28:45 -0500 Subject: [PATCH 1/2] Force container recreation on workflow Docker compose has a problem with running containers names. If container names are the same they need to be recreated or they'll clash. This also removes trailing whitespace. --- .github/workflows/deployment.yml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index def96d8..17597a0 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -8,23 +8,19 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - - name: Login to GHCR + - name: Login to GHCR uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-qemu-action@v1 with: platforms: all - - - name: Create builder + - name: Create builder uses: docker/setup-buildx-action@v1 - - - name: Build and push docker image + - name: Build and push docker image uses: docker/build-push-action@v2 with: context: . @@ -43,8 +39,7 @@ jobs: SSH_PORT: ${{ secrets.SSH_PORT }} steps: - uses: actions/checkout@v2 - - - name: Set SSH client + - name: Set SSH client env: SSH_PRIVATE_KEY: ${{ secrets.GA_PRIV_KEY }} HOST_KEY: ${{ secrets.HOST_KEY }} @@ -58,18 +53,15 @@ jobs: echo "$SSH_HOST $HOST_KEY" > $HOME/.ssh/known_hosts echo ::set-env name=SSH_AUTH_SOCK::$SSH_AUTH_SOCK echo ::set-env name=SSH_AGENT_PID::$SSH_AGENT_PID - - - name: Set DOCKER_HOST + - name: Set DOCKER_HOST run: echo "::set-env name=DOCKER_HOST::ssh://$SSH_USER@$SSH_HOST:$SSH_PORT" - - - name: Login to GHCR + - name: Login to GHCR uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - - name: Pull image and run in host + - name: Pull image and run in host run: | - docker-compose pull - docker-compose up -d + docker-compose pull --quiet + docker-compose up --force-recreate -d From 683f9f30de860968753d46bdaefe90aa7f4ea307 Mon Sep 17 00:00:00 2001 From: MinusFour Date: Fri, 25 Sep 2020 11:35:10 -0500 Subject: [PATCH 2/2] Use layer caching for docker worfklows This will make the github jobs run faster by caching the image layers. Current layers shouldn't be that big so this is a small optimization. It's unknown how much free disk space it's using to cache the layers. --- .github/workflows/deployment.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 17597a0..9e360a3 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -20,6 +20,9 @@ jobs: - name: Create builder uses: docker/setup-buildx-action@v1 + - uses: satackey/action-docker-layer-caching@v0.0.8 + continue-on-error: true + - name: Build and push docker image uses: docker/build-push-action@v2 with: