Skip to content

Commit

Permalink
ci(build-docker): install curl and jq before creating image summary
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Aug 13, 2023
1 parent 6e7b137 commit b08c94b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
44 changes: 44 additions & 0 deletions .github/docker/include
Original file line number Diff line number Diff line change
@@ -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()"
}
16 changes: 16 additions & 0 deletions .github/docker/layer-00.00-base-dependencies.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
4 changes: 2 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 []

0 comments on commit b08c94b

Please sign in to comment.