-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
184 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,113 @@ | ||
name: 'build docker images: static cURL' | ||
|
||
on: | ||
#push: | ||
# branches: | ||
# - 'main' | ||
# - 'master' | ||
# paths: | ||
# - 'static-curl.scratch.Dockerfile' | ||
# - '.github/workflows/build_docker_images-static-curl.yaml' | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '30 5 28 * *' # At 05:30 on day-of-month 28. | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Shell-Script | ||
id: script | ||
run: | | ||
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}" | ||
COMMIT_HASH=${GITHUB_SHA::8} | ||
GIT_URL=$(echo "${GITHUB_SERVER_URL}" | awk -F/ '{print $3}' | sed 's/\/*$//') | ||
GIT_URL=$(echo "$GIT_URL" | sed 's/github\.com/ghcr\.io/g') # GIT_URL switch to ghcr.io registry for GitHub | ||
GIT_REPO=${GITHUB_REPOSITORY,,} | ||
GIT_REPO_SHORT=${GIT_REPO#*/} | ||
GIT_REPO_SHORT=${GIT_REPO_SHORT#"docker-"} | ||
DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GIT_REPO_SHORT} | ||
REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GIT_REPO_SHORT} | ||
#echo "ENVs: BUILD_DATE=${BUILD_DATE}, BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}, COMMIT_HASH=${COMMIT_HASH}, GIT_URL=${GIT_URL}, GIT_REPO=${GIT_REPO}" | ||
# Set output parameters to action. | ||
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT" | ||
echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT" | ||
echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT" | ||
echo "git_url=${GIT_URL}" >> "$GITHUB_OUTPUT" | ||
echo "git_repo=${GIT_REPO}" >> "$GITHUB_OUTPUT" | ||
echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT" | ||
echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT" | ||
# static cURL | ||
CURL_VERSION=$(wget -qO- https://api.github.com/repos/stunnel/static-curl/releases/latest | grep 'tag_name' | cut -d\" -f4) | ||
echo "CURL_VERSION=${CURL_VERSION}" | ||
echo "curl_version=${CURL_VERSION}" >> "$GITHUB_OUTPUT" | ||
- name: Set up QEMU | ||
id: qemu | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
image: tonistiigi/binfmt:latest | ||
platforms: all | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GIT Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ steps.script.outputs.git_url }} | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to DockerHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Login to RED HAT Quay.io Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.REDHAT_QUAY_USERNAME }} | ||
password: ${{ secrets.REDHAT_QUAY_PASSWORD }} | ||
|
||
- name: Build | ||
uses: docker/build-push-action@v6 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./static-curl.scratch.Dockerfile | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x | ||
push: true | ||
build-args: | | ||
BUILD_DATE=${{steps.script.outputs.build_date}} | ||
VCS_REF=${{steps.script.outputs.commit_hash}} | ||
CURL_VERSION=${{steps.script.outputs.curl_version}} | ||
tags: | | ||
docker.io/${{steps.script.outputs.docker_repo}}:static-curl | ||
docker.io/${{steps.script.outputs.docker_repo}}:static-curl-${{steps.script.outputs.curl_version}} | ||
quay.io/${{steps.script.outputs.redhat_quay_repo}}:static-curl | ||
${{steps.script.outputs.git_url}}/${{steps.script.outputs.git_repo}}:static-curl | ||
#- name: Docker Hub Description | ||
# uses: peter-evans/dockerhub-description@v4 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
# repository: ${{steps.script.outputs.docker_repo}} | ||
# short-description: ${{ github.event.repository.description }} | ||
# readme-filepath: README.md |
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,71 @@ | ||
# build: docker build --no-cache --progress=plain --build-arg CURL_VERSION=8.11.0 -t tobi312/tools:static-curl -f static-curl.scratch.Dockerfile . | ||
FROM alpine:latest AS static-curl | ||
|
||
# curl: https://github.com/stunnel/static-curl | ||
# (Alternatives: https://github.com/moparisthebest/static-curl/releases or https://github.com/perryflynn/static-binaries) | ||
|
||
ARG CURL_VERSION | ||
ARG CURL_LIBC="musl" | ||
|
||
RUN \ | ||
set -ex ; \ | ||
apk add --no-cache \ | ||
ca-certificates \ | ||
#curl \ | ||
; \ | ||
ARCH=`uname -m` ; \ | ||
echo "ARCH=$ARCH" ; \ | ||
if [ "$ARCH" == "x86_64" ]; then \ | ||
echo "x86_64 (amd64)" ; \ | ||
TARGETARCH="$ARCH"; \ | ||
elif [ "$ARCH" == "aarch64" ]; then \ | ||
echo "aarch64 (arm64)" ; \ | ||
TARGETARCH="$ARCH"; \ | ||
elif [ "$ARCH" == "armv7l" ]; then \ | ||
echo "armv7 (arm)" ; \ | ||
TARGETARCH="armv7"; \ | ||
elif [ "$ARCH" == "riscv64" ]; then \ | ||
echo "riscv64" ; \ | ||
TARGETARCH="$ARCH"; \ | ||
elif [ "$ARCH" == "ppc64le" ]; then \ | ||
echo "ppc64le" ; \ | ||
TARGETARCH="powerpc64le"; \ | ||
elif [ "$ARCH" == "s390x" ]; then \ | ||
echo "s390x" ; \ | ||
TARGETARCH="$ARCH"; \ | ||
else \ | ||
echo "unknown arch" ; \ | ||
exit 1; \ | ||
fi ; \ | ||
export TARGETARCH=${TARGETARCH} ; \ | ||
#CURL_VERSION=${CURL_VERSION:-$(curl -s https://api.github.com/repos/stunnel/static-curl/releases/latest | grep 'tag_name' | cut -d\" -f4)} ; \ | ||
CURL_VERSION=${CURL_VERSION:-$(wget -qO- https://api.github.com/repos/stunnel/static-curl/releases/latest | grep 'tag_name' | cut -d\" -f4)} ; \ | ||
echo "CURL_VERSION=${CURL_VERSION}" ; \ | ||
#curl -sqL https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-linux-${TARGETARCH}-${CURL_LIBC}-${CURL_VERSION}.tar.xz | tar -xJ -C /usr/local/bin/ curl ; \ | ||
wget -qO- https://github.com/stunnel/static-curl/releases/download/${CURL_VERSION}/curl-linux-${TARGETARCH}-${CURL_LIBC}-${CURL_VERSION}.tar.xz | tar -xJ -C /usr/local/bin/ curl ; \ | ||
/usr/local/bin/curl --version | ||
|
||
FROM scratch | ||
|
||
ARG CURL_VERSION | ||
ARG VCS_REF | ||
ARG BUILD_DATE | ||
|
||
LABEL org.opencontainers.image.title="cURL" \ | ||
org.opencontainers.image.authors="cURL Community, Tobias Hargesheimer <[email protected]>" \ | ||
org.opencontainers.image.version="${CURL_VERSION}" \ | ||
org.opencontainers.image.created="${BUILD_DATE}" \ | ||
org.opencontainers.image.revision="${VCS_REF}" \ | ||
org.opencontainers.image.description="Static cURL - A command line tool and library for transferring data with URL syntax." \ | ||
org.opencontainers.image.documentation="https://curl.se/" \ | ||
org.opencontainers.image.licenses="MIT" \ | ||
org.opencontainers.image.base.name="scratch" \ | ||
org.opencontainers.image.url="https://github.com/Tob1as/docker-tools" \ | ||
org.opencontainers.image.source="https://github.com/stunnel/static-curl" | ||
|
||
COPY --from=static-curl /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=static-curl /usr/local/bin/curl /usr/bin/curl | ||
|
||
ENTRYPOINT ["/usr/bin/curl"] | ||
#CMD ["--version"] | ||
#CMD ["--help", "all"] |