diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000000000000000000000000000000000..aaed88f469c3b6138b2943382826be7a3cc8f235
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,16 @@
+dist: trusty
+sudo: required
+services:
+  - docker
+
+branches:
+  only:
+    - master
+
+script:
+  - mntdir='/mnt/ocs-url'
+  - docker run --rm -v $(pwd):${mntdir} ubuntu:14.04 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh ubuntu"
+  - docker run --rm -v $(pwd):${mntdir} fedora:20 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh fedora"
+  - docker run --rm -v $(pwd):${mntdir} base/archlinux:latest /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh archlinux"
+  #- docker run --rm -v $(pwd):${mntdir} ubuntu:16.04 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh snap"
+  #- docker run --rm -v $(pwd):${mntdir} --cap-add SYS_ADMIN --device /dev/fuse ubuntu:14.04 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh appimage"
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
index 61510ab453927e32135f73c4cd3df3205b414087..0ae658a833c72c10fa700c5f5a2cb198610af817 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -4,75 +4,33 @@ pipelines:
       - step:
           image: ubuntu:14.04
           script:
-            - apt update -qq
-            - apt -y install sudo git curl
-            - apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
-            - apt -y install devscripts debhelper fakeroot
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh ubuntu
+            - sh scripts/build-docker.sh ubuntu
   custom:
     build-ubuntu:
       - step:
           image: ubuntu:14.04
           script:
-            - apt update -qq
-            - apt -y install sudo git curl
-            - apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
-            - apt -y install devscripts debhelper fakeroot
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh ubuntu
+            - sh scripts/build-docker.sh ubuntu
     build-fedora:
       - step:
           image: fedora:20
           script:
-            # dnf >= fedora:22
-            - yum -y install sudo git curl
-            - yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
-            - yum -y install rpm-build
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh fedora
+            - sh scripts/build-docker.sh fedora
     build-archlinux:
       - step:
           image: base/archlinux:latest
           script:
-            - pacman -Syu --noconfirm
-            - pacman -S --noconfirm sudo git curl
-            - pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh archlinux
+            - sh scripts/build-docker.sh archlinux
     build-snap:
       - step:
           image: ubuntu:16.04
           script:
-            - apt update -qq
-            - apt -y install sudo git curl
-            - apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
-            - apt -y install snapcraft
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh snap
+            - sh scripts/build-docker.sh snap
     build-appimage:
       - step:
           image: ubuntu:14.04
           script:
-            # Require docker run with --cap-add SYS_ADMIN --device /dev/fuse
+            # Require?: docker run with --cap-add SYS_ADMIN --device /dev/fuse
             - echo 'appimage build is disabled currently'
             - exit 1
-            - apt update -qq
-            - apt -y install sudo git curl
-            - apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
-            - apt -y install fuse zsync desktop-file-utils
-            #- modprobe fuse
-            - useradd -m pkgbuilder
-            - export HOME=/home/pkgbuilder
-            - chown -R pkgbuilder:pkgbuilder $(pwd)
-            - sudo -u pkgbuilder sh scripts/build.sh appimage
+            - sh scripts/build-docker.sh appimage
diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh
new file mode 100644
index 0000000000000000000000000000000000000000..bffee55e87bbeacd10cd7a34ac6039e5094043ce
--- /dev/null
+++ b/scripts/build-docker.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+################################################################################
+# This is wrapper script for build.sh use from inside docker container
+################################################################################
+
+PKGUSER='pkgbuilder'
+
+BUILDTYPE=''
+if [ "${1}" ]; then
+    BUILDTYPE="${1}"
+fi
+
+PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
+
+BUILDSCRIPT="${PROJDIR}/scripts/build.sh"
+
+build_ubuntu() {
+    # docker-image: ubuntu:14.04
+    apt update -qq
+    apt -y install git curl
+    apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
+    apt -y install devscripts debhelper fakeroot
+
+    useradd -m ${PKGUSER}
+    export HOME="/home/${PKGUSER}"
+    chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
+
+    su -c "sh ${BUILDSCRIPT} ${BUILDTYPE}" ${PKGUSER}
+}
+
+build_fedora() {
+    # docker-image: fedora:20
+    yum -y install git curl
+    yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
+    yum -y install rpm-build
+    # docker-image: fedora:22
+    #dnf -y install git curl
+    #dnf -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
+    #dnf -y install rpm-build
+
+    useradd -m ${PKGUSER}
+    export HOME="/home/${PKGUSER}"
+    chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
+
+    su -c "sh ${BUILDSCRIPT} ${BUILDTYPE}" ${PKGUSER}
+}
+
+build_archlinux() {
+    # docker-image: base/archlinux:latest
+    pacman -Syu --noconfirm
+    pacman -S --noconfirm git curl
+    pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
+
+    useradd -m ${PKGUSER}
+    export HOME="/home/${PKGUSER}"
+    chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
+
+    su -c "sh ${BUILDSCRIPT} ${BUILDTYPE}" ${PKGUSER}
+}
+
+build_snap() {
+    # docker-image: ubuntu:16.04
+    apt update -qq
+    apt -y install git curl
+    apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
+    apt -y install snapcraft
+
+    useradd -m ${PKGUSER}
+    export HOME="/home/${PKGUSER}"
+    chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
+
+    su -c "sh ${BUILDSCRIPT} ${BUILDTYPE}" ${PKGUSER}
+}
+
+build_appimage() {
+    # docker-image: ubuntu:14.04
+    apt update -qq
+    apt -y install git curl
+    apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
+    apt -y install fuse zsync desktop-file-utils
+
+    modprobe fuse
+
+    useradd -m ${PKGUSER}
+    export HOME="/home/${PKGUSER}"
+    chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
+
+    su -c "sh ${BUILDSCRIPT} ${BUILDTYPE}" ${PKGUSER}
+}
+
+if [ "${BUILDTYPE}" = 'ubuntu' ]; then
+    build_ubuntu
+elif [ "${BUILDTYPE}" = 'fedora' ]; then
+    build_fedora
+elif [ "${BUILDTYPE}" = 'archlinux' ]; then
+    build_archlinux
+elif [ "${BUILDTYPE}" = 'snap' ]; then
+    build_snap
+elif [ "${BUILDTYPE}" = 'appimage' ]; then
+    build_appimage
+else
+    echo "sh $(basename "${0}") [ubuntu|fedora|archlinux|snap|appimage]"
+    exit 1
+fi
diff --git a/scripts/build.sh b/scripts/build.sh
index 0a8e4346982796247aa974f8274e98c70bbd67b3..f1032877db77c9f63509716d124c93adad32f305 100644
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 ################################################################################
-# This is utility script to make distribution packages
+# This is utility script to build distribution packages
 ################################################################################
 
 PKGNAME='ocs-url'
@@ -19,9 +19,6 @@ BUILDDIR="${PROJDIR}/build_${PKGNAME}_${BUILDVER}_${BUILDTYPE}"
 
 SRCARCHIVE="${BUILDDIR}/${PKGNAME}.tar.gz"
 
-################################################################################
-# Utility functions
-################################################################################
 export_srcarchive() {
     filepath="${1}"
     $(cd "${PROJDIR}" && git archive --prefix="${PKGNAME}/" --output="${filepath}" HEAD)
@@ -36,98 +33,65 @@ transfer_file() {
     fi
 }
 
-################################################################################
-# ubuntu
-################################################################################
-pre_ubuntu() {
+build_ubuntu() {
     cd "${PROJDIR}"
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
-}
 
-build_ubuntu() {
     tar -xzvf "${SRCARCHIVE}" -C "${BUILDDIR}"
     cp -r "${PROJDIR}/pkg/ubuntu/debian" "${BUILDDIR}/${PKGNAME}"
     cd "${BUILDDIR}/${PKGNAME}"
     debuild -uc -us -b
-}
 
-post_ubuntu() {
     transfer_file "$(find ${BUILDDIR} -type f -name "${PKGNAME}*.deb")"
 }
 
-################################################################################
-# fedora
-################################################################################
-pre_fedora() {
+build_fedora() {
     cd "${PROJDIR}"
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
-}
 
-build_fedora() {
     mkdir "${BUILDDIR}/SOURCES"
     mkdir "${BUILDDIR}/SPECS"
     mv "${SRCARCHIVE}" "${BUILDDIR}/SOURCES"
     cp "${PROJDIR}/pkg/fedora/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
     rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
-}
 
-post_fedora() {
     transfer_file "$(find ${BUILDDIR} -type f -name "${PKGNAME}*.rpm")"
 }
 
-################################################################################
-# archlinux
-################################################################################
-pre_archlinux() {
+build_archlinux() {
     cd "${PROJDIR}"
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
-}
 
-build_archlinux() {
     cp "${PROJDIR}/pkg/archlinux/PKGBUILD" "${BUILDDIR}"
     cd "${BUILDDIR}"
     updpkgsums
     makepkg -s
-}
 
-post_archlinux() {
     transfer_file "$(find ${BUILDDIR} -type f -name "${PKGNAME}*.pkg.tar.xz")"
 }
 
-################################################################################
-# snap
-################################################################################
-pre_snap() {
+build_snap() {
     cd "${PROJDIR}"
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
-}
 
-build_snap() {
     tar -xzvf "${SRCARCHIVE}" -C "${BUILDDIR}"
     cp "${PROJDIR}/pkg/snap/snapcraft.yaml" "${BUILDDIR}/${PKGNAME}"
     cp -r "${PROJDIR}/pkg/snap/setup" "${BUILDDIR}/${PKGNAME}"
     cd "${BUILDDIR}/${PKGNAME}"
     snapcraft
-}
 
-post_snap() {
     transfer_file "$(find ${BUILDDIR} -type f -name "${PKGNAME}*.snap")"
 }
 
-################################################################################
-# appimage
-################################################################################
-pre_appimage() {
+build_appimage() {
     cd "${PROJDIR}"
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
-}
 
-build_appimage() {
     tar -xzvf "${SRCARCHIVE}" -C "${BUILDDIR}"
     cd "${BUILDDIR}/${PKGNAME}"
     sh scripts/import.sh
@@ -154,25 +118,20 @@ build_appimage() {
     install -m 755 -p "${BUILDDIR}/${PKGNAME}/pkg/appimage/appimage-desktopintegration_${PKGNAME}" "${BUILDDIR}/${PKGNAME}.AppDir/AppRun"
     ./linuxdeployqt --appimage-extract
     ./squashfs-root/usr/bin/appimagetool "${BUILDDIR}/${PKGNAME}.AppDir"
-}
 
-post_appimage() {
     transfer_file "$(find ${BUILDDIR} -type f -name "${PKGNAME}*.AppImage")"
 }
 
-################################################################################
-# Make package
-################################################################################
 if [ "${BUILDTYPE}" = 'ubuntu' ]; then
-    pre_ubuntu && build_ubuntu && post_ubuntu
+    build_ubuntu
 elif [ "${BUILDTYPE}" = 'fedora' ]; then
-    pre_fedora && build_fedora && post_fedora
+    build_fedora
 elif [ "${BUILDTYPE}" = 'archlinux' ]; then
-    pre_archlinux && build_archlinux && post_archlinux
+    build_archlinux
 elif [ "${BUILDTYPE}" = 'snap' ]; then
-    pre_snap && build_snap && post_snap
+    build_snap
 elif [ "${BUILDTYPE}" = 'appimage' ]; then
-    pre_appimage && build_appimage && post_appimage
+    build_appimage
 else
     echo "sh $(basename "${0}") [ubuntu|fedora|archlinux|snap|appimage]"
     exit 1
diff --git a/scripts/scripts.pri b/scripts/scripts.pri
index d8d91634794aaf353d96a89eb38607348153cd42..a4a1c60eae14a275504996188ce7cff0e6b8853f 100644
--- a/scripts/scripts.pri
+++ b/scripts/scripts.pri
@@ -1,3 +1,4 @@
 DISTFILES += \
+    $${PWD}/build-docker.sh \
     $${PWD}/build.sh \
     $${PWD}/import.sh