Skip to content

Commit

Permalink
Merge pull request #4730 from walkerlee/update-dockerfile
Browse files Browse the repository at this point in the history
Minimize docker image
  • Loading branch information
solderzzc authored Aug 26, 2016
2 parents 7622c40 + 8465a39 commit 3f2e744
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,34 @@
#
# docker build --build-arg BUILD_REPO=YourFork/PokemonGo-Bot --build-arg BUILD_BRANCH=6a4580f .

FROM python:2.7.12-alpine
FROM alpine

RUN apk add --update --no-cache alpine-sdk git

ARG BUILD_BRANCH
ENV BUILD_BRANCH ${BUILD_BRANCH:-master}

ARG BUILD_REPO
ENV BUILD_REPO ${BUILD_REPO:-PokemonGoF/PokemonGo-Bot}
ARG BUILD_REPO=PokemonGoF/PokemonGo-Bot
ARG BUILD_BRANCH=master
ARG TIMEZONE=Etc/UTC

LABEL build_repo=$BUILD_REPO build_branch=$BUILD_BRANCH

ADD https://github.com/$BUILD_REPO/archive/$BUILD_BRANCH.tar.gz .
RUN tar -zxvf $BUILD_BRANCH.tar.gz && mv PokemonGo-Bot-* /usr/src/app && rm $BUILD_BRANCH.tar.gz

WORKDIR /usr/src/app
VOLUME ["/usr/src/app/configs", "/usr/src/app/web"]

ARG timezone=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#setup the bot
ADD http://pgoapi.com/pgoencrypt.tar.gz /tmp/
RUN cd /tmp && tar zxvf pgoencrypt.tar.gz \
&& cd pgoencrypt/src \
&& make \
&& cp libencrypt.so /usr/src/app/encrypt.so \
&& cd /tmp \
&& rm -rf /tmp/pgoencrypt*

ENV LD_LIBRARY_PATH /usr/src/app

RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip install --no-cache-dir -r requirements.txt

#remove unused stuff
RUN apk del alpine-sdk\
&& rm -rf /var/cache/apk/*
ADD https://raw.githubusercontent.com/$BUILD_REPO/$BUILD_BRANCH/requirements.txt .
RUN apk -U --no-cache add python py-pip \
&& apk --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 \
&& wget -q -O- http://pgoapi.com/pgoencrypt.tar.gz | tar zxf - -C /tmp \
&& make -C /tmp/pgoencrypt/src \
&& cp /tmp/pgoencrypt/src/libencrypt.so /usr/src/app/encrypt.so \
&& ln -s locale.h /usr/include/xlocale.h \
&& pip install --no-cache-dir -r requirements.txt \
&& apk del .build-dependencies \
&& rm -rf /var/cache/apk/* /tmp/pgoencrypt /usr/include/xlocale.h \
&& find / -name '*.pyc' -o -name '*.pyo' -exec rm -f {} \;

RUN apk -U --no-cache add --virtual .install-dependencies wget ca-certificates tar \
&& wget -q -O- https://github.com/$BUILD_REPO/archive/$BUILD_BRANCH.tar.gz | tar zxf - --strip-components=1 -C /usr/src/app \
&& apk del .install-dependencies \
&& rm -rf /var/cache/apk/*

ENTRYPOINT ["python", "pokecli.py"]

0 comments on commit 3f2e744

Please sign in to comment.