feat: docker cache
This commit is contained in:
parent
fe4a97adf3
commit
b7c1391e9a
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM gcr.io/kaniko-project/executor:debug
|
||||||
|
COPY build.sh /usr/local/bin/
|
||||||
|
ENTRYPOINT ["build.sh"]
|
13
action.yaml
13
action.yaml
@ -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 }}
|
|
||||||
|
28
build.sh
28
build.sh
@ -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"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user