-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from k4my4b/new_oci_base
New oci base
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build and publish docker-cloud/base OCI package(s) | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
paths: ["base/**"] | ||
|
||
jobs: | ||
build_and_publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build and push the OCI base image to ghcr.io | ||
run: | | ||
docker login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io | ||
docker build ./base --tag ghcr.io/${{ github.actor }}/base:latest | ||
docker push ghcr.io/${{ github.actor }}/base:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM alpine:3.19 | ||
|
||
RUN apk add --no-cache parallel grml-zsh-config | ||
|
||
COPY --chmod=775 init.d /init.d | ||
COPY --chmod=755 init.sh /init.sh | ||
COPY --chmod=775 healthcheck.d /healthcheck.d | ||
COPY --chmod=755 healthcheck.sh /healthcheck.sh | ||
|
||
ENTRYPOINT ["/init.sh"] | ||
CMD ["/init.d/start", "/init.d/stop"] | ||
|
||
HEALTHCHECK CMD ["/healthcheck.sh", "/healthcheck.d"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Default healthcheck directory is /healthcheck.d if not passed as an argument | ||
DIR="${1:-/healthcheck.d}" | ||
|
||
# Find executable files in the healthcheck directory and run them in parallel | ||
find "$DIR" -type f -executable | parallel --will-cite --halt 2 'sh {}' || { | ||
echo "Container is unhealthy!" | ||
kill -TERM 1 | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
|
||
echo "Starting up, hello!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
|
||
echo "Shutting down, goodbye!" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Default starting directory is /init.d/start if not passed as argument | ||
INDIR="${1:-/init.d/start}" | ||
|
||
# Default stoppping directory is /init.d/stop if not passed as argument | ||
EDIR="${2:-/init.d/stop}" | ||
|
||
batch_and_run_in_parallel() { | ||
# Find and sort scripts | ||
find "$1" -type f -executable -name '[0-9]*' | sort -V | \ | ||
# Group the scripts of the same priority together | ||
awk ' | ||
{ | ||
split($0, arr, "/") | ||
file = arr[length(arr)] | ||
num = substr(file, 1, index(file, "-") - 1) | ||
if (num != prev) { | ||
if (NR > 1) { | ||
print "" | ||
} | ||
prev = num | ||
} | ||
printf "%s ", $0 | ||
} | ||
END { print "" } | ||
' | \ | ||
# Execute scripts of the same priority (same group) in parallel | ||
# Exit as soon as a script fails to execute properly | ||
while IFS= read -r scripts; do | ||
parallel --will-cite --halt 2 -k -u -d ' ' sh {} ::: $scripts || { | ||
kill -TERM 1 | ||
exit 1 | ||
} | ||
done | ||
} | ||
|
||
trap 'batch_and_run_in_parallel "$EDIR"' TERM EXIT | ||
|
||
batch_and_run_in_parallel "$INDIR" |