From 2452a005742494885aad9049cea59fed880b6722 Mon Sep 17 00:00:00 2001 From: ARC-MX Date: Fri, 3 Jan 2025 22:23:53 +0800 Subject: [PATCH] image add new label --- .github/workflows/docker-image.yml | 22 ++++++++++--- Dockerfile | 7 ---- build.yaml | 7 ---- config.yaml | 2 +- run.sh | 51 ------------------------------ 5 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 Dockerfile delete mode 100644 build.yaml delete mode 100644 run.sh diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1b85129..de2f545 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,13 +32,27 @@ jobs: - name: Build and push Docker image run: | - PLATFORMS=linux/arm64,linux/amd64 + ARCH_TAGS="arm64 amd64" DOCKER_IMAGE=arcw/sgcc_electricity - docker buildx build --build-arg VERSION=${{ inputs.username }} --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push . + for ARCH in $ARCH_TAGS; do + if [ "$ARCH" == "arm64" ]; then + TAG_ARCH="aarch64" + else + TAG_ARCH=$ARCH + fi + docker buildx build --build-arg VERSION=${{ inputs.username }} --platform linux/$ARCH -t $DOCKER_IMAGE-$TAG_ARCH:latest -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push . + done - 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 + ARCH_TAGS="arm64 amd64" DOCKER_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity - docker buildx build --build-arg VERSION=${{ inputs.username }} --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push . \ No newline at end of file + for ARCH in $ARCH_TAGS; do + if [ "$ARCH" == "arm64" ]; then + TAG_ARCH="aarch64" + else + TAG_ARCH=$ARCH + fi + docker buildx build --build-arg VERSION=${{ inputs.username }} --platform linux/$ARCH -t $DOCKER_IMAGE-$TAG_ARCH:latest -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push . + done \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 11f6e0c..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM arcw/sgcc_electricity:latest - -COPY run.sh /run.sh -RUN chmod +x /run.sh - -ENV LANG C.UTF-8 -ENTRYPOINT ["/bin/bash", "/run.sh"] diff --git a/build.yaml b/build.yaml deleted file mode 100644 index 1e8fe6d..0000000 --- a/build.yaml +++ /dev/null @@ -1,7 +0,0 @@ -build_from: - aarch64: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest - amd64: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest -labels: - org.opencontainers.image.title: "SGCC Electricity Add-on" - org.opencontainers.image.description: "State Grid Electric Data" - org.opencontainers.image.source: "https://github.com/ARC-MX/sgcc_electricity_new" diff --git a/config.yaml b/config.yaml index dbcdf0b..2c0475b 100644 --- a/config.yaml +++ b/config.yaml @@ -10,7 +10,7 @@ host_network: true startup: application boot: auto init: false -#image: "{arch}-sgcc_electricity_new" +image: "registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity-{arch}" map: - config:rw options: diff --git a/run.sh b/run.sh deleted file mode 100644 index df2cbb4..0000000 --- a/run.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Read configuration from options.json -CONFIG_PATH="/data/options.json" -if [ ! -f "$CONFIG_PATH" ]; then - echo "Error: Configuration file not found $CONFIG_PATH" - exit 1 -fi -# Use jq to read config and set environment variables -export PHONE_NUMBER=$(jq -r '.phone // empty' "$CONFIG_PATH") -export PASSWORD=$(jq -r '.password // empty' "$CONFIG_PATH") -export IGNORE_USER_ID=$(jq -r '.IGNORE_USER_ID // empty' "$CONFIG_PATH") -export ENABLE_DATABASE_STORAGE=$(jq -r '.enable_database_storage // "false"' "$CONFIG_PATH") -export DB_NAME=$(jq -r '.db_name // "homeassistant.db"' "$CONFIG_PATH") -export HASS_URL=$(jq -r '.hass_url // empty' "$CONFIG_PATH") -export HASS_TOKEN=$(jq -r '.hass_token // empty' "$CONFIG_PATH") -export JOB_START_TIME=$(jq -r '.job_start_time // "00:00"' "$CONFIG_PATH") -export DRIVER_IMPLICITLY_WAIT_TIME=$(jq -r '.driver_implicitly_wait_time // "10"' "$CONFIG_PATH") -export RETRY_TIMES_LIMIT=$(jq -r '.retry_times_limit // "3"' "$CONFIG_PATH") -export LOGIN_EXPECTED_TIME=$(jq -r '.login_expected_time // "60"' "$CONFIG_PATH") -export RETRY_WAIT_TIME_OFFSET_UNIT=$(jq -r '.retry_wait_time_offset_unit // "5"' "$CONFIG_PATH") -export LOG_LEVEL=$(jq -r '.log_level // "INFO"' "$CONFIG_PATH") -export DATA_RETENTION_DAYS=$(jq -r '.data_retention_days // "30"' "$CONFIG_PATH") -export RECHARGE_NOTIFY=$(jq -r '.recharge_notify // "false"' "$CONFIG_PATH") -export BALANCE=$(jq -r '.balance // "50"' "$CONFIG_PATH") -export PUSHPLUS_TOKEN=$(jq -r '.pushplus_token // empty' "$CONFIG_PATH") -# Check required environment variables -if [ -z "$PHONE_NUMBER" ]; then - echo "Error: Phone number not set" - exit 1 -fi -if [ -z "$PASSWORD" ]; then - echo "Error: Password not set" - exit 1 -fi -if [ -z "$HASS_URL" ]; then - echo "Error: Home Assistant URL not set" - exit 1 -fi -if [ -z "$HASS_TOKEN" ]; then - echo "Error: Home Assistant Token not set" - exit 1 -fi -# Output environment variables log -echo "Environment variables setup completed:" -echo "Phone Number: ${PHONE_NUMBER:-Not Set}" -echo "Home Assistant URL: ${HASS_URL:-Not Set}" -echo "Job Start Time: ${JOB_START_TIME:-Not Set}" -echo "Log Level: ${LOG_LEVEL:-Not Set}" -echo "Data Retention Days: ${DATA_RETENTION_DAYS:-Not Set}" -# Start main program -python3 /app/main.py \ No newline at end of file