diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f2262c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +# This docker-compose setup is intented for development, testing, and CI purposes. +# -- Make changes with extreme caution! + +# Note: CircleCI Docker runners don't support volumes. + +version: "3.4" + +# Services are meant to be interchangeble between running them locally or +# inside a container. That is why all of them export their server port to the host. + +# Images that are built here are the same used in production. +services: + core: + image: kennethreitz/bake:core + build: + context: . + dockerfile: ./docker/core.Dockerfile + + bake: + image: kennethreitz/bake:${DOCKER_RELEASE:-latest} + build: + context: . + dockerfile: ./docker/bake.Dockerfile + depends_on: + - core + volumes: + - ./Bakefile:/app/Bakefile + - .:/app diff --git a/docker/bake.Dockerfile b/docker/bake.Dockerfile new file mode 100644 index 0000000..6c7a35b --- /dev/null +++ b/docker/bake.Dockerfile @@ -0,0 +1,25 @@ +FROM kennethreitz/bake:core + +ENV BAKEFILE_PATH /app/Bakefile + +# -- Install Shellcheck. +RUN set -ex && \ + apt-get install shellcheck -y -qq && \ + apt-get clean -y -qq && \ + apt-get autoclean -y -qq + +# -- Install latest Bake. +RUN set -ex && \ + pip3 install bake-cli --upgrade --quiet > /dev/null + +# -- Really slim down that image. +RUN set -ex && \ + rm -fr /var/lib/apt/lists + +# -- Copy Bakefile of depending Dockerfiles. +ONBUILD COPY ./Bakefile /app/Bakefile + +# -- Copy the application over. +ONBUILD COPY . /app + +ENTRYPOINT [ "bake" ] diff --git a/docker/core.Dockerfile b/docker/core.Dockerfile new file mode 100644 index 0000000..b5959a7 --- /dev/null +++ b/docker/core.Dockerfile @@ -0,0 +1,38 @@ +FROM ubuntu:19.04 + +# Tell Ubuntu to not prompt during apt installs. +ENV DEBIAN_FRONTEND 'noninteractive' + +# -- Setup mirrors, for faster downloads (main sources can be *very* slow sometimes). +COPY ./docker/scripts/use-mirrors.sh /opt/use-mirrors.sh +RUN set -ex && \ + /opt/use-mirrors.sh && \ + rm -fr /opt/use-mirrors.sh + +# -- System dependencies + common utilities. +RUN set -ex && \ + apt-get update -qq && \ + apt-get upgrade -y -qq && \ + apt-get install curl python3 python3-distutils -y -qq >/dev/null && \ + apt-get clean -y -qq && \ + apt-get autoclean -y -qq + +# -- Install pip. +RUN set -ex && curl -s --retry 3 https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py && \ + python3 /tmp/get-pip.py > /dev/null && rm -fr /tmp/get-pip.py + +# -- Install hconfig. +RUN set -ex && \ + pip3 install pipenv --quiet --no-cache 2>/dev/null + +# -- Clean up. +RUN set -ex && \ + apt-get clean -y -qq && apt-get autoremove -y -qq && apt-get autoclean -y -qq + +# -- Home directory. +RUN set -ex && \ + mkdir /app + +WORKDIR /app + +ENTRYPOINT [ "bash" ] diff --git a/docker/scripts/use-mirrors.sh b/docker/scripts/use-mirrors.sh new file mode 100755 index 0000000..1701276 --- /dev/null +++ b/docker/scripts/use-mirrors.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +SOURCES_LIST='/etc/apt/sources.list' +PREVIOUS_SOURCES=$(cat $SOURCES_LIST) + +perl -pe '/(http|https):\/\/(.*?)(\/|$)/ && s/$2/mirror.math.princeton.edu\/pub\//g' <<< "$PREVIOUS_SOURCES" > "$SOURCES_LIST"