...
 
Commits (28)
stages:
- docker
before_script:
- |
cat << EOF > /kaniko/.docker/config.json
{
"auths": {
"$CI_REGISTRY": {
"username": "gitlab-ci-token",
"password": "$CI_JOB_TOKEN"
}
}
}
EOF
- |
if [ "$CI_COMMIT_BRANCH" = master ]
then
TAG=latest
else
TAG="$(echo $CI_COMMIT_BRANCH | tr '/' '-')"
fi
.build-docker-image:
stage: docker
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- cp stretch-backports.list $image/
- >
/kaniko/executor
--context $CI_PROJECT_DIR/$image
--dockerfile $CI_PROJECT_DIR/$image/Dockerfile
--destination $CI_REGISTRY_IMAGE/$image:$TAG
--single-snapshot
build-docker-obs-api:
extends: .build-docker-image
variables:
image: obs-api
build-docker-obs-server:
extends: .build-docker-image
variables:
image: obs-server
build-docker-worker:
extends: .build-docker-image
variables:
image: worker
all: build
build:
@make -C obs-server
@make -C obs-api
@make -C worker
minbase:
@sudo /usr/share/docker.io/contrib/mkimage.sh -t obs/minbase \
debootstrap --variant=minbase stable
%.list:
cp $(notdir $@) $@
targets = obs-server obs-api worker
build: $(targets:%=build-%)
build-%: %/stretch-backports.list
@make -C $*
== Required packages ==
* debootstrap
* docker-compose
* docker.io
* make
* osc (optional, can be on another machine)
== Build from scratch: ==
1. Minbase image
If you are using Debian based system, a minimal base image can be built
using `docker.io` provided tools with:
1. Debian Stretch Docker Images
The recipes are prepared with the stock docker image for Debian Stretch.
The build process should automatically pull the latest official Debian Stretch
Slim variant of the image.
2. Access Privileges
Access privileges are required for docker operations. On a Debian based system,
the running user for docker should be added to the `docker` system group.
```
$ sudo make minbase
$ sudo adduser $USER docker
```
That command creates `obs/minbase` image, the rest of containers are built
on top of this image.
2. Build images for OBS server and OBS api to run on different containers
3. Build images for OBS server and OBS api to run on different containers
- OBS server container image
- OBS api container image
- OBS worker container image
......@@ -19,20 +29,32 @@
To build that images and launch in multiple containers with compose, execute:
```
$ sudo make
$ make
```
== Run containers ==
1. Run the containers
1. Run the containers (local developer mode)
```
$ docker-compose up
$ docker-compose scale worker=2
```
2. Run the containers (production mode with images from CI Container Registry)
```
$ sudo docker-compose up
$ sudo docker-compose scale obs-worker=2
$ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
$ docker-compose scale worker=2
```
== Access Open Build Service UI ==
1. Open Build Service should be now running, point browser to
`https://localhost/`
For privileged access, use the `Admin` user. Its password is `opensuse`
by default. Change that password immediately.
For unprivileged access, create another user.
== Troubleshooting ==
1. docker compose fails to start
......
---
version: '2'
services:
obs-server:
image: registry.gitlab.collabora.com/obs/docker-obs/obs-server:latest
obs-api:
image: registry.gitlab.collabora.com/obs/docker-obs/obs-api:latest
worker:
image: registry.gitlab.collabora.com/obs/docker-obs/worker:latest
FROM obs/minbase
LABEL maintainer Hector Oron Martinez <hector.oron@collabora.co.uk>
FROM debian:stretch-slim
LABEL maintainer Andrew Lee (李健秋) <andrew.lee@collabora.co.uk>
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
# Use cdn-aws.deb.debian.org
RUN mkdir -p /etc/apt/sources.list.d
COPY stretch-backports.list /etc/apt/sources.list.d/
# Use stretch since it’s not the stable anymore
RUN \
sed -i 's/deb.debian.org/cdn-aws.deb.debian.org/g' /etc/apt/sources.list \
&& echo "deb http://cdn-aws.deb.debian.org/debian stretch-backports main contrib non-free" >> /etc/apt/sources.list \
sed -i 's/stable/stretch/g' /etc/apt/sources.list \
&& echo "obs-api obs-api/dbconfig-install boolean false" | debconf-set-selections \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install obs-api locales supervisor \
&& apt-get clean \
# Configure UTF-7 locale
&& update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
&& locale-gen en_US.UTF-8 \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& apt-get -y install obs-api locales supervisor \
# purge and re-create /var/lib/mysql with appropriate ownership
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \
&& chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
&& chmod 777 /var/run/mysqld \
&& rm -rf /var/lib/apt/lists/*
&& chmod 777 /var/run/mysqld
VOLUME /var/lib/mysql
......
#!/usr/bin/env sh
#!/bin/sh
# Make sure there are no stale files from previous runs
rm -rfv /run/*
mkdir -m a=rwxt /run/lock
if [ -z "$DB_HOST" -o -z "$DB_ROOT_PASSWORD" -o -z "$DB_NAME" -o -z "$DB_USER" -o -z "$DB_PASSWORD" -o -z "$OBS_BACKEND_HOST" ]; then
echo >&2 'error: database is uninitialized and password option is not specified or OBS'
......@@ -10,7 +14,7 @@ fi
# Generate ssl-cert
make-ssl-cert generate-default-snakeoil --force-overwrite
# Place api and repo url on index page
FQHOSTNAME=`hostname -f`
FQHOSTNAME=`hostname`
sed -e "s,___API_URL___,https://$FQHOSTNAME,g" \
-e "s,___REPO_URL___,http://$FQHOSTNAME:82,g" \
/usr/share/obs/overview/overview.html.TEMPLATE > \
......
FROM obs/minbase
LABEL maintainer Hector Oron Martinez <hector.oron@collabora.co.uk>
FROM debian:stretch-slim
LABEL maintainer Andrew Lee (李健秋) <andrew.lee@collabora.co.uk>
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
# Use cdn-aws.deb.debian.org and enable backports repo.
RUN sed -i 's/deb.debian.org/cdn-aws.deb.debian.org/g' /etc/apt/sources.list \
&& echo "deb http://cdn-aws.deb.debian.org/debian stretch-backports main contrib non-free" >> /etc/apt/sources.list \
RUN mkdir -p /etc/apt/sources.list.d
COPY stretch-backports.list /etc/apt/sources.list.d/
# Use stretch since it’s not the stable anymore
RUN sed -i 's/stable/stretch/g' /etc/apt/sources.list \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y supervisor \
obs-server locales \
&& apt-get clean \
&& update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
&& locale-gen en_US.UTF-8 \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& rm -rf /var/lib/apt/lists/*
&& apt-get install -y supervisor \
obs-server locales
VOLUME /srv/obs
......
#!/usr/bin/env sh
#!/bin/sh
if [ -z "$OBS_FRONTEND_HOST" ]; then
echo >&2 'error: OBS server frontend is unavailable and hostname option'
......@@ -7,7 +7,12 @@ if [ -z "$OBS_FRONTEND_HOST" ]; then
exit 1
fi
HOSTNAME=$(hostname)
echo "Configure OBS backend host: ${HOSTNAME}"
sed -i "s/hostname = .*/hostname = '${HOSTNAME}';/g" /etc/obs/BSConfig.pm
echo "Configure OBS frontend host: ${OBS_FRONTEND_HOST}"
sed -i s/"frontend = undef"/"frontend = '${OBS_FRONTEND_HOST}'"/g /etc/obs/BSConfig.pm
sed -i "s/frontend = undef/frontend = '${OBS_FRONTEND_HOST}'/g" /etc/obs/BSConfig.pm
/usr/bin/supervisord -n
......@@ -4,7 +4,8 @@ The test images are based on docker-obs's minbase, obs/obs-api,
obs/obs-server and obs/worker images. If you haven't create them,
you will probably a `pull access denied` for these images.
Please follow the README.md under docker-obs project root dir to
create these images first.
create these images first. You can stop before running
`sudo docker-compose up`.
To build the test images and launch in multiple containers with compose,
execute following commands under `docker-obs/obs-tests` directory:
......@@ -44,6 +45,11 @@ eg:
1. Open Build Service should be now running, point browser to
`https://localhost/`
For privileged access, use the `Admin` user. Its password is `opensuse`
by default.
For unprivileged access, create another user.
== Access to the shell of the containers ==
The worker container:
......@@ -62,8 +68,11 @@ OBS logs are localted under /var/log/obs/ inside the containers.
== test_dod_1.sh ==
The test_dod_1.sh is designed to test DoD stup and build a hello package
from debian.
`test_dod_1.sh` is designed to test download-on-demand setup by building
the `hello` package from Debian.
Before running it, make sure you have a `deb-src` line in your
`/etc/apt/sources.list`, and have run `apt-get update`.
You may test it by add following line into your /etc/hosts
```
......@@ -73,6 +82,9 @@ and then run
```
test_dod_1.sh obs-api
```
Use the `Admin` user. Its password is `opensuse` by default.
The script will setup debian projects and DoD automaticlly and submit
`hello` package build. You may check the webUI again once you ran the
script.
......
......@@ -8,4 +8,10 @@
<arch>armv7hl</arch>
<arch>aarch64</arch>
</repository>
<repository name="Debian_9.0">
<path project="Debian:9" repository="main"/>
<arch>x86_64</arch>
<arch>armv7hl</arch>
<arch>aarch64</arch>
</repository>
</project>
......@@ -10,15 +10,15 @@ Preinstall: perl
# preinstall essentials + dependencies
Preinstall: base-files base-passwd bash bsdutils coreutils dash debconf
Preinstall: debianutils diffutils dpkg e2fslibs e2fsprogs findutils gawk
Preinstall: gcc-4.9-base grep gzip hostname initscripts insserv libacl1
Preinstall: libattr1 libblkid1 libbz2-1.0 libc-bin libc6 libcomerr2 libdb5.3
Preinstall: libgcc1 liblzma5 libmount1 libncurses5 libpam-modules
Preinstall: libpcre3 libsmartcols1
Preinstall: libpam-modules-bin libpam-runtime libpam0g libreadline6
Preinstall: gcc-6-base grep gzip hostname initscripts init-system-helpers
Preinstall: insserv libacl1 libattr1 libblkid1 libbz2-1.0 libc-bin libc6
Preinstall: libcomerr2 libdb5.3 libgcc1 liblzma5 libmount1 libncurses5
Preinstall: libpam-modules libpcre3 libsmartcols1
Preinstall: libpam-modules-bin libpam-runtime libpam0g libreadline7
Preinstall: libselinux1 libsemanage-common libsemanage1 libsepol1 libsigsegv2
Preinstall: libslang2 libss2 libtinfo5 libustr-1.0-1 libuuid1 login lsb-base
Preinstall: mount multiarch-support ncurses-base ncurses-bin passwd perl-base
Preinstall: readline-common sed sensible-utils sysv-rc sysvinit sysvinit-utils
Preinstall: readline-common sed sensible-utils sysv-rc sysvinit-utils
Preinstall: tar tzdata util-linux zlib1g
Runscripts: base-passwd user-setup base-files gawk
......@@ -30,7 +30,7 @@ Order: user-setup:base-files
# Essential packages (this should also pull the dependencies)
Support: base-files base-passwd bash bsdutils coreutils dash debianutils
Support: diffutils dpkg e2fsprogs findutils grep gzip hostname libc-bin
Support: login mount ncurses-base ncurses-bin perl-base sed sysvinit
Support: login mount ncurses-base ncurses-bin perl-base sed
Support: sysvinit-utils tar util-linux
# Build-essentials
......
......@@ -3,12 +3,28 @@
The folder contains sid images for tests. These are a sid/minbase,
sid/obs-api, sid/obs-server and sid/worker images.
Required packages:
* debootstrap
* docker-compose
* docker.io
* make
* osc (optional, can be on another machine)
* sudo
You'll need a sid/minbase container, which you can generate with:
```
$ sudo make minbase
```
To build the test images and launch in multiple containers with compose,
execute following commands under `docker-obs/obs-tests/sid` directory:
```
$ sudo make
```
== Run containers ==
1. Run the containers
......@@ -41,6 +57,11 @@ eg:
1. Open Build Service should be now running, point browser to
`https://localhost/`
For privileged access, use the `Admin` user. Its password is `opensuse`
by default.
For unprivileged access, create another user.
== Access to the shell of the containers ==
The worker container:
......@@ -59,8 +80,11 @@ OBS logs are localted under /var/log/obs/ inside the containers.
== test_dod_1.sh ==
The test_dod_1.sh is designed to test DoD stup and build a hello package
from debian.
`test_dod_1.sh` (in the `obs-tests` directory) is designed to test
download-on-demand setup by building the `hello` package from Debian.
Before running it, make sure you have a `deb-src` line in your
`/etc/apt/sources.list`, and have run `apt-get update`.
You may test it by add following line into your /etc/hosts
```
......@@ -68,12 +92,14 @@ You may test it by add following line into your /etc/hosts
```
and then run
```
test_dod_1.sh obs-api
./test_dod_1.sh obs-api
```
The script will setup debian projects and DoD automaticlly and submit
`hello` package build. You may check the webUI again once you ran the
script.
Use the `Admin` user. Its password is `opensuse` by default.
== Stop the containers ==
Press Ctrl-C in the console that runs the containers.
......
---
version: '2'
version: '2.1'
networks:
obs:
......@@ -11,6 +11,8 @@ services:
obs-server:
image: sid/obs-server
hostname: obs-server
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
restart: unless-stopped
environment:
OBS_FRONTEND_HOST: obs-api
......@@ -25,6 +27,8 @@ services:
- obs-server
image: sid/obs-api
hostname: obs-api
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
volumes:
- /srv/docker/obs-api/mysql:/var/lib/mysql
- /tmp/binaries:/tmp/binaries
......@@ -48,6 +52,8 @@ services:
- obs-server
image: sid/worker
hostname: worker
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
volumes:
- /tmp/binaries:/tmp/binaries
restart: unless-stopped
......
......@@ -64,12 +64,12 @@ echo "obs-api obs-api/db/dbname string ${DB_NAME}" | debconf-set-selections
# MySQL username for obs-api:
echo "obs-api obs-api/db/app-user string ${DB_USER}@${DB_NAME}" | debconf-set-selections
echo "mariadb-server-10.1 mysql-server/root_password password ${DB_ROOT_PASSWORD}" | debconf-set-selections
echo "mariadb-server-10.1 mysql-server/root_password_again password ${DB_ROOT_PASSWORD}" | debconf-set-selections
echo "mariadb-server-10.3 mysql-server/root_password password ${DB_ROOT_PASSWORD}" | debconf-set-selections
echo "mariadb-server-10.3 mysql-server/root_password_again password ${DB_ROOT_PASSWORD}" | debconf-set-selections
echo "Starting database server."
if [ ! -d "/var/lib/mysql/mysql" ]; then
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure mariadb-server-10.1
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure mariadb-server-10.3
service mysql start
# Run dpkg-reconfigure twice to make sure it reconfigured correctly.
echo "Configuring database ${DB_NAME} for ${DB_USER}@${DB_NAME}."
......
#!/bin/bash
set -e
set -u
OPTIONS="-o DPkg::Options::=--force-confdef -y --no-install-recommends --allow-downgrades"
BINPATH="/tmp/binaries"
......
#!/bin/bash
set -e
set -u
OPTIONS="-o DPkg::Options::=--force-confdef -y --no-install-recommends --allow-downgrades"
BINPATH="/tmp/binaries"
......
deb http://deb.debian.org/debian stretch-backports main
FROM obs/minbase
LABEL maintainer Hector Oron Martinez <hector.oron@collabora.co.uk>
FROM debian:stretch-slim
LABEL maintainer Andrew Lee (李健秋) <andrew.lee@collabora.co.uk>
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
# Use cdn-aws.deb.debian.org and enable backports repo.
RUN sed -i 's/deb.debian.org/cdn-aws.deb.debian.org/g' /etc/apt/sources.list \
&& echo "deb http://cdn-aws.deb.debian.org/debian stretch-backports main contrib non-free" >> /etc/apt/sources.list \
RUN mkdir -p /etc/apt/sources.list.d
COPY stretch-backports.list /etc/apt/sources.list.d/
# Use stretch since it’s not the stable anymore
RUN sed -i 's/stable/stretch/g' /etc/apt/sources.list \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y supervisor \
&& apt-get install -y supervisor \
obs-worker locales \
&& apt-get clean \
&& update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
&& locale-gen en_US.UTF-8 \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/obsworker \
&& rm -rf /var/lib/apt/lists/*
&& sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/obsworker
VOLUME /srv/obs
......
#!/usr/bin/env sh
#!/bin/sh
if [ -z "$OBS_SRC_SERVER" -o -z "$OBS_REPO_SERVERS" ]; then
echo >&2 'error: OBS source server or repository server are unavailable'
......