mirror of https://github.com/langgenius/dify.git
feat: use gha as cache
This commit is contained in:
parent
c20dd0985c
commit
f7d69b9288
|
|
@ -26,14 +26,7 @@ if [[ "${REFSPEC}" == "main" ]]; then
|
|||
CACHE_FROM_TAG="latest"
|
||||
fi
|
||||
|
||||
echo "Pulling cache image ${API_REPO_NAME}:${CACHE_FROM_TAG}"
|
||||
if docker buildx imagetools create cache-image --name=${API_REPO_NAME}:${CACHE_FROM_TAG} -platform=linux/amd64,linux/arm64; then
|
||||
API_CACHE_FROM_SCRIPT="--cache-from cache-image"
|
||||
else
|
||||
echo "WARNING: Failed to pull ${API_REPO_NAME}:${CACHE_FROM_TAG}, disable build image cache."
|
||||
API_CACHE_FROM_SCRIPT=""
|
||||
fi
|
||||
|
||||
docker buildx create --use --driver=docker-container
|
||||
|
||||
cat<<EOF
|
||||
Rolling with tags:
|
||||
|
|
@ -47,7 +40,8 @@ EOF
|
|||
#
|
||||
cd api
|
||||
docker buildx build \
|
||||
${API_CACHE_FROM_SCRIPT} \
|
||||
--cache-to type=gha,mode=max,scope=$CACHE_FROM_TAG-image \
|
||||
--cache-from type=gha,mode=max,scope=$CACHE_FROM_TAG-image \
|
||||
--platform=linux/amd64,linux/arm64 \
|
||||
--build-arg COMMIT_SHA=${SHA} \
|
||||
-t "${API_REPO_NAME}:${SHA}" \
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ jobs:
|
|||
username: ${{ secrets.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Expose GitHub Runtime
|
||||
uses: crazy-max/ghaction-github-runtime@v2
|
||||
|
||||
- name: Build and push Docker image
|
||||
shell: bash
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -26,14 +26,7 @@ if [[ "${REFSPEC}" == "main" ]]; then
|
|||
CACHE_FROM_TAG="latest"
|
||||
fi
|
||||
|
||||
echo "Pulling cache image ${WEB_REPO_NAME}:${CACHE_FROM_TAG}"
|
||||
if docker buildx imagetools create cache-image --name=${WEB_REPO_NAME}:${CACHE_FROM_TAG} -platform=linux/amd64,linux/arm64; then
|
||||
WEB_CACHE_FROM_SCRIPT="--cache-from cache-image"
|
||||
else
|
||||
echo "WARNING: Failed to pull ${WEB_REPO_NAME}:${CACHE_FROM_TAG}, disable build image cache."
|
||||
WEB_CACHE_FROM_SCRIPT=""
|
||||
fi
|
||||
|
||||
docker buildx create --use --driver=docker-container
|
||||
|
||||
cat<<EOF
|
||||
Rolling with tags:
|
||||
|
|
@ -47,7 +40,8 @@ EOF
|
|||
#
|
||||
cd web
|
||||
docker buildx build \
|
||||
${WEB_CACHE_FROM_SCRIPT} \
|
||||
--cache-to type=gha,mode=max,scope=$CACHE_FROM_TAG-image \
|
||||
--cache-from type=gha,mode=max,scope=$CACHE_FROM_TAG-image \
|
||||
--build-arg COMMIT_SHA=${SHA} \
|
||||
--platform=linux/amd64,linux/arm64 \
|
||||
-t "${WEB_REPO_NAME}:${SHA}" \
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ jobs:
|
|||
username: ${{ secrets.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Expose GitHub Runtime
|
||||
uses: crazy-max/ghaction-github-runtime@v2
|
||||
|
||||
- name: Build and push Docker image
|
||||
shell: bash
|
||||
env:
|
||||
|
|
|
|||
Loading…
Reference in New Issue