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 required: true
runs: runs:
using: composite using: docker
steps: image: Dockerfile
- 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 }}

View File

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