From 6aab48c89939c69dfe2533cb45fed651d668b12b Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Mon, 12 Aug 2019 18:15:47 +0800 Subject: [PATCH] feat(docker): add buster image with minimum dependencies --- Dockerfiles/buster.Dockerfile | 23 +++++++---------------- Dockerfiles/ubuntu.Dockerfile | 21 +++++++++++++++++++++ docker-push.sh | 10 +++++----- 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 Dockerfiles/ubuntu.Dockerfile diff --git a/Dockerfiles/buster.Dockerfile b/Dockerfiles/buster.Dockerfile index f4e71e32..b68a67c2 100644 --- a/Dockerfiles/buster.Dockerfile +++ b/Dockerfiles/buster.Dockerfile @@ -1,27 +1,18 @@ -FROM python:3.7.4-slim-buster AS dependency +FROM python:3.7.4-slim-buster AS base WORKDIR /gnes/ -COPY setup.py ./setup.py +ADD . ./ RUN apt-get update && apt-get install --no-install-recommends -y \ - build-essential g++ gfortran file binutils \ - python3-dev cython libopenblas-dev && \ + build-essential \ + python3-dev libopenblas-dev && \ ln -s locale.h /usr/include/xlocale.h && \ - python -c "import distutils.core;s=distutils.core.run_setup('setup.py').install_requires;f=open('requirements_tmp.txt', 'w');[f.write(v+'\n') for v in s];f.close()" && \ - cat requirements_tmp.txt && \ - pip install --no-cache-dir --compile -r requirements_tmp.txt && \ - rm -rf /var/lib/apt/lists/* && \ + pip install . --no-cache-dir --compile && \ + rm -rf /tmp/* && rm -rf /gnes && \ + apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* && \ rm /usr/include/xlocale.h -FROM dependency as base - -ADD . ./ - -RUN pip install . --no-cache-dir --compile && \ - rm -rf /tmp/* && \ - rm -rf /gnes - WORKDIR / ENTRYPOINT ["gnes"] \ No newline at end of file diff --git a/Dockerfiles/ubuntu.Dockerfile b/Dockerfiles/ubuntu.Dockerfile new file mode 100644 index 00000000..0ab8414f --- /dev/null +++ b/Dockerfiles/ubuntu.Dockerfile @@ -0,0 +1,21 @@ +FROM ubuntu:18.04 AS base + +WORKDIR /gnes/ + +ADD . ./ + +RUN apt-get update && apt-get install --no-install-recommends -y \ + build-essential \ + python3-dev python3-pip libopenblas-dev && \ + ln -s locale.h /usr/include/xlocale.h && \ + cd /usr/local/bin && \ + ln -s /usr/bin/python3 python && \ + pip3 install --upgrade pip && \ + pip3 install . --no-cache-dir --compile && \ + rm -rf /tmp/* && rm -rf /gnes && \ + apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* && \ + rm /usr/include/xlocale.h + +WORKDIR / + +ENTRYPOINT ["gnes"] \ No newline at end of file diff --git a/docker-push.sh b/docker-push.sh index fd83fd64..41f5361a 100755 --- a/docker-push.sh +++ b/docker-push.sh @@ -20,26 +20,26 @@ _docker_push() { _select_dockerfile() { PS3='Please select the Dockerfile you want to build (type 1, 2, 3, ...): ' - options=("Dockerfile" "alpine.Dockerfile" "buster.Dockerfile" "ubuntu.Dockerfile") + options=("full(~7.2GB)" "alpine(~300MB)" "buster(~800MB)" "ubuntu") select opt in "${options[@]}" do case $opt in - "Dockerfile") + "full(~7.2GB)") export DOCKER_FILE='Dockerfiles/full.Dockerfile' export OS_TAG='full' break ;; - "alpine.Dockerfile") + "alpine(~300MB)") export DOCKER_FILE='Dockerfiles/alpine.Dockerfile' export OS_TAG='alpine' break ;; - "buster.Dockerfile") + "buster(~800MB)") export DOCKER_FILE='Dockerfiles/buster.Dockerfile' export OS_TAG='buster' break ;; - "ubuntu.Dockerfile") + "ubuntu") export DOCKER_FILE='Dockerfiles/ubuntu.Dockerfile' export OS_TAG='ubuntu' break