From a8bb275cf4a12f07ec9777019be54ebc4fbe98bf Mon Sep 17 00:00:00 2001 From: yshtcn Date: Tue, 4 Jun 2024 00:31:10 +0800 Subject: [PATCH] # Fix bug --- AliCloudIPUpdater.py | 6 +++--- Dockerfile | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/AliCloudIPUpdater.py b/AliCloudIPUpdater.py index 90de8bd..abf60c2 100644 --- a/AliCloudIPUpdater.py +++ b/AliCloudIPUpdater.py @@ -129,8 +129,8 @@ def load_ip_records(ip_record_file): def main(): try: # 加载配置文件 - config_path = os.environ.get('CONFIG_PATH', '/config/config.json') - sample_config_path = os.environ.get('SAMPLE_CONFIG_PATH', '/config/config.sample.json') + config_path = os.environ.get('CONFIG_PATH', '/app/config/config.json') + sample_config_path = os.environ.get('SAMPLE_CONFIG_PATH', '/app/config.sample.json') config = load_config(config_path, sample_config_path) ACCESS_KEY_ID = config['ACCESS_KEY_ID'] @@ -141,7 +141,7 @@ def main(): GETIP_URLS = config['GETIP_URLS'] PORTS = config['PORTS'] PRIORITY = config.get('PRIORITY', 1) - IP_RECORD_FILE = config.get('IP_RECORD_FILE', '/logs/ip_records.json') + IP_RECORD_FILE = config.get('IP_RECORD_FILE', '/app/config/' + config.get('IP_RECORD_FILE', 'ip_records.json')) INTERVAL_SECONDS = config.get('INTERVAL_SECONDS', 3600) client = AcsClient(ACCESS_KEY_ID, ACCESS_KEY_SECRET, REGION_ID) diff --git a/Dockerfile b/Dockerfile index 5cde190..5304891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,19 @@ # Use an official Python runtime as a parent image -FROM python:3.9-slim +FROM python:3.12-slim # Set the working directory WORKDIR /app -# Copy the current directory contents into the container at /app -COPY . /app - # Install any needed packages specified in requirements.txt +COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt +# Copy the application files into the container +COPY AliCloudIPUpdater.py /app/ +COPY config.sample.json /app/ + # Create directories for config and logs -RUN mkdir /config /logs +RUN mkdir -p /app/config -# Copy the sample config file into the image -COPY config.sample.json /config/config.sample.json - -# Run update_aliyun.py when the container launches +# Run AliCloudIPUpdater.py when the container launches CMD ["python", "AliCloudIPUpdater.py"]