Skip to content

Merge pull request #12 from wintermeyer/refactoring #2

Merge pull request #12 from wintermeyer/refactoring

Merge pull request #12 from wintermeyer/refactoring #2

Workflow file for this run

name: Docker build
on: push
jobs:
build:
runs-on: ${{ matrix.os }}
name: OS ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
timeout-minutes: 15
permissions:
actions: write
steps:
- name: Checkout
uses: actions/checkout@v4
timeout-minutes: 5
# Pull the latest image to build, and avoid caching pull-only images.
# (docker pull is faster than caching in most cases.)
- name: Docker-Compose pull
run: docker-compose pull
# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- name: action-docker-layer-caching
uses: jpribyl/action-docker-layer-caching@v0.1.1
# Ignore the failure of a step and avoid terminating the job:
continue-on-error: true
- name: Build containers
run: DOCKER_BUILDKIT=0 docker-compose build
timeout-minutes: 10
- name: Start containers
run: |
docker-compose up &
elapsed=0
while [ $elapsed -le 120 ]
do
state_db="$( docker container ls --filter "name=animina[\\-_]db" --format="{{.State}}" )"
state_web="$( docker container ls --filter "name=animina[\\-_]web" --format="{{.State}}" )"
if [[ "$state_db" == "running" ]] && [[ "$state_web" == "running" ]]; then
echo "All containers are running."
echo "Waiting for post-up actions ..."
sleep 20
echo "Done waiting."
exit 0
fi
echo "Containers not running yet (state_db=${state_db}, state_web=${state_web})."
docker container ls
sleep 5
elapsed=$((elapsed + 5))
done
echo "Containers failed to start."
exit 1
# Note that the docs for COMPOSE_PROJECT_NAME say that the container
# name is "{compose_project_name}-{service_name}", and it is like that
# indeed when using Docker Desktop, but on ubuntu-22.04 on GitHub a
# "_" is used as separator.
# https://web.archive.org/web/20240106171030/https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
timeout-minutes: 2
- name: Stop containers
if: always()
run: docker-compose down
timeout-minutes: 1
# Finally, "Post Run jpribyl/action-docker-layer-caching@v0.1.1",
# which is the process of saving the cache, will be executed.
# For Emacs:
# Local Variables:
# mode: yaml
# indent-tabs-mode: nil
# tab-width: 2
# c-basic-offset: 2
# End:
#
# For VIM:
# vim: set softtabstop=2 shiftwidth=2 tabstop=2 expandtab: