Skip to content

Commit e66ca7e

Browse files
committed
Merge pull request #2102 from aledbf/reduce_controller_size
feat(controller): image without development libraries to reduce the size.
2 parents aabf393 + 2084164 commit e66ca7e

2 files changed

Lines changed: 48 additions & 28 deletions

File tree

controller/Dockerfile

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,13 @@ RUN curl -sSL -o /usr/local/bin/etcdctl https://s3-us-west-2.amazonaws.com/opdem
1313
RUN curl -sSL -o /usr/local/bin/confd https://s3-us-west-2.amazonaws.com/opdemand/confd-v0.5.0-json \
1414
&& chmod +x /usr/local/bin/confd
1515

16-
# install required system packages
17-
# HACK: install git so we can install bacongobbler's fork of django-fsm
18-
# install openssh-client for temporary fleetctl wrapper
19-
RUN apt-get update && \
20-
apt-get install -yq python-dev libpq-dev libyaml-dev git openssh-client
21-
22-
# install pip
23-
RUN curl -sSL https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | python -
24-
25-
# add a deis user that has passwordless sudo (for now)
26-
RUN useradd deis --groups sudo --home-dir /app --shell /bin/bash
27-
RUN sed -i -e 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/' /etc/sudoers
28-
29-
# create a /app directory for storing application data
30-
RUN mkdir -p /app && chown -R deis:deis /app
31-
32-
# create directory for confd templates
33-
RUN mkdir -p /templates && chown -R deis:deis /templates
34-
35-
# create directory for logs
36-
RUN mkdir -p /var/log/deis && chown -R deis:deis /var/log/deis
37-
3816
# define execution environment
3917
CMD ["/app/bin/boot"]
4018
EXPOSE 8000
4119

4220
# define work environment
4321
WORKDIR /app
4422

45-
# install dependencies
46-
ADD requirements.txt /app/requirements.txt
47-
RUN pip install -r /app/requirements.txt
48-
4923
ADD . /app
5024

51-
# Create static resources
52-
RUN /app/manage.py collectstatic --settings=deis.settings --noinput
25+
RUN DOCKER_BUILD=true /app/build.sh

controller/build.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -z $DOCKER_BUILD ]]; then
4+
echo
5+
echo "Note: this script is intended for use by the Dockerfile and not as a way to build the controller locally"
6+
echo
7+
exit 1
8+
fi
9+
10+
DEBIAN_FRONTEND=noninteractive
11+
12+
# install required system packages
13+
# HACK: install git so we can install bacongobbler's fork of django-fsm
14+
# install openssh-client for temporary fleetctl wrapper
15+
apt-get update && \
16+
apt-get install -yq python-dev libpq-dev libyaml-dev git
17+
18+
# install pip
19+
curl -sSL https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | python -
20+
21+
# add a deis user that has passwordless sudo (for now)
22+
useradd deis --groups sudo --home-dir /app --shell /bin/bash
23+
sed -i -e 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/' /etc/sudoers
24+
25+
# create a /app directory for storing application data
26+
mkdir -p /app && chown -R deis:deis /app
27+
28+
# create directory for confd templates
29+
mkdir -p /templates && chown -R deis:deis /templates
30+
31+
# create directory for logs
32+
mkdir -p /var/log/deis && chown -R deis:deis /var/log/deis
33+
34+
# install dependencies
35+
pip install -r /app/requirements.txt
36+
37+
# Create static resources
38+
/app/manage.py collectstatic --settings=deis.settings --noinput
39+
40+
# cleanup. indicate that python, libpq and libyanl are required packages.
41+
apt-mark unmarkauto python python-openssl libpq5 libpython2.7 libyaml-0-2 && \
42+
apt-get remove -y --purge python-dev gcc cpp libpq-dev libyaml-dev git && \
43+
apt-get autoremove -y --purge && \
44+
apt-get clean -y && \
45+
rm -Rf /usr/share/man /usr/share/doc && \
46+
rm -rf /tmp/* /var/tmp/* && \
47+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)