Skip to content

Commit a0f5a03

Browse files
committed
Inception of the docker image dedicated to dev
0 parents  commit a0f5a03

File tree

8 files changed

+287
-0
lines changed

8 files changed

+287
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
src/repository/*

Dockerfile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#
2+
# This Dockerfile is for creating an image to bootstrap a container within which one or more
3+
# Silverpeas projects in developement can be built. It is expected the source code is shared
4+
# between the host (in which the IDE is running) and the container (in which the build is performed).
5+
#
6+
# By using such a container, we ensure the build is reproductible and doesn't depend on the
7+
# environment context specific to the developer's host.
8+
#
9+
FROM ubuntu:bionic
10+
11+
LABEL name="Silverpeas Build" description="An image to build a Silverpeas project" vendor="Silverpeas" version=1
12+
MAINTAINER Miguel Moquillon "miguel.moquillon@silverpeas.org"
13+
14+
ENV TERM=xterm
15+
16+
# Parameters whose values are required for the tests to succeed
17+
ARG DEFAULT_LOCALE=fr_FR.UTF-8
18+
ARG MAVEN_VERSION=3.6.1
19+
ARG MAVEN_SHA=b4880fb7a3d81edd190a029440cdf17f308621af68475a4fe976296e71ff4a4b546dd6d8a58aaafba334d309cc11e638c52808a4b0e818fc0fd544226d952544
20+
ARG WILDFLY_VERSION=15.0.1
21+
ARG JAVA_VERSION=8
22+
23+
# Because the source code is shared between the host and the container, it is required the identifier
24+
# of the owner is the same between this two environments. By default, it is set at 1000.
25+
ARG USER_ID=1000
26+
27+
COPY src/maven-deps.zip /tmp/
28+
29+
RUN apt-get update && apt-get install -y \
30+
vim \
31+
curl \
32+
git \
33+
openssh-client \
34+
gnupg \
35+
locales \
36+
procps \
37+
net-tools \
38+
zip \
39+
unzip \
40+
openjdk-${JAVA_VERSION}-jdk \
41+
ffmpeg \
42+
imagemagick \
43+
ghostscript \
44+
libreoffice-writer \
45+
libreoffice-calc \
46+
libreoffice-impress \
47+
gpgv \
48+
&& rm -rf /var/lib/apt/lists/* \
49+
&& update-ca-certificates -f \
50+
&& useradd -g users -u ${USER_ID} -d /home/silveruser -ms /bin/bash silveruser \
51+
&& mkdir -p /usr/share/maven /usr/share/maven/ref \
52+
&& curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
53+
&& echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
54+
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
55+
&& rm -f /tmp/apache-maven.tar.gz \
56+
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn \
57+
&& unzip /tmp/maven-deps.zip -d /home/silveruser/ \
58+
&& chown -R silveruser:users /home/silveruser/.m2 \
59+
&& curl -fsSL -o /tmp/swftools-bin-0.9.2.zip https://www.silverpeas.org/files/swftools-bin-0.9.2.zip \
60+
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 *swftools-bin-0.9.2.zip' | sha256sum - \
61+
&& unzip /tmp/swftools-bin-0.9.2.zip -d / \
62+
&& curl -fsSL -o /tmp/pdf2json-bin-0.68.zip https://www.silverpeas.org/files/pdf2json-bin-0.68.zip \
63+
&& echo 'eec849cdd75224f9d44c0999ed1fbe8764a773d8ab0cf7fff4bf922ab81c9f84 *pdf2json-bin-0.68.zip' | sha256sum - \
64+
&& unzip /tmp/pdf2json-bin-0.68.zip -d / \
65+
&& curl -fsSL -o /tmp/wildfly-${WILDFLY_VERSION}.Final.FOR-TESTS.zip https://www.silverpeas.org/files/wildfly-${WILDFLY_VERSION}.Final.FOR-TESTS.zip \
66+
&& mkdir /opt/wildfly-for-tests \
67+
&& unzip /tmp/wildfly-${WILDFLY_VERSION}.Final.FOR-TESTS.zip -d /opt/wildfly-for-tests/ \
68+
&& chown -R silveruser:users /opt/wildfly-for-tests/ \
69+
&& sed -i 's/\/home\/miguel\/tmp/\/opt\/wildfly-for-tests/g' /opt/wildfly-for-tests/wildfly-15.0.1.Final/standalone/configuration/standalone-full.xml \
70+
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
71+
&& echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen \
72+
&& echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen \
73+
&& locale-gen \
74+
&& update-locale LANG=${DEFAULT_LOCALE} LANGUAGE=${DEFAULT_LOCALE} LC_ALL=${DEFAULT_LOCALE}
75+
76+
COPY src/inputrc /home/silveruser/.inputrc
77+
COPY src/settings.xml /home/silveruser/.m2/
78+
79+
ENV LANG ${DEFAULT_LOCALE}
80+
ENV LANGUAGE ${DEFAULT_LOCALE}
81+
ENV LC_ALL ${DEFAULT_LOCALE}
82+
ENV MAVEN_HOME /usr/share/maven
83+
84+
# By default, the build will be done in the default user's home directory
85+
USER silveruser
86+
WORKDIR /home/silveruser
87+
88+
# The GPG and SSL keys to use for respectively signing and then deploying the built artifact to
89+
# our Nexus server have to to be provided by an outside directory; therefore the below definition
90+
# of volumes.
91+
# WARNING: You have to link also two files in order to be able to deploy the build results and to
92+
# push commits:
93+
# - /home/silveruser/.m2/settings.xml and /home/silveruser/.m2/settings-security.xml files with your
94+
# own in order to sign and to deploy the artifact with Maven. In these files the GPG key, the SSL
95+
# passphrase as well as the remote servers must be defined.
96+
# - /home/silveruser/.m2/.gitconfig file with your own in order to be able to push any commits.
97+
VOLUME ["/home/silveruser/.ssh", "/home/silveruser/.gnupg"]

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# docker-silverpeas-dev
2+
3+
A `Dockerfile` that produces a Docker image to build a [Silverpeas 6](http://www.silverpeas.org)
4+
project.
5+
6+
Such an image is dedicated to the developers that wish to have an environment ready to build
7+
(compile and test) a Silverpeas project and this in a reproducible way, without having to be worried
8+
about specific tools to install or specific settings required for the tests to run correctly.
9+
10+
## Image creation
11+
12+
To create an image, just do:
13+
14+
$ ./build.sh
15+
16+
this will build an image to work on the latest version of Silverpeas as defined in the `Dockerfile`
17+
with the tag `silverpeas/sivlerdev:latest`.
18+
19+
Otherwise, to create an image to build a given version of Silverpeas 6, you have to specify as argument
20+
both the version of Silverpeas followed by the exact version of Wildfly used by this version:
21+
22+
$ ./build.sh -v 6.0 10.1.0
23+
24+
This will build a Docker image with the tag `silverpeas/silverdev:6.0`. It is to work on a
25+
Silverpeas 6.0 project and with Wildfly 10.1.0. Here, the version of Silverpeas passed as argument
26+
isn't in fact important; it just a convention stipulating that a tag of an image is the version
27+
of the Silverpeas projects for which it was created. By doing so, it will be easy for the developer
28+
to switch between different containers, each of them prepared for a different version of Silverpeas.
29+
But the version of Wildfly passed as argument is important because a Wildfly distribution preconfigured
30+
for the integration tests will be downloaded and in general, for each version of Silverpeas
31+
(stable or in-development version) matches a given version of Wildfly.
32+
33+
The image is created to start a container with a default user (`silveruser`). 1000 is his identifier
34+
and `users` (group identifier 100) is its main group.
35+
In order to avoid permissions problems with the source code that is shared between the host and the
36+
container, it is required that the identifier of your account in your host is the same that the
37+
identifier of the default user in the container. In the case your user identifier isn't 1000, then you have to
38+
create an image by specifying the identifier in the command line as following (here, in our example,
39+
the user identifier is 1026):
40+
41+
$ ./build.sh -u 1026
42+
43+
or
44+
45+
$ ./build.sh -v 6.0 10.1.0 -u 1026
46+
47+
for creating a Docker image for Silverpeas 6.0 projects and with Wildfly 10.1.0.
48+
49+
## Container running
50+
51+
To run a container `silverdev` from the lastest version of the image, just do:
52+
53+
$ ./run.sh "$HOME"/Projects
54+
55+
or for a given version, say 6.0:
56+
57+
$ ./run.sh "$HOME"/Projects 6.0
58+
59+
where the first parameter is the path of the directory that will contain (or that already contains)
60+
the source code of some Silverpeas projects. This directory will be shared between your host the
61+
the container. The script bootstraps a container with the following name `silverdev-latest` for the
62+
former and `silverdev-6.0` for the latter.
63+
64+
The script will link the following directories and files in your home `.ssh`, `.gnupg`,
65+
`.m2/settings.xml`, `.m2/settings-security.xml` and `.gitconfig` to those of the default user in the
66+
container. By doing so, any build performed within the container will be able to fetch dependencies,
67+
to sign the source code, to deploy the software artifacts into a Nexus server and to commit and
68+
push into a Git remote repository.
69+
70+
If you requirement is just to build a Silverpeas project (id est compiling and testing), then
71+
you don't have to link these directories and files. You can then run a container as
72+
following:
73+
74+
$ docker run -it \
75+
-v "$HOME"/Projects:/home/silveruser/Projects \
76+
silverpeas/silverdev /bin/bash
77+
78+
If your requirement is also to commit and push into a remote Git repository, then link your
79+
`.gitconfig` file as following:
80+
81+
$ docker run -it \
82+
-v "$HOME"/Projects:/home/silveruser/Projects \
83+
-v "$HOME"/.gitconfig:/home/silveruser/.gitconfig \
84+
silverpeas/silverdev /bin/bash
85+
86+

build.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
function die() {
4+
echo "Error: $1"
5+
exit 1
6+
}
7+
8+
function checkNotEmpty() {
9+
test "Z$1" != "Z" || die "Parameter is empty"
10+
}
11+
12+
version=0
13+
while [[ $# -gt 0 ]]; do
14+
key="$1"
15+
case $key in
16+
-u)
17+
user="--build-arg USER_ID=$2"
18+
shift # past argument
19+
shift # past value
20+
;;
21+
-v)
22+
silverpeas_version="$2"
23+
wildfly_version="$3"
24+
checkNotEmpty ${silverpeas_version}
25+
checkNotEmpty ${wildfly_version}
26+
version=1
27+
shift # past argument
28+
shift # past first value
29+
shift # past second value
30+
;;
31+
*)
32+
die "Unknown option: $1"
33+
;;
34+
esac
35+
done
36+
37+
38+
# build the Docker image for building some of the Silverpeas projects
39+
if [[ ${version} -eq 1 ]]; then
40+
docker build ${user} \
41+
--build-arg WILDFLY_VERSION=${wildfly_version} \
42+
-t silverpeas/silverdev:${silverpeas_version} \
43+
.
44+
else
45+
docker build ${user} \
46+
-t silverpeas/silverdev:latest \
47+
.
48+
fi
49+

run.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
function die() {
4+
echo "Error: $1"
5+
exit 1
6+
}
7+
8+
if [[ $# -eq 1 ]]; then
9+
image_version=$1
10+
else
11+
image_version=latest
12+
fi
13+
14+
# run the silverpeas build image by linking the required volumes for signing and deploying built artifacts.
15+
docker run -it -v "$HOME"/.m2/settings.xml:/home/silveruser/.m2/settings.xml \
16+
-v "$HOME"/.m2/settings-security.xml:/home/silveruser/.m2/settings-security.xml \
17+
-v "$HOME"/.gitconfig:/home/silveruser/.gitconfig \
18+
-v "$HOME"/.ssh:/home/silveruser/.ssh \
19+
-v "$HOME"/.gnupg:/home/silveruser/.gnupg \
20+
--name silverdev-${image_version} \
21+
silverpeas/silverdev:${image_version} /bin/bash

src/inputrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"\e[A": history-search-backward
2+
"\e[B": history-search-forward
3+
"\e[C": forward-char
4+
"\e[D": backward-char

src/maven-deps.zip

4.26 MB
Binary file not shown.

src/settings.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
5+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
<mirrors>
7+
<mirror>
8+
<id>Silverpeas Nexus</id>
9+
<name>Silverpeas Nexus Public Mirror</name>
10+
<url>https://www.silverpeas.org/nexus/content/groups/silverpeas</url>
11+
<mirrorOf>*</mirrorOf>
12+
</mirror>
13+
</mirrors>
14+
15+
<profiles>
16+
<profile>
17+
<id>required-props</id>
18+
<properties>
19+
<temp.directory>/opt/wildfly-for-tests</temp.directory>
20+
</properties>
21+
</profile>
22+
</profiles>
23+
24+
<activeProfiles>
25+
<activeProfile>required-props</activeProfile>
26+
</activeProfiles>
27+
</settings>
28+

0 commit comments

Comments
 (0)