feat: docker cache

This commit is contained in:
ange 2024-05-02 17:10:52 +02:00
parent fe4a97adf3
commit b7c1391e9a
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
3 changed files with 16 additions and 28 deletions

3
Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM gcr.io/kaniko-project/executor:debug
COPY build.sh /usr/local/bin/
ENTRYPOINT ["build.sh"]

View File

@ -16,14 +16,5 @@ inputs:
required: true
runs:
using: composite
steps:
- name: Build
run: ${{ gitea.action_path }}/build.sh
env:
- ACTION_DOCKERFILE=${{ inputs.dockerfile }}
- ACTION_TAG=${{ inputs.tag }}
- ACTION_REGISTRY=${{ gitea.server_url }}
- ACTION_IMAGE=${{ gitea.repository }}
- ACTION_USERNAME=${{ inputs.username }}
- ACTION_PASSWORD=${{ inputs.password }}
using: docker
image: Dockerfile

View File

@ -1,25 +1,19 @@
#!/bin/bash -e
#!/bin/sh -ex
exec 3<> /tmp/kaniko && rm /tmp/kaniko
cat <<EOF >&3
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"$ACTION_REGISTRY": {
"username": "$ACTION_USERNAME",
"password": "$ACTION_PASSWORD"
"$GITHUB_SERVER_URL": {
"username": "$INPUT_USERNAME",
"password": "$INPUT_PASSWORD"
}
}
}
EOF
REGISTRY="${ACTION_REGISTRY/https:\/\/}"
docker run --rm \
-v "$PWD:$PWD:ro" \
-v "$HOME/.cache/kaniko:/cache" \
-v "/proc/$$/fd/3:/kaniko/.docker/config.json:ro" \
gcr.io/kaniko-project/executor:latest \
--cache true \
--context "${ACTION_DOCKERFILE%/*}" \
--dockerfile "$ACTION_DOCKERFILE" \
--destination "$REGISTRY/$ACTION_IMAGE:$ACTION_TAG"
REGISTRY="$(echo "$GITHUB_SERVER_URL" | sed 's .*:// ')"
/kaniko/executor \
--cache=true \
--context "${INPUT_DOCKERFILE%/*}" \
--dockerfile "$INPUT_DOCKERFILE" \
--destination "$REGISTRY/$GITHUB_REPOSITORY:$INPUT_TAG"