From f46c70dcbd23f1e01346ce2d1a4adf09ee5054b9 Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 27 Jan 2022 23:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9D=92=E9=BE=99=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_base.yml | 58 ++++++++++++++++++++++++++++++++ docker/Dockerfile | 38 +++------------------ docker/base/Dockerfile | 43 +++++++++++++++++++++++ 3 files changed, 106 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/build_base.yml create mode 100644 docker/base/Dockerfile diff --git a/.github/workflows/build_base.yml b/.github/workflows/build_base.yml new file mode 100644 index 00000000..42f4eec8 --- /dev/null +++ b/.github/workflows/build_base.yml @@ -0,0 +1,58 @@ +name: Build QL BASE + +on: + schedule: + - cron: '00 18 * * *' # GMT 14:00 => 北京时间 2:00 + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + packages: write + contents: read + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: Set time zone + uses: szenius/set-timezone@v1.0 + with: + timezoneLinux: "Asia/Shanghai" + timezoneMacos: "Asia/Shanghai" + timezoneWindows: "China Standard Time" + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + build-args: | + MAINTAINER=${{ github.repository_owner }} + QL_BRANCH=${{ github.ref_name }} + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x + context: docker/base/ + push: true + tags: whyour/ql:base diff --git a/docker/Dockerfile b/docker/Dockerfile index 31277ef0..dd620df2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,51 +1,23 @@ -FROM node:alpine +FROM whyour/ql:base ARG QL_MAINTAINER="whyour" LABEL maintainer="${QL_MAINTAINER}" ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git ARG QL_BRANCH=master + ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ LANG=zh_CN.UTF-8 \ SHELL=/bin/bash \ PS1="\u@\h:\w \$ " \ QL_DIR=/ql \ QL_BRANCH=${QL_BRANCH} + WORKDIR ${QL_DIR} -RUN set -x \ - && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \ - && apk update -f \ - && apk upgrade \ - && apk --no-cache add -f bash \ - coreutils \ - moreutils \ - git \ - curl \ - wget \ - tzdata \ - perl \ - openssl \ - nginx \ - python3 \ - jq \ - openssh \ - py3-pip \ - python2 \ - g++ \ - make \ - && rm -rf /var/cache/apk/* \ - && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && touch ~/.bashrc \ - && git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ - && git config --global user.email "qinglong@@users.noreply.github.com" \ - && git config --global user.name "qinglong" \ + +RUN git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ && cd ${QL_DIR} \ && cp -f .env.example .env \ && chmod 777 ${QL_DIR}/shell/*.sh \ && chmod 777 ${QL_DIR}/docker/*.sh \ - && npm install -g pnpm \ - && pnpm install -g pm2 \ - && pnpm install -g ts-node typescript tslib \ - && rm -rf /root/.npm \ && pnpm install --prod \ && rm -rf /root/.pnpm-store \ && git clone -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \ diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000..89f5d9e1 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,43 @@ +FROM node:alpine +ARG QL_MAINTAINER="whyour" +LABEL maintainer="${QL_MAINTAINER}" + +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + LANG=zh_CN.UTF-8 \ + SHELL=/bin/bash \ + PS1="\u@\h:\w \$ " + + +RUN set -x \ + && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \ + && apk update -f \ + && apk upgrade \ + && apk --no-cache add -f bash \ + coreutils \ + moreutils \ + git \ + curl \ + wget \ + tzdata \ + perl \ + openssl \ + nginx \ + python3 \ + jq \ + openssh \ + py3-pip \ + python2 \ + g++ \ + make \ + && rm -rf /var/cache/apk/* \ + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && touch ~/.bashrc \ + && git config --global user.email "qinglong@@users.noreply.github.com" \ + && git config --global user.name "qinglong" \ + && npm install -g pnpm \ + && pnpm install -g pm2 \ + && pnpm install -g ts-node typescript tslib \ + && rm -rf /root/.npm \ + +CMD [ "node" ]