From 76fa6bd0bde9cca5c053da9d69d19cb6928ebd1f Mon Sep 17 00:00:00 2001 From: ARC-MX Date: Thu, 6 Jun 2024 22:50:01 +0800 Subject: [PATCH] Replace Docker Hub with Aliyun repositories --- .github/workflows/docker-image.yml | 20 +++++++++++++++++--- Dockerfile | 2 +- README.md | 13 ++++++++++--- docker-compose.yml | 4 ++-- requirements.txt | 1 + 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0e59517..6d354f9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -21,11 +21,25 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Log into registry - run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + - name: Log into docker hub registry + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: pull Docker and push to Aliyun + run: | + docker pull mongo:4.4.18 + docker tag mongo:4.4.18 registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 - name: Build and push Docker image run: | PLATFORMS=linux/arm64,linux/amd64,linux/arm/v7 DOCKER_IMAGE=arcw/sgcc_electricity - docker buildx build --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:1.4.0 --file Dockerfile-for-github-action --push . \ No newline at end of file + docker buildx build --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:1.4.0 --file Dockerfile-for-github-action --push . + + - name: Log into Aliyun hub registry and push Docker image + run: | + echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.ALIYUN_USERNAME }} --password-stdin registry.cn-hangzhou.aliyuncs.com + PLATFORMS=linux/arm64,linux/amd64,linux/arm/v7 + DOCKER_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity + docker buildx build --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:1.4.0 --file Dockerfile-for-github-action --push . + docker push registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f5555ac..3188d48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-slim-buster as build +FROM python:3.9-bullseye as build ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 diff --git a/README.md b/README.md index 44c2d9c..8a000c3 100644 --- a/README.md +++ b/README.md @@ -108,21 +108,28 @@ # 日志级别 LOG_LEVEL="INFO" # 例如“DEBUG”可以查看出错情况 ``` -4. 运行 +4. 镜像拉取 ```bash docker compose up --build # 或者后台运行 docker compose up -d --build ``` -5. 更新容器 +5. 运行 + + ```bash + docker compose up --build + # 或者后台运行 + docker compose up -d --build + ``` +6. 更新容器 ```bash docker compose down # 删除容器 docker compose pull # 更新镜像 docker compose up # 重新运行 ``` -6. 运行成功应该显示如下日志: +7. 运行成功应该显示如下日志: ```bash 2024-06-06 16:00:43 [INFO ] ---- 程序开始,当前仓库版本为1.3.3,仓库地址为https://github.com/ARC-MX/sgcc_electricity_new.git diff --git a/docker-compose.yml b/docker-compose.yml index 4ae2e0f..86958f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: - .env depends_on: - mongo - image: arcw/sgcc_electricity:latest # armv8 + image: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest # armv8 # build: # context: . # dockerfile: Dockerfile @@ -22,7 +22,7 @@ services: command: python3 main.py # 默认将近30天数据写入mongo数据库,方便查询 mongo: - image: mongo:4.4.18 + image: registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 restart: always container_name: mongo-for-sgcc networks: diff --git a/requirements.txt b/requirements.txt index 769cc2d..3ad0ba4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ Pillow==9.2.0 undetected_chromedriver==3.4.7 pymongo~=3.12.0 # onnxruntime==1.17.3 +numpy==1.24.3 python-dotenv \ No newline at end of file