Skip to content

Commit 8b63ece

Browse files
committed
Make Docker flexible by supporting command args
docker build -t wirecloudx . --build-arg GITHUB_ACCOUNT=<my-account> --build-arg GITHUB_REPOSITORY=<your repo> --build-arg SOURCE_BRANCH=<your branch>
1 parent 0b45ccb commit 8b63ece

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

dev/Dockerfile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
FROM python:3.6-stretch
1+
2+
ARG PYTHON_VERSION=3.6-stretch
3+
FROM python:${PYTHON_VERSION}
4+
5+
ARG GITHUB_ACCOUNT=Wirecloud
6+
ARG GITHUB_REPOSITORY=wirecloud
7+
ARG SOURCE_BRANCH=master
8+
9+
# Copying Build time arguments to environment variables so they are persisted at run time and can be
10+
# inspected within a running container.
11+
# see: https://vsupalov.com/docker-build-time-env-values/ for a deeper explanation.
12+
13+
ENV GITHUB_ACCOUNT=${GITHUB_ACCOUNT} \
14+
GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
215

316
MAINTAINER WireCloud Team <wirecloud@conwet.com>
417

5-
ENV DEFAULT_THEME=wirecloud.defaulttheme
6-
ENV FORWARDED_ALLOW_IPS=*
7-
ENV DB_PORT=5432
18+
ENV DEFAULT_THEME=wirecloud.defaulttheme \
19+
FORWARDED_ALLOW_IPS=* \
20+
DB_PORT=5432
821

922
RUN apt-get update && \
1023
apt-get install -y libmemcached-dev gosu && \
@@ -13,14 +26,14 @@ RUN apt-get update && \
1326
gosu nobody true
1427

1528
# Install WireCloud & dependencies
16-
RUN git clone --depth=1 https://github.com/Wirecloud/wirecloud.git && \
29+
RUN git clone -b "${SOURCE_BRANCH}" --depth=1 --single-branch https://github.com/"${GITHUB_ACCOUNT}"/"${GITHUB_REPOSITORY}".git && \
1730
apt-get update && apt-get install -y gettext && \
1831
pip install "django<=1.11" && \
19-
cd wirecloud/src && \
32+
cd "${GITHUB_REPOSITORY}"/src && \
2033
python setup.py bdist_wheel && \
2134
pip install --no-cache-dir dist/*.whl && \
2235
cd ../.. && \
23-
rm -rf wirecloud && \
36+
rm -rf "${GITHUB_REPOSITORY}" && \
2437
apt-get remove -y gettext && \
2538
rm -rf /var/lib/apt/lists/*
2639

0 commit comments

Comments
 (0)