From c63bcd7706040099bb5a24293dc4e9a8400c548d Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 7 Jan 2023 18:16:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9docker=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_docker_image.yml | 8 +++++--- docker/Dockerfile | 15 +++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index e50dad88..03c2a5d9 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -5,7 +5,6 @@ on: branches: - 'master' - 'develop' - # Sequence of patterns matched against refs/tags tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 schedule: @@ -13,7 +12,6 @@ on: # note: 这里是GMT时间,北京时间减去八小时即可。如北京时间 22:30 => GMT 14:30 # minute hour day month dayOfWeek - cron: '00 14 * * *' # GMT 14:00 => 北京时间 22:00 - #- cron: '30 16 * * *' # GMT 16:30(前一天) => 北京时间 00:30 workflow_dispatch: jobs: @@ -155,12 +153,16 @@ jobs: build-args: | MAINTAINER=${{ github.repository_owner }} QL_BRANCH=${{ github.ref_name }} + SOURCE_COMMIT=${{ github.sha }} network: host platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 - context: docker/ + context: . + file: ./docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=whyour/qinglong:cache + cache-to: type=registry,ref=whyour/qinglong:cache,mode=max - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/docker/Dockerfile b/docker/Dockerfile index de16ce8a..8bdc5a6b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,8 +13,6 @@ ENV PNPM_HOME=/root/.local/share/pnpm \ QL_DIR=/ql \ QL_BRANCH=${QL_BRANCH} -WORKDIR ${QL_DIR} - RUN set -x \ && sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ && apk update -f \ @@ -42,7 +40,13 @@ RUN set -x \ && git config --global http.postBuffer 524288000 \ && npm install -g pnpm \ && pnpm add -g pm2 ts-node typescript tslib \ - && git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ + && rm -rf /root/.pnpm-store \ + && rm -rf /root/.local/share/pnpm/store \ + && rm -rf /root/.cache \ + && rm -rf /root/.npm + +ARG SOURCE_COMMIT +RUN git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ && cd ${QL_DIR} \ && cp -f .env.example .env \ && chmod 777 ${QL_DIR}/shell/*.sh \ @@ -55,6 +59,9 @@ RUN set -x \ && git clone -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \ && mkdir -p ${QL_DIR}/static \ && cp -rf /static/* ${QL_DIR}/static \ - && rm -rf /static + && rm -rf /static \ + && rm -rf /tmp/build + +WORKDIR ${QL_DIR} ENTRYPOINT ["./docker/docker-entrypoint.sh"]