diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0e59517..6fa7e09 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: 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: pull Docker image + run: | + docker pull mongo:4.4.18 + docker tag mongo:4.4.18 registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 + + - 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/Dockerfile-for-github-action b/Dockerfile-for-github-action index 7adc6d7..5b2e4c9 100644 --- a/Dockerfile-for-github-action +++ b/Dockerfile-for-github-action @@ -21,16 +21,16 @@ RUN apt-get --allow-releaseinfo-change update \ RUN cd /tmp \ && python3 -m pip install --upgrade pip -RUN if [${TARGETARCH} == "arm"]; then \ +RUN if ["$TARGETARCH" = "arm"]; then \ cd /tmp \ && curl -O -L https://github.com/nknytk/built-onnxruntime-for-raspberrypi-linux/blob/master/wheels/bullseye/onnxruntime-1.16.0-cp39-cp39-linux_armv7l.whl \ && PIP_ROOT_USER_ACTION=ignore pip3 install onnxruntime-1.16.0-cp39-cp39-linux_armv7l.whl \ + && curl -O -L https://github.com/maxisoft/pytorch-arm/releases/download/v1.0.0/numpy-1.23.5-cp39-cp39-linux_armv7l.whl \ + && PIP_ROOT_USER_ACTION=ignore pip3 install numpy-1.23.5-cp39-cp39-linux_armv7l.whl \ && PIP_ROOT_USER_ACTION=ignore pip3 install cmake==3.14.3; \ - fi - -RUN if [${TARGETARCH} == "arm64"]; then \ + else \ cd /tmp \ - && PIP_ROOT_USER_ACTION=ignore pip3 install onnxruntime==1.17.3; \ + && PIP_ROOT_USER_ACTION=ignore pip3 install onnxruntime==1.17.3 numpy==1.23.5; \ fi RUN cd /tmp \ diff --git a/README.md b/README.md index 44c2d9c..cc9a07c 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ ```bash git clone https://github.com/ARC-MX/sgcc_electricity_new.git + # 如果github网络环境不好的话可以使用国内镜像,完全同步的,个人推荐使用国内镜像 + # git clone https://gitee.com/ARC-MX/sgcc_electricity_new.git cd sgcc_electricity_new ``` 3. 创建环境变量文件 @@ -110,6 +112,10 @@ ``` 4. 运行 + 我已经优化了镜像环境,将镜像的地址配置为阿里云,如果要使用docker hub的源可以将docker-compose.yml中 + image: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest 改为 arcw/sgcc_electricity:latest + image: registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 改为 mongo:4.4.18 + ```bash docker compose up --build # 或者后台运行 diff --git a/docker-compose.yml b/docker-compose.yml index 4ae2e0f..520723a 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 # for use docker.io: arcw/sgcc_electricity:latest # 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 # for use docker.io: mongo:4.4.18 restart: always container_name: mongo-for-sgcc networks: diff --git a/requirements.txt b/requirements.txt index 769cc2d..a3bc305 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