forked from mozilla-releng/balrog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce docker container from 776.9MB to 246.6MB (uncompressed) (mozil…
…la-releng#153). r=bhearsum Each command in a Dockerfile creates a new layer. To keep the final docker image small build dependencies must be removed in the same Dockerfile command. Removing data in separate commands does not make the final image smaller. This commit uses the above technique for adding and building with pip+gcc and node+npm dependencies. It also adds a few extra cleanup commands for files in /root/cache/.pip, /root/.npm and /tmp/phantomjs.
- Loading branch information
1 parent
281a2ba
commit c2f64e2
Showing
1 changed file
with
17 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ MAINTAINER [email protected] | |
# Node and npm are to build the frontend. nodejs-legacy is needed by this version of npm. These will get removed after building. | ||
# libmysqlclient-dev is required to use SQLAlchemy with MySQL, which we do in production. | ||
RUN apt-get -q update \ | ||
&& apt-get -q --yes install libpcre3 libpcre3-dev nodejs nodejs-legacy npm libmysqlclient-dev \ | ||
&& apt-get -q --yes install libpcre3 libpcre3-dev libmysqlclient-dev \ | ||
&& apt-get clean | ||
|
||
WORKDIR /app | ||
|
@@ -15,7 +15,12 @@ WORKDIR /app | |
# these rarely change and is more cache friendly | ||
# ... really speeds up building new containers | ||
COPY requirements.txt /app/ | ||
RUN pip install -r requirements.txt | ||
RUN apt-get install -q --yes gcc && \ | ||
pip install -r requirements.txt && \ | ||
apt-get -q --yes remove gcc && \ | ||
apt-get -q --yes autoremove && \ | ||
apt-get clean && \ | ||
rm -rf /root/.cache | ||
|
||
# Copying Balrog to /app instead of installing it means that production can run | ||
# it, and we can bind mount to override it for local development. | ||
|
@@ -24,19 +29,19 @@ COPY ui/ /app/ui/ | |
COPY uwsgi/ /app/uwsgi/ | ||
COPY scripts/manage-db.py scripts/run-batch-deletes.sh scripts/run.sh /app/scripts/ | ||
COPY version.json /app/ | ||
RUN rm -rf /app/auslib/test | ||
|
||
WORKDIR /app/ui | ||
RUN npm install | ||
RUN npm run build | ||
|
||
RUN find . -maxdepth 1 -not -name dist -exec rm -rf {} \; | ||
|
||
RUN apt-get -q --yes remove nodejs nodejs-legacy npm \ | ||
&& apt-get clean | ||
|
||
WORKDIR /app | ||
|
||
RUN cd ui && \ | ||
apt-get -q --yes install nodejs nodejs-legacy npm && \ | ||
npm install && \ | ||
npm run build && \ | ||
apt-get -q --yes remove nodejs nodejs-legacy npm && \ | ||
apt-get -q --yes autoremove && \ | ||
apt-get clean && \ | ||
rm -rf /root/.npm /tmp/phantomjs && \ | ||
find . -maxdepth 1 -not -name dist -exec rm -rf {} \; | ||
|
||
# Using /bin/bash as the entrypoint works around some volume mount issues on Windows | ||
# where volume-mounted files do not have execute bits set. | ||
# https://github.com/docker/compose/issues/2301#issuecomment-154450785 has additional background. | ||
|