docker: allow to specify the branch to pull for various repos
authorJordan Petridis <jordan@centricular.com>
Mon, 10 Feb 2020 13:09:49 +0000 (15:09 +0200)
committerJordan Petridis <jpetridis@gnome.org>
Sun, 8 Mar 2020 18:53:23 +0000 (18:53 +0000)
Declare an docker build-arg [1] and use it
whenever cloning one of our repositories. If the buildarg
is not specified, the variable defaults back to 'master'
and thus the current behavior doesn't change.

From the .gitlab-ci.yml file, when building pass
the GST_UPSTREAM_BRANCH that's defined from the ci_template
as the buildarg so we will be building the corresponding branches
for the docker images.

Close #33

[1] https://docs.docker.com/engine/reference/builder/#arg

.gitlab-ci.yml
docker/android/Dockerfile
docker/android/prepare.sh
docker/build_manifest/Dockerfile
docker/cerbero/Dockerfile-fedora
docker/fedora/Dockerfile
docker/fedora/prepare.sh

index 760b7a1..b55554e 100644 (file)
@@ -1,3 +1,5 @@
+include: "gitlab/ci_template.yml"
+
 stages:
   - "build docker"
   - "preparation"
@@ -36,7 +38,7 @@ test manifest:
     - export _UID="${IMAGE}:${DATE}-${CI_JOB_ID}"
     - export LATEST="${IMAGE}:latest"
 
-    - docker build --pull -f ${DOCKERFILE} -t ${LATEST} ${CONTEXT_DIR}
+    - docker build --pull --build-arg DEFAULT_BRANCH=${GST_UPSTREAM_BRANCH} -f ${DOCKERFILE} -t ${LATEST} ${CONTEXT_DIR}
 
     # If we are in a fork, push the image to the reigstry regardless the branch
     - |
@@ -110,8 +112,6 @@ android docker:
     DOCKERFILE: "docker/android/Dockerfile"
   extends: .base
 
-include: "gitlab/ci_template.yml"
-
 .build local:
   extends: '.build'
   when: 'manual'
index 05a7ab4..f874ff0 100644 (file)
@@ -3,6 +3,8 @@ FROM registry.fedoraproject.org/fedora:31
 ENV ANDROID_HOME=/android/sdk
 ENV ANDROID_NDK_HOME=/android/ndk
 
+ARG DEFAULT_BRANCH="master"
+
 COPY prepare.sh cleanup.sh /root/
 
 RUN /usr/bin/sh /root/prepare.sh && \
index 3284392..4b01162 100644 (file)
@@ -37,11 +37,11 @@ mkdir $GSTREAMER_ROOT_ANDROID
 tar -xvf /android/sources/gstreamer-android.tar.xz -C $GSTREAMER_ROOT_ANDROID
 ls $GSTREAMER_ROOT_ANDROID
 
-git clone https://gitlab.freedesktop.org/gstreamer/gst-examples.git /android/sources/gst-examples
+git clone -b ${DEFAULT_BRANCH} https://gitlab.freedesktop.org/gstreamer/gst-examples.git /android/sources/gst-examples
 chmod +x /android/sources/gst-examples/playback/player/android/gradlew
 /android/sources/gst-examples/playback/player/android/gradlew --no-search-upward --no-daemon --project-dir /android/sources/gst-examples/playback/player/android dependencies --refresh-dependencies
 
-git clone https://gitlab.freedesktop.org/gstreamer/gst-docs.git /android/sources/gst-docs
+git clone -b ${DEFAULT_BRANCH} https://gitlab.freedesktop.org/gstreamer/gst-docs.git /android/sources/gst-docs
 chmod +x /android/sources/gst-docs/examples/tutorials/android/gradlew
 /android/sources/gst-docs/examples/tutorials/android/gradlew --no-search-upward --no-daemon --project-dir /android/sources/gst-docs/examples/tutorials/android dependencies --refresh-dependencies
 
index a0b85bb..e3c4921 100644 (file)
@@ -1,5 +1,7 @@
 FROM  python:3.7.1-alpine
 
+ARG DEFAULT_BRANCH="master"
+
 RUN pip install requests
 RUN apk add git
-RUN cd / && git clone https://gitlab.freedesktop.org/gstreamer/gst-ci.git
\ No newline at end of file
+RUN cd / && git clone -b ${DEFAULT_BRANCH:=master} https://gitlab.freedesktop.org/gstreamer/gst-ci.git
index b3d22d9..2347399 100644 (file)
@@ -2,6 +2,8 @@ FROM registry.fedoraproject.org/fedora:31
 
 ENV TERM="dumb"
 
+ARG DEFAULT_BRANCH="master"
+
 # System setup
 RUN echo "fastestmirror=true" >>  /etc/dnf/dnf.conf && \
     dnf upgrade -y && \
@@ -11,7 +13,7 @@ RUN echo "fastestmirror=true" >>  /etc/dnf/dnf.conf && \
 RUN git config --global user.email "cerbero@gstreamer.freedesktop.org" && \
     git config --global user.name  "Cerbero Build System"
 
-RUN git clone https://gitlab.freedesktop.org/gstreamer/cerbero.git && \
+RUN git clone -b ${DEFAULT_BRANCH} https://gitlab.freedesktop.org/gstreamer/cerbero.git && \
     mkdir $HOME/.cerbero && \
     echo "allow_parallel_build=True" > $HOME/.cerbero/cerbero.cbc && \
     echo "use_ccache=True" >> $HOME/.cerbero/cerbero.cbc && \
index 56f9279..82abdd3 100644 (file)
@@ -4,6 +4,8 @@ ENV RUSTUP_HOME=/usr/local/rustup \
     CARGO_HOME=/usr/local/cargo \
     PATH=/usr/local/cargo/bin:$PATH
 
+ARG DEFAULT_BRANCH="master"
+
 COPY prepare.sh cleanup.sh /root/
 
 RUN /usr/bin/sh /root/prepare.sh && \
index 5b79d7a..e52d8cc 100644 (file)
@@ -223,6 +223,6 @@ cargo --version
 rustc --version
 
 # get gst-build and make all subprojects available
-git clone git://anongit.freedesktop.org/gstreamer/gst-build /gst-build/
+git clone -b ${DEFAULT_BRANCH} https://gitlab.freedesktop.org/gstreamer/gst-build.git /gst-build/
 cd /gst-build
 meson subprojects download