Skip to content

Commit 30e1e7f

Browse files
author
Matthew Fisher
committed
refactor(controller): optimize layer creation
This restructures the Dockerfile in such a way that allows users to rebuild the controller with minimal changes to the docker image's layers.
1 parent 32fc59f commit 30e1e7f

1 file changed

Lines changed: 17 additions & 29 deletions

File tree

controller/Dockerfile

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,35 @@ RUN wget -qO- https://raw.githubusercontent.com/pypa/pip/1.5.5/contrib/get-pip.p
1111
# HACK: install git so we can install bacongobbler's fork of django-fsm
1212
RUN apt-get install -yq git
1313

14-
# install requirements before ADD to cache layer and speed build
15-
RUN pip install celery==3.1.11 \
16-
Django==1.6.4 \
17-
django-allauth==0.15.0 \
18-
git+https://github.com/deis/django-fsm@add-exception-handling \
19-
django-guardian==1.1.1 \
20-
django-json-field==0.5.5 \
21-
django-yamlfield==0.5 \
22-
djangorestframework==2.3.13 \
23-
gunicorn==18.0 \
24-
psycopg2==2.5.2 \
25-
python-etcd==0.3.0 \
26-
PyYAML==3.10 \
27-
redis==2.9.1 \
28-
static==1.0.2 \
29-
South==0.8.4
30-
3114
# install openssh-client for temporary fleetctl wrapper
3215
RUN apt-get install -yq openssh-client
3316

34-
# clone the project into /app
35-
ADD . /app
36-
37-
# install python requirements
38-
RUN pip install -r /app/requirements.txt
39-
40-
# Create static resources
41-
RUN /app/manage.py collectstatic --settings=deis.settings --noinput
42-
4317
# add a deis user that has passwordless sudo (for now)
4418
RUN useradd deis --groups sudo --home-dir /app --shell /bin/bash
4519
RUN sed -i -e 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/' /etc/sudoers
46-
RUN chown -R deis:deis /app
20+
21+
# create a /app directory for storing application data
22+
RUN mkdir -p /app && chown -R deis:deis /app
4723

4824
# create directory for confd templates
4925
RUN mkdir -p /templates && chown -R deis:deis /templates
5026

5127
# create directory for logs
5228
RUN mkdir -p /var/log/deis && chown -R deis:deis /var/log/deis
5329

54-
# define the execution environment
55-
WORKDIR /app
30+
# define execution environment
5631
CMD ["/app/bin/boot"]
5732
EXPOSE 8000
33+
34+
# define work environment
35+
WORKDIR /app
36+
37+
# install dependencies
38+
ADD requirements.txt /app/requirements.txt
39+
RUN pip install -r /app/requirements.txt
40+
41+
# clone the project into /app
42+
ADD . /app
43+
44+
# Create static resources
45+
RUN /app/manage.py collectstatic --settings=deis.settings --noinput

0 commit comments

Comments
 (0)