Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoFresh committed Aug 16, 2021
1 parent 6bf843a commit af70ac1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 63 deletions.
99 changes: 38 additions & 61 deletions .github/workflows/docker-compose-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,14 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ github.repository }}_app1
${{ github.repository }}_app2
${{ env.REGISTRY }}/${{ github.repository }}_app1
${{ env.REGISTRY }}/${{ github.repository }}_app2
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
Expand All @@ -64,38 +42,37 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# TODO: pull
- name: docker/build-push-action
uses: docker/build-push-action@v2
with:
context: ./app1
file: ./app1/Dockerfile
push: true
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
# - name: docker/build-push-action
# uses: docker/build-push-action@v2
# with:
# context: ./app1
# file: ./app1/Dockerfile
# push: true
# builder: ${{ steps.buildx.outputs.name }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
#
# - name: docker/build-push-action
# uses: docker/build-push-action@v2
# with:
# context: ./app2
# file: ./app2/Dockerfile
# push: true
# builder: ${{ steps.buildx.outputs.name }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: docker/build-push-action
uses: docker/build-push-action@v2
with:
context: ./app2
file: ./app2/Dockerfile
push: true
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- name: Build the stack
run: docker-compose build

# - name: Build the stack
# run: docker-compose build --pull --build-arg BUILDKIT_INLINE_CACHE=1
#
# - name: Push the stack
# run: docker-compose push
- name: Push the stack
run: docker-compose push

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# - name: Move cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ version: "3.9"

services:
app1:
build: app1
build:
context: ./app1
cache_from:
- ghcr.io/cyanofresh/docker-compose-ga-cache-example_app1
image: ghcr.io/cyanofresh/docker-compose-ga-cache-example_app1
ports:
- "3000:3000"
environment:
NODE_ENV: production
PORT: 3000
app2:
build: app2
build:
context: ./app2
cache_from:
- ghcr.io/cyanofresh/docker-compose-ga-cache-example_app2
image: ghcr.io/cyanofresh/docker-compose-ga-cache-example_app2
ports:
- "4000:4000"
Expand Down

0 comments on commit af70ac1

Please sign in to comment.