Skip to content

Commit

Permalink
UPDATE Cache Docker layers in Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vectornguyen76 committed Aug 18, 2023
1 parent 08606ac commit b7fb9bf
Showing 1 changed file with 11 additions and 39 deletions.
50 changes: 11 additions & 39 deletions .github/workflows/development_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,6 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

# - name: Cache Docker layers
# id: cache-docker
# uses: actions/cache@v2
# with:
# path: |
# ~/.docker
# key: ${{ runner.os }}-docker-${{ hashFiles('**/image-search-engine/Dockerfile') }}

# - name: Build Docker Image
# id: build_docker
# run: |
# docker compose build image_search

# # Add tag
# docker tag image_search_img:latest ${{ secrets.DOCKERHUB_USERNAME }}/image_search_img:latest

# - name: Push Docker Image
# id: push_images
# run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/image_search_img:latest

build-push-text-search:
runs-on: ubuntu-latest
env:
Expand All @@ -64,29 +44,21 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
id: docker_hub_auth
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Cache Docker layers
id: cache-docker
uses: actions/cache@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
path: |
~/.docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/text-search-engine/Dockerfile') }}

- name: Build Docker Image
id: build_docker
run: |
docker compose build text_search
# Add tag
docker tag text_search_img:latest ${{ secrets.DOCKERHUB_USERNAME }}/text_search_img:latest
- name: Push Docker Image
id: push_images
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/text_search_img:latest
context: ./text-search-engine
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/text_search_img:latest
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit b7fb9bf

Please sign in to comment.