Skip to content

Commit 420b781

Browse files
authored
Merge pull request #43 from aarranz/feature/slim-version
Reduce dev image size
2 parents d9d5fe1 + b8f79d2 commit 420b781

3 files changed

Lines changed: 40 additions & 32 deletions

File tree

dev/Dockerfile

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,68 @@
1-
ARG PYTHON_VERSION=3.6-stretch
2-
FROM python:${PYTHON_VERSION}
1+
ARG PYTHON_VERSION=3.6
32

43
ARG GITHUB_ACCOUNT=Wirecloud
54
ARG GITHUB_REPOSITORY=wirecloud
65
ARG SOURCE_BRANCH=develop
76

7+
8+
9+
FROM python:${PYTHON_VERSION} AS builder
10+
11+
ARG GITHUB_ACCOUNT
12+
ARG GITHUB_REPOSITORY
13+
ARG SOURCE_BRANCH
14+
15+
# Build WireCloud wheel
16+
RUN git clone -b "${SOURCE_BRANCH}" --depth=1 --single-branch https://github.com/"${GITHUB_ACCOUNT}"/"${GITHUB_REPOSITORY}".git && \
17+
apt-get update && apt-get install -y gettext && \
18+
pip install "django<=2.3" && \
19+
cd "${GITHUB_REPOSITORY}"/src && \
20+
python setup.py bdist_wheel
21+
22+
23+
24+
FROM python:${PYTHON_VERSION}-slim
25+
26+
ARG GITHUB_ACCOUNT
27+
ARG GITHUB_REPOSITORY
28+
ARG SOURCE_BRANCH
29+
830
# Copying Build time arguments to environment variables so they are persisted at run time and can be
931
# inspected within a running container.
1032
# see: https://vsupalov.com/docker-build-time-env-values/ for a deeper explanation.
1133

1234
ENV GITHUB_ACCOUNT=${GITHUB_ACCOUNT} \
13-
GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
14-
15-
MAINTAINER WireCloud Team <wirecloud@conwet.com>
16-
17-
ENV DEFAULT_THEME=wirecloud.defaulttheme \
35+
GITHUB_REPOSITORY=${GITHUB_REPOSITORY} \
36+
DEFAULT_THEME=wirecloud.defaulttheme \
1837
FORWARDED_ALLOW_IPS=* \
1938
DB_PORT=5432 \
2039
LOGLEVEL=info
2140

22-
RUN apt-get update && \
23-
apt-get install -y libmemcached-dev gosu && \
24-
pip install --no-cache-dir social-auth-app-django "gunicorn==19.3.0" "psycopg2==2.6" pylibmc pysolr "elasticsearch==2.4.1" && \
25-
rm -rf /var/lib/apt/lists/* && \
26-
gosu nobody true
27-
2841
# Install WireCloud & dependencies
29-
RUN git clone -b "${SOURCE_BRANCH}" --depth=1 --single-branch https://github.com/"${GITHUB_ACCOUNT}"/"${GITHUB_REPOSITORY}".git && \
30-
apt-get update && apt-get install -y gettext && \
31-
pip install "django<=1.11" && \
32-
cd "${GITHUB_REPOSITORY}"/src && \
33-
python setup.py bdist_wheel && \
34-
pip install --no-cache-dir dist/*.whl && \
35-
cd ../.. && \
36-
rm -rf "${GITHUB_REPOSITORY}" && \
37-
apt-get remove -y gettext && \
38-
rm -rf /var/lib/apt/lists/*
39-
42+
COPY --from=builder ${GITHUB_REPOSITORY}/src/dist /dist
4043
COPY ./docker-entrypoint.sh /
4144
COPY ./manage.py /usr/local/bin/
4245

43-
RUN adduser --system --group --shell /bin/bash wirecloud && \
44-
pip install --no-cache-dir channels asgi_ipc asgi_redis asgi_rabbitmq && \
45-
pip install wirecloud-keycloak && \
46+
RUN apt-get update && \
47+
apt-get install -y --no-install-recommends libmemcached-dev gosu gcc ca-certificates curl && \
48+
pip install --no-cache-dir social-auth-app-django "gunicorn==19.3.0" psycopg2-binary pylibmc pysolr "elasticsearch==2.4.1" && \
49+
pip install --no-cache-dir /dist/*.whl && \
50+
rm -rf /dist && \
51+
adduser --system --group --shell /bin/bash wirecloud && \
52+
pip install --no-cache-dir "channels<2.3" "channels-redis" "channels-rabbitmq" wirecloud-keycloak && \
4653
mkdir -p /opt/wirecloud_instance /var/www/static && \
4754
cd /opt && \
4855
wirecloud-admin startproject wirecloud_instance wirecloud_instance && \
4956
chown -R wirecloud:wirecloud wirecloud_instance /var/www/static && \
5057
chmod a+x wirecloud_instance/manage.py && \
51-
chmod a+x /docker-entrypoint.sh
58+
chmod a+x /docker-entrypoint.sh && \
59+
apt-get remove -y gcc libmemcached-dev --autoremove && \
60+
rm -rf /var/lib/apt/lists/*
5261

5362
COPY ./settings.py ./urls.py /opt/wirecloud_instance/wirecloud_instance/
5463

5564
WORKDIR /opt/wirecloud_instance
5665

57-
# volumes must be created after running the collectstatic command
5866
VOLUME /var/www/static
5967
VOLUME /opt/wirecloud_instance/data
6068

dev/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import os
55
from wirecloud.commons.utils.conf import load_default_wirecloud_conf
6-
from django.core.urlresolvers import reverse_lazy
6+
from django.urls import reverse_lazy
77

88
DEBUG = os.environ.get("DEBUG", "False").strip().lower() == "true"
99
BASEDIR = os.path.dirname(os.path.abspath(__file__))

dev/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
admin.autodiscover()
1515

16-
login_method = django_auth.login
16+
login_method = django_auth.LoginView.as_view()
1717
if settings.IDM_AUTH == 'fiware':
1818
login_method = wc_fiware.login
1919

@@ -34,7 +34,7 @@
3434
url(r'^admin/logout/?$', wc_auth.logout),
3535

3636
# Admin interface
37-
url(r'^admin/', include(admin.site.urls)),
37+
url(r'^admin/', admin.site.urls),
3838
)
3939

4040
if settings.IDM_AUTH:

0 commit comments

Comments
 (0)