Skip to content

Commit

Permalink
Optimize python build time #562
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Jul 3, 2023
1 parent 7714f55 commit 31e2169
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 44 deletions.
19 changes: 1 addition & 18 deletions utils/build/docker/python/django-poc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
FROM python:3.9

# print versions
RUN python --version && curl --version

# install hello world app
RUN pip install django pycryptodome gunicorn gevent requests

RUN mkdir app
RUN django-admin startproject django_app app
WORKDIR /app
RUN python3 manage.py startapp app

RUN sed -i "1s/^/from django.urls import include\n/" django_app/urls.py
RUN sed -i "s/admin\///g" django_app/urls.py
RUN sed -i "s/admin.site.urls/include(\"app.urls\")/g" django_app/urls.py
RUN sed -i "s/ALLOWED_HOSTS\s=\s\[\]/ALLOWED_HOSTS = \[\"0.0.0.0\",\"weblog\"\,\"localhost\"\]/g" django_app/settings.py
FROM datadog/system-tests:django-poc.base-v0

COPY utils/build/docker/python/django/app.sh /app/app.sh
COPY utils/build/docker/python/django/django.app.urls.py /app/app/urls.py
COPY utils/build/docker/python/iast.py /app/iast.py


COPY utils/build/docker/python/install_ddtrace.sh utils/build/docker/python/get_appsec_rules_version.py binaries* /binaries/
RUN /binaries/install_ddtrace.sh

Expand Down
25 changes: 25 additions & 0 deletions utils/build/docker/python/django-poc.base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.9-slim

# install bin dependancies
RUN apt-get update && apt-get install -y curl git gcc g++

# print versions
RUN python --version && curl --version

# install python deps
RUN pip install django pycryptodome gunicorn gevent requests

RUN mkdir app
RUN django-admin startproject django_app app
WORKDIR /app
RUN python3 manage.py startapp app

RUN sed -i "1s/^/from django.urls import include\n/" django_app/urls.py
RUN sed -i "s/admin\///g" django_app/urls.py
RUN sed -i "s/admin.site.urls/include(\"app.urls\")/g" django_app/urls.py
RUN sed -i "s/ALLOWED_HOSTS\s=\s\[\]/ALLOWED_HOSTS = \[\"0.0.0.0\",\"weblog\"\,\"localhost\"\]/g" django_app/settings.py


# docker build --progress=plain -f utils/build/docker/python/django-poc.base.Dockerfile -t datadog/system-tests:django-poc.base-v0 .
# docker push datadog/system-tests:django-poc.base-v0

12 changes: 2 additions & 10 deletions utils/build/docker/python/flask-poc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
FROM python:3.9

# print versions
RUN python --version && curl --version

# install hello world app
# Tracer does not support flask 2.3.0 or higher, pin the flask version for now
RUN pip install flask==2.2.4 gunicorn gevent requests pycryptodome psycopg2
FROM datadog/system-tests:flask-poc.base-v0

COPY utils/build/docker/python/flask /app
COPY utils/build/docker/python/iast.py /app/iast.py
Expand All @@ -23,6 +16,5 @@ ENV DD_REMOTECONFIG_POLL_SECONDS=1
ENV FLASK_APP=app.py
CMD ./app.sh

# docker build -f utils/build/docker/python.flask-poc.Dockerfile -t test .
# docker build -f utils/build/docker/python/flask-poc.Dockerfile -t test .
# docker run -ti -p 7777:7777 test

15 changes: 15 additions & 0 deletions utils/build/docker/python/flask-poc.base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.9-slim

# install bin dependancies
RUN apt-get update && apt-get install -y curl git gcc g++

# print versions
RUN python --version && curl --version

# install python deps
# Tracer does not support flask 2.3.0 or higher, pin the flask version for now
RUN pip install flask==2.2.4 gunicorn gevent requests pycryptodome psycopg2-binary

# docker build --progress=plain -f utils/build/docker/python/flask-poc.base.Dockerfile -t datadog/system-tests:flask-poc.base-v0 .
# docker push datadog/system-tests:flask-poc.base-v0

9 changes: 1 addition & 8 deletions utils/build/docker/python/uds-flask.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
FROM python:3.9

# print versions
RUN python --version && curl --version

# install hello world app
# Tracer does not support flask 2.3.0 or higher, pin the flask version for now
RUN pip install flask==2.2.4 gunicorn gevent requests pycryptodome psycopg2
FROM datadog/system-tests:flask-poc.base-v0

COPY utils/build/docker/python/flask /app
COPY utils/build/docker/python/iast.py /app/iast.py
Expand Down
9 changes: 1 addition & 8 deletions utils/build/docker/python/uwsgi-poc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
FROM python:3.9

# print versions
RUN python --version && curl --version

# install hello world app
# Tracer does not support flask 2.3.0 or higher, pin the flask version for now
RUN pip install flask==2.2.4 uwsgi requests pycryptodome psycopg2
FROM datadog/system-tests:flask-poc.base-v0

COPY utils/build/docker/python/flask /app
COPY utils/build/docker/python/iast.py /app/iast.py
Expand Down

0 comments on commit 31e2169

Please sign in to comment.