From d6aa0595b20c6829c334c8a2312f7f39da6efe0e Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 11 Aug 2020 02:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9D=84=EF=B8=8F=20=E4=BD=BF=E7=94=A8=20Githu?= =?UTF-8?q?b=20Action=20=E8=87=AA=E5=8A=A8=E6=9E=84=E5=BB=BA=20Docker=20?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 7 +++---- utils/docker.sh | 6 +++--- 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..c253a94 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,35 @@ +name: Docker Push + +on: + push: + branches: + - 'master' + paths-ignore: + - "README.md" + +jobs: + buildx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Dockerhub login + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin + - name: Set up Docker Buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + buildx-version: latest + - name: Build dockerfile (with push) + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + run: | + docker buildx build \ + --platform=linux/amd64,linux/arm/v7,linux/arm64 \ + --output "type=image,push=true" \ + --file ./Dockerfile . \ + --tag mrwangzhe/pagermaid_modify:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2c37a6d..407877c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,13 +31,12 @@ RUN pacman -Syu --needed --noconfirm \ file \ procps-ng RUN sed -e 's;^# \(%wheel.*NOPASSWD.*\);\1;g' -i /etc/sudoers -RUN useradd pagermaid -u 3333 -r -m -d /pagermaid +RUN useradd pagermaid -r -m -d /pagermaid RUN usermod -aG wheel,users pagermaid USER pagermaid RUN mkdir /pagermaid/workdir RUN git clone -b master https://github.com/xtaodada/PagerMaid-Modify.git /pagermaid/workdir WORKDIR /pagermaid/workdir -RUN python3 -m virtualenv /pagermaid/venv -RUN source /pagermaid/venv/bin/activate; pip3 install -r requirements.txt +RUN python3 -m virtualenv venv +RUN source venv/bin/activate; pip3 install -r requirements.txt CMD ["sh","utils/docker-run.sh"] -CMD ["sh","utils/entrypoint.sh"] diff --git a/utils/docker.sh b/utils/docker.sh index 8555dcd..763fb60 100644 --- a/utils/docker.sh +++ b/utils/docker.sh @@ -55,16 +55,16 @@ access_check() { build_docker() { printf "请输入 PagerMaid 容器的名称:" read -r container_name <&1 - echo "正在构建 Docker 镜像 . . ." + echo "正在拉取 Docker 镜像 . . ." docker rm -f "$container_name" > /dev/null 2>&1 - docker build - --force-rm --no-cache -t pagermaid_"$container_name" < Dockerfile.persistant + docker pull pagermaid_modify } start_docker() { echo "正在启动 Docker 容器 . . ." echo "在登录后,请按 Ctrl + C 使容器在后台模式下重新启动。" sleep 3 - docker run -it --restart=always --name="$container_name" --hostname="$container_name" pagermaid_"$container_name" <&1 + docker run -it --restart=always --name="$container_name" --hostname="$container_name" pagermaid_modify <&1 echo "" echo "Docker 创建完毕。" echo ""