Skip to content

Commit 9eb4756

Browse files
committed
fix(Dockerfile): ensure apt-get install is prefixed by update
Since Dockerfile layers are cached, having `apt-get update` as a separate command creates the potential for a subsequent `apt-get install` to fail. Best practices (other than "install from source") seem to be to make both commands into a one-liner. This PR ensures we don't `apt-get install` as its own command anywhere, removes the installation of some packages that were already in deis/base, and removes a redundant ENV DEBIAN_FRONTEND statement.
1 parent 38a2196 commit 9eb4756

7 files changed

Lines changed: 23 additions & 44 deletions

File tree

builder/Dockerfile

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
11
FROM deis/base:latest
22
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

4-
ENV DEBIAN_FRONTEND noninteractive
5-
6-
RUN apt-get update
7-
8-
# install ssh server
9-
RUN apt-get install -yq openssh-server
4+
# install docker-in-docker
5+
RUN echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
6+
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
7+
# install builder, docker, and hook dependencies
8+
RUN apt-get update && apt-get install -yq \
9+
openssh-server git \
10+
aufs-tools iptables lxc \
11+
curl \
12+
lxc-docker-1.0.0
13+
14+
# configure ssh server
1015
RUN rm /etc/ssh/ssh_host_*
1116
RUN dpkg-reconfigure openssh-server
1217
RUN mkdir -p /var/run/sshd
1318

14-
# install docker in docker deps
15-
RUN apt-get install -yq aufs-tools iptables ca-certificates lxc
16-
RUN echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
17-
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
18-
RUN apt-get update -qy
19-
RUN apt-get install -yq lxc-docker-1.0.0
20-
2119
# install recent pip
2220
RUN wget -qO- https://raw.githubusercontent.com/pypa/pip/1.5.5/contrib/get-pip.py | python -
2321

2422
# install hook dependencies
2523
RUN pip install pyyaml requests
2624

27-
# install hook utilities
28-
RUN apt-get install -yq curl vim
29-
3025
# install all i18n locales
3126
RUN ln -s /usr/share/i18n/SUPPORTED /var/lib/locales/supported.d/all && locale-gen
3227

3328
# install git and configure gituser
3429
ENV GITHOME /home/git
3530
ENV GITUSER git
36-
RUN apt-get install -yq git
3731
RUN useradd -d $GITHOME $GITUSER
3832
RUN mkdir -p $GITHOME/.ssh && chown git:git $GITHOME/.ssh
3933
RUN chown -R $GITUSER:$GITUSER $GITHOME
4034

4135
# let the git user run `sudo /home/git/builder` (not writeable)
42-
RUN apt-get install -yq sudo
4336
RUN echo "%git ALL=(ALL:ALL) NOPASSWD:/home/git/builder" >> /etc/sudoers
4437

4538
# add the current build context to /app

cache/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
44
# install redis from OS package
55
RUN apt-get update && apt-get install -yq python-software-properties
66
RUN add-apt-repository ppa:chris-lea/redis-server -y
7-
RUN apt-get update
8-
RUN apt-get install -yq redis-server
7+
RUN apt-get update && apt-get install -yq redis-server
98

109
# add the current build context to /app
1110
ADD . /app

controller/Dockerfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ FROM deis/base:latest
22
MAINTAINER OpDemand <info@opdemand.com>
33

44
# install required system packages
5+
# HACK: install git so we can install bacongobbler's fork of django-fsm
6+
# install openssh-client for temporary fleetctl wrapper
57
RUN apt-get update && \
6-
apt-get install -yq python-dev libpq-dev libyaml-dev
8+
apt-get install -yq python-dev libpq-dev libyaml-dev git openssh-client
79

810
# install recent pip
911
RUN wget -qO- https://raw.githubusercontent.com/pypa/pip/1.5.5/contrib/get-pip.py | python -
1012

11-
# HACK: install git so we can install bacongobbler's fork of django-fsm
12-
RUN apt-get install -yq git
13-
14-
# install openssh-client for temporary fleetctl wrapper
15-
RUN apt-get install -yq openssh-client
16-
1713
# add a deis user that has passwordless sudo (for now)
1814
RUN useradd deis --groups sudo --home-dir /app --shell /bin/bash
1915
RUN sed -i -e 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/' /etc/sudoers

database/Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ FROM deis/base:latest
22
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

44
# install 9.3 from postgresql.org repository
5-
RUN apt-get -yq install wget ca-certificates
65
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
76
RUN wget --quiet --no-check-certificate -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
8-
RUN apt-get update
9-
RUN apt-get install -yq postgresql-9.3 && /etc/init.d/postgresql stop
10-
11-
# debug to remove
12-
RUN apt-get install -yq curl
7+
RUN apt-get update && apt-get install -yq postgresql-9.3 && /etc/init.d/postgresql stop
138

149
# add the current build context to /app
1510
ADD . /app

logger/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ FROM deis/base:latest
22
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

44
# install go runtime
5-
RUN wget -O /tmp/go1.2.1.linux-amd64.tar.gz -q https://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz
6-
RUN tar -C /usr/local -xzf /tmp/go1.2.1.linux-amd64.tar.gz
5+
RUN wget -qO- https://storage.googleapis.com/golang/go1.2.2.linux-amd64.tar.gz | tar -C /usr/local -xz
76

87
# prepare go environment
98
RUN mkdir -p /go

registry/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ FROM deis/base:latest
22
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

44
# install required packages (copied from dotcloud/docker-registry Dockerfile)
5-
RUN sed -i 's/main$/main universe/' /etc/apt/sources.list
6-
RUN apt-get update
7-
RUN apt-get install -y git-core build-essential python-dev \
5+
RUN sed -i 's/main$/main universe/' /etc/apt/sources.list
6+
RUN apt-get update && apt-get install -y git-core build-essential python-dev \
87
libevent-dev python-openssl liblzma-dev wget
98

109
# install recent pip

router/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
FROM deis/base
1+
FROM deis/base:latest
22
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

4-
RUN apt-get update
5-
RUN apt-get install -yq patch libpcre3 libpcre3-dev libssl-dev libgeoip-dev
4+
RUN apt-get update && \
5+
apt-get install -yq patch libpcre3 libpcre3-dev libssl-dev libgeoip-dev
66

77
RUN wget -q http://nginx.org/download/nginx-1.6.0.tar.gz -O /tmp/nginx-1.6.0.tar.gz
88
RUN wget -q https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/v0.4.5.tar.gz -O /tmp/tcp-proxy.tar.gz
99

1010
WORKDIR /tmp
11-
1211
RUN tar -xzf nginx-1.6.0.tar.gz
1312
RUN tar -xzf tcp-proxy.tar.gz
1413

1514
WORKDIR /tmp/nginx-1.6.0
1615
RUN patch -p1 < /tmp/nginx_tcp_proxy_module-0.4.5/tcp.patch
1716
RUN ./configure --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_spdy_module --with-http_sub_module --with-mail --with-mail_ssl_module --add-module=/tmp/nginx_tcp_proxy_module-0.4.5
18-
RUN make
19-
RUN make install
17+
RUN make && make install
2018

2119
ADD . /app
2220
WORKDIR /app

0 commit comments

Comments
 (0)