Add possibility to build packages inside docker 82/48382/9
authorMichal Skalski <mskalski@mirantis.com>
Wed, 16 Nov 2016 00:34:27 +0000 (01:34 +0100)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 16 Nov 2016 20:04:22 +0000 (15:04 -0500)
Also add recent RPM/.deb build_vars.yaml sections.

Change-Id: I7dc501d552d8e345c70612b88ab534e54dd81dc2
Signed-off-by: Michal Skalski <mskalski@mirantis.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
deb/.dockerignore [new file with mode: 0644]
deb/.gitignore [new file with mode: 0644]
deb/Dockerfile [new file with mode: 0644]
deb/README.markdown
deb/Vagrantfile
deb/build_vars.yaml
rpm/.dockerignore [new file with mode: 0644]
rpm/Dockerfile [new file with mode: 0644]
rpm/README.markdown
rpm/Vagrantfile
rpm/build_vars.yaml

diff --git a/deb/.dockerignore b/deb/.dockerignore
new file mode 100644 (file)
index 0000000..4116958
--- /dev/null
@@ -0,0 +1,2 @@
+opendaylight
+cache
diff --git a/deb/.gitignore b/deb/.gitignore
new file mode 100644 (file)
index 0000000..9bf4d18
--- /dev/null
@@ -0,0 +1,2 @@
+*.deb
+*.tar.gz
diff --git a/deb/Dockerfile b/deb/Dockerfile
new file mode 100644 (file)
index 0000000..f2f8aa8
--- /dev/null
@@ -0,0 +1,15 @@
+# Dockerfile
+FROM debian:jessie-backports
+
+ENV DEBIAN_FRONTEND noninteractive
+RUN apt-get update && apt-get install -y \
+        build-essential \
+        sudo \
+        devscripts \
+        equivs \
+        dh-systemd \
+        python-yaml \
+        python-jinja2
+RUN mkdir -p /build
+ENTRYPOINT ["/build/build.py"]
+CMD ["-h"]
index 5a05e8e9ffd85f404ac5ecc04dc560d4d5e2503d..fb4edf3b62b7297176d33109db56a90e11bf9008 100644 (file)
@@ -5,6 +5,7 @@ Logic for building OpenDaylight's upstream Debian packages.
 #### Table of Contents
 1. [Overview](#overview)
 1. [Vagrant Build Environment](#vagrant-build-environment)
+  * [Docker provider](#docker-provider)
 1. [Building Debs](#building-debs)
 1. [Defining New Debs](#defining-new-debs)
   * [Deb Build Variables](#deb-build-variables)
@@ -23,8 +24,8 @@ TODO: Overview of Debian pkg builds, plans
 
 ## Vagrant Build Environment
 
-Deb builds can be done in the included Vagrantfile. It provides a
-consistent, known-working and easily shared environment.
+The included Vagrantfile defines a consistent, known-working and easily
+shared environment. It supports both VM and container-based providers.
 
     [~/packaging/deb]$ vagrant status
     Current machine states:
@@ -35,6 +36,28 @@ consistent, known-working and easily shared environment.
     [vagrant@localhost ~]$ ls /vagrant/
     opendaylight  README.markdown  Vagrantfile
 
+### Docker provider
+
+The Vagrantfile defines a Docker provider, enabling easy access to build.py
+in a container. The general command format is:
+
+```
+$ vagrant docker-run -- <flags to build.py>
+```
+
+To pass 5.0 (Boron) as the version to build:
+
+```
+$ vagrant docker-run -- -v 5 0
+```
+
+Dockerfile can be also used directly to build container image:
+
+```
+$ docker build -t "odl_deb" .
+$ docker run -v $(pwd):/build odl_deb -v 5 0
+```
+
 ## Building Debs
 
 The `build.py` helper script is used for building OpenDaylight .debs.
@@ -243,4 +266,4 @@ host Debs for consumption. The Boron .deb package for Debian/Ubuntu, can be inst
 following the instructions given [here][2].
 
 [1]: https://build.opensuse.org/
-[2]: http://software.opensuse.org/download.html?project=home%3Aakshitajha&package=opendaylight
\ No newline at end of file
+[2]: http://software.opensuse.org/download.html?project=home%3Aakshitajha&package=opendaylight
index 5d324b25634098109d1e6ad48855961e681f4b95..d3cb0c3cd7f741a84d069607c3862169295e86b5 100644 (file)
@@ -1,19 +1,32 @@
 # -*- mode: ruby -*-
 # vi: set ft=ruby :
 
+BOX = "debian/jessie64"
+BOX_VERSION = "= 8.5.2"
+
 Vagrant.configure("2") do |config|
   # Configure VM RAM and CPU for VirtualBox
-  config.vm.provider :virtualbox do |virtualbox|
+  config.vm.provider :virtualbox do |virtualbox, override|
     virtualbox.memory = 1024
     # Two cores over default one for faster builds
     virtualbox.cpus = 2
+    override.vm.box = BOX
+    override.vm.box_version = BOX_VERSION
   end
 
   # Configure VM RAM and CPU for LibVirt
-  config.vm.provider :libvirt do |libvirt|
+  config.vm.provider :libvirt do |libvirt, override|
     libvirt.memory = 1024
     # Two cores over default one for faster builds
     libvirt.cpus = 2
+    override.vm.box = BOX
+    override.vm.box_version = BOX_VERSION
+  end
+
+  config.vm.provider "docker" do |docker, override|
+    docker.build_dir = "."
+    docker.remains_running = false
+    override.vm.synced_folder ".", "/build"
   end
 
   # NFS is fragile, disable it and use rsync
@@ -22,10 +35,6 @@ Vagrant.configure("2") do |config|
   # Sync folders /packaging/deb/ and /vagrant
   config.vm.synced_folder ".", "/vagrant"
 
-  # Start from Debian VM so resulting pkgs will build on all Deb derivatives
-  config.vm.box = "debian/jessie64"
-  config.vm.box_version = "= 8.5.2"
-
   # Update package info to prevent old info from causing 404s during install
   config.vm.provision "shell", inline: "apt-get update"
 
index 2cb456e3ec5253b90d4fc079efc60cc7e72e47a7..066763da7b5ea39454a5aabe1b525913c8b994d8 100644 (file)
@@ -46,21 +46,45 @@ builds:
     pkg_version: "1"
     sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
     codename: Beryllium-SR3
-    download_url: "https://nexus.opendaylight.org/content/repositories/autorelease-1367/org/opendaylight/integration/distribution-karaf/0.4.3-Beryllium-SR3/distribution-karaf-0.4.3-Beryllium-SR3.tar.gz"
+    download_url: "https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.4.3-Beryllium-SR3/distribution-karaf-0.4.3-Beryllium-SR3.tar.gz"
     java_version: "7"
     changelog_date: "Tue, 26 Jul 2016"
     changelog_time: "17:48:42 +0530"
     changelog_name: "Daniel Farrell"
     changelog_email: "dfarrell@redhat.com"
+  - version_major: "4"
+    version_minor: "4"
+    version_patch: "0"
+    pkg_version: "1"
+    sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
+    codename: Beryllium-SR4
+    download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.4.4-Beryllium-SR4/distribution-karaf-0.4.4-Beryllium-SR4.tar.gz"
+    java_version: "7"
+    changelog_date: "Wed, 16 Nov 2016"
+    changelog_time: "01:40:00 +0100"
+    changelog_name: "Michal Skalski"
+    changelog_email: "mskalski@mirantis.com"
   - version_major: "5"
     version_minor: "0"
     version_patch: "0"
     pkg_version: "1"
-    codename: SNAPSHOT
-    download_url: "https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-karaf/0.5.0-SNAPSHOT/distribution-karaf-0.5.0-20160809.145534-4240.tar.gz"
+    codename: Boron
+    download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.0-Boron/distribution-karaf-0.5.0-Boron.tar.gz"
     sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
     java_version: "8"
-    changelog_date: "Tue, 09 Aug 2016"
-    changelog_time: "17:48:42 +0530"
-    changelog_name: "Daniel Farrell"
-    changelog_email: "dfarrell@redhat.com"
+    changelog_date: "Wed, 16 Nov 2016"
+    changelog_time: "01:40:00 +0100"
+    changelog_name: "Michal Skalski"
+    changelog_email: "mskalski@mirantis.com"
+  - version_major: "5"
+    version_minor: "1"
+    version_patch: "0"
+    pkg_version: "1"
+    codename: Boron-SR1
+    download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.1-Boron-SR1/distribution-karaf-0.5.1-Boron-SR1.tar.gz"
+    sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
+    java_version: "8"
+    changelog_date: "Wed, 16 Nov 2016"
+    changelog_time: "01:40:00 +0100"
+    changelog_name: "Michal Skalski"
+    changelog_email: "mskalski@mirantis.com"
diff --git a/rpm/.dockerignore b/rpm/.dockerignore
new file mode 100644 (file)
index 0000000..06cf653
--- /dev/null
@@ -0,0 +1 @@
+cache
diff --git a/rpm/Dockerfile b/rpm/Dockerfile
new file mode 100644 (file)
index 0000000..bef3f64
--- /dev/null
@@ -0,0 +1,14 @@
+FROM centos:centos7
+
+RUN yum -y update && yum -y install epel-release
+RUN yum -y install fedora-packager \
+    python-pip \
+    && yum clean all
+COPY requirements.txt /tmp/requirements.txt
+RUN pip install --upgrade pip && pip install -r /tmp/requirements.txt
+RUN useradd builder
+RUN usermod -a -G mock builder
+RUN mkdir -p /build
+USER builder
+ENTRYPOINT ["/build/build.py"]
+CMD ["-h"]
index e0b6a1eb7884e322c005d992465b48312d8a5f43..4f39b14fe394fdf0bc28013b47d6ea89d8caceb2 100644 (file)
@@ -28,20 +28,42 @@ See the Templates vs Macros section for details about why we use this design.
 
 ## Vagrant Build Environment
 
-All SRPM builds are done in the included Vagrantfile. It provides a
-consistent, known-working and easily shared environment.
+The included Vagrantfile defines a consistent, known-working and easily
+shared environment. It supports both VM and container-based providers.
 
 ```
-[~/packaging/rpm]$ vagrant status
+$ vagrant status
 Current machine states:
 
 default                   not created (virtualbox)
-[~/packaging/rpm]$ vagrant up
-[~/packaging/rpm]$ vagrant ssh
+$ vagrant up
+$ vagrant ssh
 [vagrant@localhost vagrant]$ ls /vagrant/
 build.py  build_vars.yaml  cache  connect.sh  Vagrantfile <snip>
 ```
 
+### Docker provider
+
+The Vagrantfile defines a Docker provider, enabling easy access to build.py
+in a container. The general command format is:
+
+```
+$ vagrant docker-run -- <flags to build.py>
+```
+
+To pass 5.0 (Boron) as the version to build:
+
+```
+$ vagrant docker-run -- -v 5 0
+```
+
+Dockerfile can be also used directly to build container image:
+
+```
+$ docker build -t "odl_rpm" .
+$ docker run -v $(pwd):/build odl_rpm -v 5 0
+```
+
 ## Defining New RPMs
 
 The dynamic aspects of a build, such as ODL and RPM version info, have all
index e212f94d560b3c025317702eb4099b640134269a..cd1a2334e8616bca6ed19177b9c537ce07920b56 100644 (file)
@@ -3,21 +3,27 @@
 
 # Vagrantfile API/syntax version.
 VAGRANTFILE_API_VERSION = "2"
+BOX = "centos/7"
 
 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
-  # RPM build environment is CentOS 7
-  config.vm.box = "centos/7"
-
   # Configure VM RAM and CPU for VirtualBox. Change this to meet your needs.
-  config.vm.provider :virtualbox do |virtualbox|
+  config.vm.provider :virtualbox do |virtualbox, override|
     virtualbox.memory = 2048
     virtualbox.cpus = 2
+    override.vm.box = BOX
   end
 
   # Configure VM RAM and CPU for LibVirt. Change this to meet your needs.
-  config.vm.provider :libvirt do |libvirt|
+  config.vm.provider :libvirt do |libvirt, override|
     libvirt.memory = 2048
     libvirt.cpus = 2
+    override.vm.box = BOX
+  end
+
+  config.vm.provider "docker" do |docker, override|
+    docker.build_dir = "."
+    docker.remains_running = false
+    override.vm.synced_folder ".", "/build"
   end
 
   # NFS is fragile, use rsync
index f52d4dcace4d7585afd3bc5995f43aefcadd1dfe..c6b512a20e3782646aafa55ce4ec32f7bd626467 100644 (file)
@@ -104,3 +104,13 @@ builds:
     changelog_date: "Thu Oct 27 2016"
     changelog_name: "Daniel Farrell"
     changelog_email: "dfarrell@redhat.com"
+  - version_major: "5"
+    version_minor: "1"
+    version_patch: "0"
+    rpm_release: "1"
+    codename: Boron-SR1
+    download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.1-Boron-SR1/distribution-karaf-0.5.1-Boron-SR1.tar.gz"
+    sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
+    changelog_date: "Wed Nov 16 2016"
+    changelog_name: "Michal Skalski"
+    changelog_email: "mskalski@mirantis.com"