Skip to content

Commit 4d41975

Browse files
authored
Merge pull request #4 from HarmvZ/add-dev-build-stage
Improve container build stages
2 parents 8f29619 + d4cb293 commit 4d41975

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

deploy/Dockerfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM ubuntu:16.04
15+
FROM ubuntu:16.04 as base-stage
1616

1717
# Install required packages and remove the apt packages cache when done.
1818

@@ -24,8 +24,6 @@ RUN apt-get update && \
2424
python3-dev \
2525
python3-setuptools \
2626
python3-pip \
27-
nginx \
28-
supervisor \
2927
cron \
3028
tzdata \
3129
sqlite3 && \
@@ -36,22 +34,32 @@ RUN apt-get update && \
3634
ENV TZ=Europe/Amsterdam
3735
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
3836

39-
# install uwsgi now because it takes a little while
40-
RUN pip3 install uwsgi
37+
# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
38+
# to prevent re-installing (all your) dependencies when you made a change a line or two in your app.
39+
40+
COPY requirements /home/docker/code/
4141

42+
43+
44+
From base-stage as develop-stage
45+
RUN pip3 install -r /home/docker/code/local.txt
46+
47+
# add (the rest of) our code
48+
COPY . /home/docker/code/
49+
50+
51+
52+
FROM base-stage as production-stage
4253
# setup all the configfiles
4354
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
4455
COPY deploy/nginx-app.conf /etc/nginx/sites-available/default
4556
COPY deploy/supervisor-app.conf /etc/supervisor/conf.d/
4657

47-
# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
48-
# to prevent re-installing (all your) dependencies when you made a change a line or two in your app.
4958

50-
COPY requirements /home/docker/code/
5159
RUN pip3 install -r /home/docker/code/production.txt
5260

5361
# add (the rest of) our code
5462
COPY . /home/docker/code/
5563

5664
EXPOSE 8888
57-
CMD ["supervisord", "-n"]
65+
CMD ["supervisord", "-n"]

dockerfiles/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

dockerfiles/env

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)