Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3861 from robaerd/release-docker-images
Browse files Browse the repository at this point in the history
docker: add release images for distributions packages are generated for
  • Loading branch information
mpranj authored Jun 4, 2021
2 parents 38bd48a + a305f17 commit 64ca082
Show file tree
Hide file tree
Showing 18 changed files with 550 additions and 187 deletions.
2 changes: 1 addition & 1 deletion doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ _(Michael Tucek)_ TODO PLEASE REMOVE LINE ON RELEASE
### Docker

- Add Fedora 34 images. _(Mihael Pranjić)_
- <<TODO>>
- We added release images that come with pre-installed dependencies and sudo permissions for each distribution we build packages for. _(Robert Sowula)_
- <<TODO>>

## Infrastructure
Expand Down
29 changes: 28 additions & 1 deletion scripts/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,39 @@
This folder contains all Docker related artifacts.

A list of all Dockerfiles used by the build server can be found in the
[Jenkinsfile](https://master.libelektra.org/scripts/jenkins/Jenkinsfile).
[Jenkinsfile](https://master.libelektra.org/scripts/jenkins/Jenkinsfile) and
[Jenkinsfile.release](https://master.libelektra.org/scripts/jenkins/Jenkinsfile.release).

> **Note:**
> Any commands in this file are expected to be run from the root
> of the repository.
## Types of Docker images

We generally have three types of docker images:

1. **Testing/Packaging Docker images**
These Docker images are used in our test and package stages of our CI and are able to perform tasks like api documentation or DEB/RPM package generation.
The prefix of the Dockerfile determines for which task a Dockerfile is used.
For example a `doc.Dockerfile` has all dependencies to generate the api documentation.
A dockerfile with the name `Dockerfile` is used for general full builds and optionally also for package generation.
These images do not have any root priviledges.
2. **Images that test the Elektra packages** _(package.Dockerfile)_
Packages are installed during the image build procedure.
These images are only used in the [Jenkinsfile.release](https://master.libelektra.org/scripts/jenkins/Jenkinsfile.release) to run test-suites and archive the results.
These images do not have any root priviledges.
3. **Release images** _(release.Dockerfile)_
Release images install the latest released version of Elektra (from source or packages)
and are pushed to DockerHub and our public Docker registry.
During the build stage, tests are executed on the installed version of Elektra.
These images are never run as container in our CI as they have permissions to use `sudo`.

## Downloading Released Images

We provide Docker images containing an installed version of Elektra with multiple base images.
You can view all available images Docker images on [DockerHub](https://hub.docker.com/r/elektra/elektra).
To start for example a Ubuntu Focal based Elektra container with the Elektra version `0.9.5`, run `docker run -it elektra/elektra:0.9.5-1-focal`

## Downloading Prebuilt Images

You can download prebuilt images for local testing from our build environment.
Expand Down
44 changes: 44 additions & 0 deletions scripts/docker/debian/bullseye/package.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM debian:bullseye

ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y install strace \
&& rm -rf /var/lib/apt/lists/*

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.deb ${ELEKTRA_ROOT}
COPY ./*.ddeb ${ELEKTRA_ROOT}

RUN apt-get update \
&& apt-get -y install ${ELEKTRA_ROOT}/* \
&& rm -rf /var/lib/apt/lists/*

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

USER ${JENKINS_USERID}
44 changes: 19 additions & 25 deletions scripts/docker/debian/bullseye/release.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@ ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y install strace \
&& rm -rf /var/lib/apt/lists/*

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins
ARG USERID=1000
RUN adduser elektra --uid ${USERID} \
&& adduser elektra sudo

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.deb ${ELEKTRA_ROOT}
COPY ./*.ddeb ${ELEKTRA_ROOT}

RUN apt-get update \
&& apt-get -y install \
sudo \
vim \
&& apt-get -y install ${ELEKTRA_ROOT}/* \
&& rm -rf /var/lib/apt/lists/*

RUN rm -rf ${ELEKTRA_ROOT}

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

RUN kdb run_all

RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${USERID}
WORKDIR /home/elektra

USER ${JENKINS_USERID}
CMD ["/bin/bash","-l"]
44 changes: 44 additions & 0 deletions scripts/docker/debian/buster/package.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM debian:buster

ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y install strace \
&& rm -rf /var/lib/apt/lists/*

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.deb ${ELEKTRA_ROOT}
COPY ./*.ddeb ${ELEKTRA_ROOT}

RUN apt-get update \
&& apt-get -y install ${ELEKTRA_ROOT}/* \
&& rm -rf /var/lib/apt/lists/*

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

USER ${JENKINS_USERID}
44 changes: 19 additions & 25 deletions scripts/docker/debian/buster/release.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@ ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y install strace \
&& rm -rf /var/lib/apt/lists/*

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins
ARG USERID=1000
RUN adduser elektra --uid ${USERID} \
&& adduser elektra sudo

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.deb ${ELEKTRA_ROOT}
COPY ./*.ddeb ${ELEKTRA_ROOT}

RUN apt-get update \
&& apt-get -y install \
sudo \
vim \
&& apt-get -y install ${ELEKTRA_ROOT}/* \
&& rm -rf /var/lib/apt/lists/*

RUN rm -rf ${ELEKTRA_ROOT}

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

RUN kdb run_all

RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${USERID}
WORKDIR /home/elektra

USER ${JENKINS_USERID}
CMD ["/bin/bash","-l"]
37 changes: 37 additions & 0 deletions scripts/docker/fedora/33/package.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM fedora:33

RUN dnf upgrade --refresh -y \
&& dnf install -y strace \
&& dnf clean all -y

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.rpm ${ELEKTRA_ROOT}

RUN yum localinstall -y ${ELEKTRA_ROOT}/* \
&& dnf clean all -y

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

USER ${JENKINS_USERID}
40 changes: 19 additions & 21 deletions scripts/docker/fedora/33/release.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
FROM fedora:33

RUN dnf upgrade --refresh -y \
&& dnf install -y strace \
&& dnf install -y \
sudo \
vim \
&& dnf clean all -y

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins
ARG USERID=1000
RUN adduser elektra --uid ${USERID}
RUN usermod -aG wheel elektra

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
Expand All @@ -28,10 +17,19 @@ COPY ./*.rpm ${ELEKTRA_ROOT}
RUN yum localinstall -y ${ELEKTRA_ROOT}/* \
&& dnf clean all -y

RUN rm -rf ${ELEKTRA_ROOT}

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

RUN kdb run_all

RUN echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${USERID}
WORKDIR /home/elektra

USER ${JENKINS_USERID}
CMD ["/bin/bash","-l"]
37 changes: 37 additions & 0 deletions scripts/docker/fedora/34/package.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM fedora:34

RUN dnf upgrade --refresh -y \
&& dnf install -y strace \
&& dnf clean all -y

# Create User:Group
# The id is important as jenkins docker agents use the same id that is running
# on the slaves to execute containers
ARG JENKINS_GROUPID
RUN groupadd \
-g ${JENKINS_GROUPID} \
-f \
jenkins

ARG JENKINS_USERID
RUN useradd \
--create-home \
--uid ${JENKINS_USERID} \
--gid ${JENKINS_GROUPID} \
--shell "/bin/bash" \
jenkins

ENV ELEKTRA_ROOT=/opt/elektra/
RUN mkdir -p ${ELEKTRA_ROOT}
COPY ./*.rpm ${ELEKTRA_ROOT}

RUN yum localinstall -y ${ELEKTRA_ROOT}/* \
&& dnf clean all -y

RUN kdb mount-info \
&& mkdir -p `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` || true \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SPEC .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/KDB_DB_SYSTEM .` \
&& chown -R ${JENKINS_USERID} `kdb sget system:/info/elektra/constants/cmake/BUILTIN_DATA_FOLDER .`

USER ${JENKINS_USERID}
Loading

0 comments on commit 64ca082

Please sign in to comment.