From 8cbd7c3748ba70563429d68d2535d72d21d53a97 Mon Sep 17 00:00:00 2001 From: Walker Lee Date: Wed, 31 Aug 2016 02:08:31 +0800 Subject: [PATCH] Using $TIMEZONE environment variable to set timezone --- Dockerfile | 19 +++++++++++++------ docker-compose.yml | 2 ++ docker-compose_tor.yml | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36e182d8b4..19f9ea5360 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,22 +16,19 @@ FROM alpine ARG BUILD_REPO=PokemonGoF/PokemonGo-Bot ARG BUILD_BRANCH=master -ARG TIMEZONE=Etc/UTC LABEL build_repo=$BUILD_REPO build_branch=$BUILD_BRANCH WORKDIR /usr/src/app VOLUME ["/usr/src/app/configs", "/usr/src/app/web"] -RUN apk -U --no-cache add python py-pip \ +RUN apk -U --no-cache add python py-pip tzdata \ && rm -rf /var/cache/apk/* \ && find / -name '*.pyc' -o -name '*.pyo' | xargs -rn1 rm -f ADD http://pgoapi.com/pgoencrypt.tar.gz /tmp/pgoencrypt.tar.gz ADD https://raw.githubusercontent.com/$BUILD_REPO/$BUILD_BRANCH/requirements.txt . -RUN apk -U --no-cache add --virtual .build-dependencies python-dev gcc make musl-dev git tzdata \ - && cp -fa /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ - && echo $TIMEZONE > /etc/timezone \ +RUN apk -U --no-cache add --virtual .build-dependencies python-dev gcc make musl-dev git \ && tar zxf /tmp/pgoencrypt.tar.gz -C /tmp \ && make -C /tmp/pgoencrypt/src \ && cp /tmp/pgoencrypt/src/libencrypt.so /usr/src/app/encrypt.so \ @@ -48,4 +45,14 @@ RUN apk -U --no-cache add --virtual .pgobot-dependencies wget ca-certificates ta && apk del .pgobot-dependencies \ && rm -rf /var/cache/apk/* /tmp/pgobot-version -ENTRYPOINT ["python", "pokecli.py"] +RUN printf "#!/bin/sh\n\ +\n\ +TIMEZONE=\${TIMEZONE:-Etc/UTC}\n\ +\n\ +ln -sfn /usr/share/zoneinfo/\$TIMEZONE /etc/localtime\n\ +echo \$TIMEZONE > /etc/timezone\n\ +\n\ +python pokecli.py \$@\n" > /entrypoint.sh \ + && chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 291b692939..8625631650 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: - ./configs:/usr/src/app/configs - ./data:/usr/src/app/data - ./web:/usr/src/app/web + environment: + - TIMEZONE=Etc/UTC stdin_open: true tty: true bot1-pokegoweb: diff --git a/docker-compose_tor.yml b/docker-compose_tor.yml index bb5309e826..33b9acbfc3 100644 --- a/docker-compose_tor.yml +++ b/docker-compose_tor.yml @@ -23,6 +23,8 @@ services: - ./configs:/usr/src/app/configs - ./data:/usr/src/app/data - ./web:/usr/src/app/web + environment: + - TIMEZONE=Etc/UTC stdin_open: true tty: true bot1-pokegoweb: