Refactoring the structure of our images master
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 19 Sep 2017 13:33:04 +0000 (15:33 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 19 Sep 2017 13:33:04 +0000 (15:33 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
19 files changed:
src/pakfire/Dockerfile [new file with mode: 0644]
src/pakfire/build.sh [new file with mode: 0755]
src/pakfire/setup-org.sh [moved from src/pbs-web/setup-org.sh with 51% similarity]
src/pbs-base/Dockerfile [new file with mode: 0644]
src/pbs-base/build.sh [new file with mode: 0755]
src/pbs-base/setup-org.sh [new file with mode: 0644]
src/pbs-hub/Dockerfile
src/pbs-hub/build.sh
src/pbs-hub/pbs-hub.service [new file with mode: 0644]
src/pbs-hub/setup-org.sh [deleted file]
src/pbs-manager/Dockerfile
src/pbs-manager/build.sh
src/pbs-manager/pbs-manager.service [new file with mode: 0644]
src/pbs-manager/pbs.conf [deleted file]
src/pbs-manager/setup-org.sh [deleted file]
src/pbs-web/Dockerfile
src/pbs-web/build.sh
src/pbs-web/pbs-web.service [new file with mode: 0644]
src/pbs-web/pbs.conf [deleted file]

diff --git a/src/pakfire/Dockerfile b/src/pakfire/Dockerfile
new file mode 100644 (file)
index 0000000..1216c1e
--- /dev/null
@@ -0,0 +1,13 @@
+FROM centos:latest
+MAINTAINER jonatanschlag
+
+ADD setup.sh /tmp/setup.sh
+RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
+
+
+USER root 
+
+# Define default command.
+CMD ["/bin/bash"]
+
diff --git a/src/pakfire/build.sh b/src/pakfire/build.sh
new file mode 100755 (executable)
index 0000000..3d64f43
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+. /usr/lib/docker-shell-scripts-lib/tag.sh
+. /usr/lib/docker-shell-scripts-lib/get-id.sh
+. /usr/lib/docker-shell-scripts-lib/preparation.sh
+. /usr/lib/docker-shell-scripts-lib/logging.sh
+. /usr/lib/docker-shell-scripts-lib/install.sh
+
+###
+### Build the pakfire Dockerimage
+###
+
+### preparation ###
+# cd into script dir
+(cd $(dirname -- "$(readlink -e -- "$BASH_SOURCE")") || exit
+
+# check for all necessary files
+
+CheckForFile "setup-org.sh"
+CheckForFile "Dockerfile"
+
+#create a work copy of setup.sh
+cp setup-org.sh setup.sh
+### paramter for mariadb build
+repo="ipfire-pakfire"
+dockertag="new"
+username=jonatanschlag
+tag="${username}/${repo}:${dockertag}"
+### Build the docker image
+docker build --no-cache=true -t "$tag" .
+### Tag the docker image
+back=$(tag-image "${username}/${repo}")
+
+if [ "error" = "$back" ]; then
+        echo "Tagging was not successful"
+fi
+rm -f setup.sh
+)
similarity index 51%
rename from src/pbs-web/setup-org.sh
rename to src/pakfire/setup-org.sh
index 3b79545..2c67062 100644 (file)
@@ -17,14 +17,13 @@ log "Update all packages"
 yum update -y
 log "Installing epel"
 yum install -y epel-release
-log "Installing packages for build"
-yum install -y git gcc make intltool autoconf libtool libtool-devel libcap-devel libsolv-devel python-devel xz-devel
-log "Installing dependencies"
-yum install -y python-daemon python-tornado libcap libsolv xz
+build_deps="git gcc make autoconf libtool intltool libcap-devel libsolv-devel python-devel xz-devel"
+deps="libcap libsolv xz python"
 
-# add a user
-groupadd -g 2000 pbs
-useradd --system --no-create-home --shell /bin/bash --uid 2000 --gid 2000 pbs
+log "Installing dependencies"
+yum install -y ${deps}
+log "Installing packages for build"
+yum install -y ${build_deps}
 
 mkdir -p /opt/dev
 log "Building pakfire"
@@ -36,16 +35,8 @@ cd pakfire
 make
 make install
 
-log "Installing the pbs"
-cd /opt/
-git clone -b master  http://git.ipfire.org/pub/git/pbs.git
-cd pbs
-chmod +x pakfire-web
-
 # cleanup
-yum remove -y git gcc make intltool autoconf libtool libtool-devel
+yum remove -y ${build_deps}
 yum autoremove -y
 yum clean all
-rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/dev/*
-
-# set permissions
+rm -rf /var/tmp/* /var/cache/yum/* /opt/dev/*
diff --git a/src/pbs-base/Dockerfile b/src/pbs-base/Dockerfile
new file mode 100644 (file)
index 0000000..14af12e
--- /dev/null
@@ -0,0 +1,13 @@
+FROM jonatanschlag/ipfire-pakfire:latest
+MAINTAINER jonatanschlag
+
+ADD setup.sh /tmp/setup.sh
+RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
+
+
+USER root 
+
+# Define default command.
+CMD ["/bin/bash"]
+
diff --git a/src/pbs-base/build.sh b/src/pbs-base/build.sh
new file mode 100755 (executable)
index 0000000..31db576
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+. /usr/lib/docker-shell-scripts-lib/tag.sh
+. /usr/lib/docker-shell-scripts-lib/get-id.sh
+. /usr/lib/docker-shell-scripts-lib/preparation.sh
+. /usr/lib/docker-shell-scripts-lib/logging.sh
+. /usr/lib/docker-shell-scripts-lib/install.sh
+
+###
+### Build the pakfire Dockerimage
+###
+
+### preparation ###
+# cd into script dir
+(cd $(dirname -- "$(readlink -e -- "$BASH_SOURCE")") || exit
+
+# check for all necessary files
+
+CheckForFile "setup-org.sh"
+CheckForFile "Dockerfile"
+
+#create a work copy of setup.sh
+cp setup-org.sh setup.sh
+### paramter for mariadb build
+repo="ipfire-pbs-base"
+dockertag="new"
+username=jonatanschlag
+tag="${username}/${repo}:${dockertag}"
+### Build the docker image
+docker build --no-cache=true -t "$tag" .
+### Tag the docker image
+back=$(tag-image "${username}/${repo}")
+
+if [ "error" = "$back" ]; then
+        echo "Tagging was not successful"
+fi
+rm -f setup.sh
+)
diff --git a/src/pbs-base/setup-org.sh b/src/pbs-base/setup-org.sh
new file mode 100644 (file)
index 0000000..f34e747
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+#settings
+#
+#="database"
+
+log() {
+       echo "#######################################"
+       echo ""
+       echo "$@"
+       echo ""
+       echo "#######################################"
+}
+
+# build the pbs from master branch
+log "Update all packages"
+yum update -y
+log "Installing epel"
+yum install -y epel-release
+deps="python python-tornado python-daemon"
+
+log "Installing dependencies"
+yum install -y ${deps}
+
+
+# add a user
+groupadd -g 2000 pbs
+useradd --system --no-create-home --shell /bin/bash --uid 2000 --gid 2000 pbs
+
+mkdir -p /opt/pbs
+
+# set permissions
+chown -R pbs:pbs /opt/pbs
+
+# cleanup
+yum autoremove -y
+yum clean all
+rm -rf /var/tmp/* /var/cache/yum/* /opt/dev/*
index 4115459..d301978 100644 (file)
@@ -1,14 +1,11 @@
-FROM centos:latest
+FROM jonatanschlag/ipfire-pbs-base:latest
 MAINTAINER jonatanschlag
 
-ENV DEBIAN_FRONTEND noninteractive
+#ADD setup.sh /tmp/setup.sh
+#RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
 
-ADD setup.sh /tmp/setup.sh
-RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
-
-USER psb 
+USER pbs
 
 # Define default command.
-CMD [""]
+CMD ["/opt/pbs/pakfire-hub"]
 
index b473ceb..505517c 100755 (executable)
@@ -6,7 +6,7 @@
 . /usr/lib/docker-shell-scripts-lib/install.sh
 
 ###
-### Build the pbs Dockerimage
+### Build the pbs-hub Dockerimage
 ###
 
 ### preparation ###
 
 # check for all necessary files
 
-CheckForFile "setup-org.sh"
 CheckForFile "Dockerfile"
 
-#create a work copy of setup.sh
-cp setup-org.sh setup.sh
 ### paramter for mariadb build
-repo="ipfire-pbs"
+repo="ipfire-pbs-hub"
 dockertag="new"
 username=jonatanschlag
 tag="${username}/${repo}:${dockertag}"
@@ -33,5 +30,4 @@ back=$(tag-image "${username}/${repo}")
 if [ "error" = "$back" ]; then
         echo "Tagging was not successful"
 fi
-rm -f setup.sh
 )
diff --git a/src/pbs-hub/pbs-hub.service b/src/pbs-hub/pbs-hub.service
new file mode 100644 (file)
index 0000000..ced31d4
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Pakfire Build Service - Hub
+Requires=docker.service
+After=docker.service
+[Service]
+Environment=GIT_REPO=/root/pbs
+ExecStartPre=-/usr/bin/docker stop pbs-hub
+ExecStartPre=-/usr/bin/docker rm pbs-hub
+ExecStartPre=-/usr/bin/docker pull jonatanschlag/ipfire-pbs-hub:latest
+ExecStart=/usr/bin/docker run -p 80:80 --mount type=bind,source="${GIT_REPO}",target=/opt/pbs --name=pbs-hub jonatanschlag/ipfire-pbs-hub:latest
+ExecStop=/usr/bin/docker stop pbs-hub
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/pbs-hub/setup-org.sh b/src/pbs-hub/setup-org.sh
deleted file mode 100644 (file)
index 5a693b3..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-#settings
-#
-="database"
-
-# build the pbs from master branch
-apt-get update -y && apt-get install -y  gcc make git
-# add a user
-addgroup --gid 2000 pbs 
-adduser --system --no-create-home --shell /bin/bash --uid 2000 --disabled-password --disabled-login --gid 2000 pbs
-
-# build the pot
-mkdir -p /opt/dev
-cd /opt/
-git clone -b master  http://git.ipfire.org/pub/git/pbs.git 
-cd pbs
-# Maybe we have to change the configuration
-#sed -i s/"mysqlpassword"/"$mysql_pass"/g config.h
-#sed -i s/"mysqlhost"/"$mysql_host"/g config.h
-#sed -i s/"authmode"/"$pot_authmode"/g config.h
-#sed -i s/"sleeptime"/"$pot_sleeptime"/g config.h
-
-./configure --prefix=/usr
-make
-make install
-# cleanup
-apt-get remove -y git make gcc
-apt-get autoremove -y 
-apt-get clean
-rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/dev/*
-
-# set permissions
index 4115459..e4c6620 100644 (file)
@@ -1,14 +1,11 @@
-FROM centos:latest
+FROM jonatanschlag/ipfire-pbs-base:latest
 MAINTAINER jonatanschlag
 
-ENV DEBIAN_FRONTEND noninteractive
+#ADD setup.sh /tmp/setup.sh 
+#RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
 
-ADD setup.sh /tmp/setup.sh
-RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
-
-USER psb 
+USER pbs 
 
 # Define default command.
-CMD [""]
+CMD ["/opt/pbs/pakfire-manager"]
 
index b473ceb..11ffd9f 100755 (executable)
@@ -6,7 +6,7 @@
 . /usr/lib/docker-shell-scripts-lib/install.sh
 
 ###
-### Build the pbs Dockerimage
+### Build the pbs-manager Dockerimage
 ###
 
 ### preparation ###
 
 # check for all necessary files
 
-CheckForFile "setup-org.sh"
 CheckForFile "Dockerfile"
 
-#create a work copy of setup.sh
-cp setup-org.sh setup.sh
 ### paramter for mariadb build
-repo="ipfire-pbs"
+repo="ipfire-pbs-manager"
 dockertag="new"
 username=jonatanschlag
 tag="${username}/${repo}:${dockertag}"
@@ -33,5 +30,4 @@ back=$(tag-image "${username}/${repo}")
 if [ "error" = "$back" ]; then
         echo "Tagging was not successful"
 fi
-rm -f setup.sh
 )
diff --git a/src/pbs-manager/pbs-manager.service b/src/pbs-manager/pbs-manager.service
new file mode 100644 (file)
index 0000000..d040d4a
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Pakfire Build Service - Manager
+Requires=docker.service
+After=docker.service
+[Service]
+Environment=GIT_REPO=/root/pbs
+ExecStartPre=-/usr/bin/docker stop pbs-manager
+ExecStartPre=-/usr/bin/docker rm pbs-manager
+ExecStartPre=-/usr/bin/docker pull jonatanschlag/ipfire-pbs-manager:latest
+ExecStart=/usr/bin/docker run -p 80:80 --mount type=bind,source="${GIT_REPO}",target=/opt/pbs --name=pbs-manager jonatanschlag/ipfire-pbs-manager:latest
+ExecStop=/usr/bin/docker stop pbs-manager
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/pbs-manager/pbs.conf b/src/pbs-manager/pbs.conf
deleted file mode 100644 (file)
index 8b477cb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[database]
-; Credentials to the pakfire build service database.
-
-host  = database
-user  = pakfire
-pass  = pakfire
-db    = pakfire
-
-[geoip-database]
-; Credentials to the geoip database.
-
-host  = database
-user  = pakfire
-pass  = pakfire
-db    = geoip
diff --git a/src/pbs-manager/setup-org.sh b/src/pbs-manager/setup-org.sh
deleted file mode 100644 (file)
index 5a693b3..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-#settings
-#
-="database"
-
-# build the pbs from master branch
-apt-get update -y && apt-get install -y  gcc make git
-# add a user
-addgroup --gid 2000 pbs 
-adduser --system --no-create-home --shell /bin/bash --uid 2000 --disabled-password --disabled-login --gid 2000 pbs
-
-# build the pot
-mkdir -p /opt/dev
-cd /opt/
-git clone -b master  http://git.ipfire.org/pub/git/pbs.git 
-cd pbs
-# Maybe we have to change the configuration
-#sed -i s/"mysqlpassword"/"$mysql_pass"/g config.h
-#sed -i s/"mysqlhost"/"$mysql_host"/g config.h
-#sed -i s/"authmode"/"$pot_authmode"/g config.h
-#sed -i s/"sleeptime"/"$pot_sleeptime"/g config.h
-
-./configure --prefix=/usr
-make
-make install
-# cleanup
-apt-get remove -y git make gcc
-apt-get autoremove -y 
-apt-get clean
-rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/dev/*
-
-# set permissions
index 797f3f7..1cd2caa 100644 (file)
@@ -1,11 +1,8 @@
-FROM centos:latest
+FROM jonatanschlag/ipfire-pbs-base:latest
 MAINTAINER jonatanschlag
 
-ADD setup.sh /tmp/setup.sh
-RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
-
-ADD pbs.conf /opt/pbs/pbs.conf
+#ADD setup.sh /tmp/setup.sh 
+#RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
 
 USER pbs 
 
index d0df259..07c0af9 100755 (executable)
 
 # check for all necessary files
 
-CheckForFile "setup-org.sh"
 CheckForFile "Dockerfile"
 
-#create a work copy of setup.sh
-cp setup-org.sh setup.sh
 ### paramter for mariadb build
 repo="ipfire-pbs-web"
 dockertag="new"
@@ -33,5 +30,4 @@ back=$(tag-image "${username}/${repo}")
 if [ "error" = "$back" ]; then
         echo "Tagging was not successful"
 fi
-rm -f setup.sh
 )
diff --git a/src/pbs-web/pbs-web.service b/src/pbs-web/pbs-web.service
new file mode 100644 (file)
index 0000000..8f0dca7
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Pakfire Build Service - Web
+Requires=docker.service
+After=docker.service
+[Service]
+Environment=GIT_REPO=/root/pbs
+ExecStartPre=-/usr/bin/docker stop pbs-web
+ExecStartPre=-/usr/bin/docker rm pbs-web
+ExecStartPre=-/usr/bin/docker pull jonatanschlag/ipfire-pbs-web:latest
+ExecStart=/usr/bin/docker run -p 80:80 --mount type=bind,source="${GIT_REPO}",target=/opt/pbs --name=pbs-web jonatanschlag/ipfire-pbs-web:latest
+ExecStop=/usr/bin/docker stop pbs-web
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/pbs-web/pbs.conf b/src/pbs-web/pbs.conf
deleted file mode 100644 (file)
index 8b477cb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[database]
-; Credentials to the pakfire build service database.
-
-host  = database
-user  = pakfire
-pass  = pakfire
-db    = pakfire
-
-[geoip-database]
-; Credentials to the geoip database.
-
-host  = database
-user  = pakfire
-pass  = pakfire
-db    = geoip