###
### DO NOT MODIFY THIS FILE.  THIS FILE HAS BEEN AUTOGENERATED
###
#
# DO NOT MODIFY THIS FILE.  THIS FILE HAS BEEN AUTOGENERATED
#

FROM circleci/buildpack-deps:trusty-curl

# docker installations command expect to run as root
USER root

#  The package `btrfs-progs` has replaced `btrfs-tools` in newer distros. 
#  We'll try both for now but after older distros like Ubuntu 16.04 (Xenial), 
#  and Debian Stretch drop off the tag lists from upstream, we should just 
#  install `btrfs-progs`.
RUN apt-get update && apt-get install -y \
		iptables \
		xz-utils && \
	if ! apt-get install -y btrfs-tools; then  apt-get install -y btrfs-progs; fi

# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box
RUN set -x \
    && addgroup --system dockremap \
    && adduser --system --ingroup dockremap dockremap \
    && echo 'dockremap:165536:65536' >> /etc/subuid \
    && echo 'dockremap:165536:65536' >> /etc/subgid

ENV DIND_COMMIT 3b5fac462d21ca164b3778647420016315289034

RUN wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind" \
    && chmod +x /usr/local/bin/dind

RUN set -x \
    && addgroup --system docker \
    && sudo usermod --append --groups docker circleci

# avoid creating separate files and embed file here
RUN printf '#!/bin/sh \n\
set -e \n\
if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then \n\
    set -- dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 "$@" \n\
fi \n\
 \n\
if [ "$1" = 'dockerd' ]; then \n\
    set -- sudo sh "$(which dind)" "$@" \n\
fi \n\
 \n\
exec "$@" \n\
' > /usr/local/bin/dockerd-entrypoint.sh \
   && chmod +x /usr/local/bin/dockerd-entrypoint.sh

VOLUME /var/lib/docker

ENTRYPOINT ["dockerd-entrypoint.sh"]

LABEL com.circleci.user="circleci"
LABEL com.circleci.preserve-entrypoint=true

USER circleci
