diff --git a/.github/docker/include b/.github/docker/include new file mode 100644 index 00000000..b13c31f3 --- /dev/null +++ b/.github/docker/include @@ -0,0 +1,44 @@ +#!/bin/sh +# +# .github/docker/include +# +# Usage: source from layer script and call the functions +# +# Notes: +# - use sh/posix syntax only + +layer_begin() { + printf "=== %s:%s start ===\n\n" "${0}" "layer_begin()" + + printf "%s: %s\n" "$1" "$(date +%Y%m%d-%H%M%S)" >/etc/ci-image-info + cat /etc/ci-image-info + printf "\n" + + echo apt update + apt update || exit + printf "\n" + + echo apt list --upgradable + apt list --upgradable || exit + printf "\n" + + echo apt upgrade -y + apt upgrade -y || exit + printf "\n" + + printf "=== %s:%s end ===\n\n" "${0}" "layer_begin()" +} + +layer_end() { + printf "=== %s:%s start ===\n\n" "${0}" "layer_end()" + + echo apt-get clean + apt-get clean || exit + printf "\n" + + echo rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* || exit + printf "\n" + + printf "=== %s:%s end ===\n\n" "${0}" "layer_end()" +} diff --git a/.github/docker/layer-00.00-base-dependencies.sh b/.github/docker/layer-00.00-base-dependencies.sh new file mode 100755 index 00000000..adc86a16 --- /dev/null +++ b/.github/docker/layer-00.00-base-dependencies.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# this path from for the container +# shellcheck disable=SC1091 +. /.github/docker/include + +layer_begin "$@" + +PACKAGES="apt-utils bash coreutils curl jq moreutils sudo tmux vim-nox" + +echo apt install -y "${PACKAGES}" +# shellcheck disable=SC2086 +apt install -y ${PACKAGES} || exit +printf "\n" + +layer_end "$@" diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 517bcbea..189db115 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -133,8 +133,8 @@ jobs: printf "%s\n" "Hello World!" - name: Docker Build Summary [${{ matrix.os }}] run: |- - ORG_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}" - TOKEN="$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:vpayno/${ORG_IMAGE}:pull" | jq -r .access_token)" + ORG_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}" + TOKEN="$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ORG_IMAGE}:pull" | jq -r .access_token)" { printf "Docker Hub Image Info\n" curl -sS --header "Authorization: Bearer ${TOKEN}" "https://index.docker.io/v2/${ORG_IMAGE}/tags/list" | jq . diff --git a/Dockerfile b/Dockerfile index 2a471dcb..bb3f5406 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,21 @@ # -# Dockerfile: ci-generic-debian +# Dockerfile # From debian:bullseye-slim As ci-generic-base +COPY .github/docker /.github/docker + +RUN .github/docker/layer-00.00-base-dependencies.sh ci-generic-debian + # Copies your code file from your action repository to the filesystem path `/` of the container COPY .github/docker/entrypoint.sh /entrypoint.sh +RUN rm -rvf /.github + # app + args # Executes `entrypoint.sh` when the Docker container starts up ENTRYPOINT ["/entrypoint.sh"] -# extra args -# CMD [] +# Extra args +CMD []