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

Use docker/build-push-action to cache docker build #1696

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 23 additions & 20 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,11 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true
driver: docker

- name: Notify workflow starting
uses: voxmedia/github-action-slack-notify-build@v1
continue-on-error: true
if: success()
id: slack
with:
channel_id: ${{ secrets.SLACK_NOTIFICATIONS_CHANNEL_ID }}
status: STARTING
color: warning
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}

- name: Setup
run: bash -c 'mkdir -p ./freesound-data/{packs,uploads,avatars} && echo FS_USER_ID_FROM_ENV=$(id -u) > .env && cp freesound/local_settings.example.py freesound/local_settings.py'

Expand All @@ -42,17 +30,32 @@ jobs:
run: echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
continue-on-error: true

- name: Pull docker images
run: docker-compose -f docker-compose.test.yml pull
- name: Build base image
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile.base
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
load: true

- uses: jpribyl/action-docker-layer-caching@v0.1.1
continue-on-error: true
- name: check images
run: docker image ls

- name: Build base image
run: make -C docker
- name: Build cached image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile.workers_web
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Pull docker images
run: docker-compose -f docker-compose.test.yml pull

- name: Build images
run: docker-compose -f docker-compose.test.yml build db test_runner
run: docker-compose -f docker-compose.test.yml build test_runner

- name: Run tests
run: docker-compose -f docker-compose.test.yml run --rm test_runner python manage.py test --noinput --settings=freesound.test_settings
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ version: "3.7"
services:
db:
image: postgres:12.1
volumes:
- pgdata:/var/lib/postgresql/data
env_file:
- environment
volumes:
- ./freesound-data/db_dev_dump:/freesound-data/db_dev_dump
ports:
- "5432:5432"
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.workers_web
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN make clean && make

# --- main Freesound docker file contents

FROM freesound:2023-07
FROM mtgupf/freesound:2023-07

RUN mkdir -p /etc/apt/keyrings/
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
Expand Down