Skip to content

Commit ba66edd

Browse files
committed
In some circumstances, the IDE (for example IntelliJ Idea) can fail when
opening an existing project. In order to fix this, the container has to be run in a privileged mode. Since Ubuntu 22.04, Firefox isn't anymore available as a native package but as a snap one. In order to avoid to use snap within a Docker container, a PPA repository providing Firefox is added. Improve a little bit the scripts build.sh and run.sh. It is now possible to give a custome name to the Docker image instead of silverpeas/silverdev.
1 parent 27432e4 commit ba66edd

File tree

4 files changed

+125
-56
lines changed

4 files changed

+125
-56
lines changed

Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@
99
# <Silverpeas major version>.<Silverpeas minor version>.<Docker image patch version>
1010
# For instance, a Docker image with version 6.2.1 means it defines a development and build
1111
# environment for a projet based upon Silverpeas 6.2 and it is the first corrective version of such
12-
# a Docker image.
13-
#
12+
# a Docker image. The Silverpeas 6.2 can to be not yet released; in such a case, it means the Docker image is to
13+
# work on the next version of Silverpeas and, once this version is released it is to work on the patch versions of
14+
# this version of Silverpeas.
1415
# By using such a container, we ensure the build is reproductible and doesn't depend on the
1516
# environment context specific to the developer's host. Only the .m2 repository and some settings
1617
# like .m2/settings.xml, .gitconfig, .gnupg and .ssh of the current user in the host are shared with
1718
# the container in order to be able to interact with his remote services.
1819
#
1920
FROM ubuntu:jammy
2021

21-
LABEL name="Silverpeas Dev" description="A Docker image to dev and to build a Silverpeas project" vendor="Silverpeas" version="6.4-SNAPSHOT" build=1
22+
LABEL name="Silverpeas Dev" description="A Docker image to dev and to build a Silverpeas project" vendor="Silverpeas" version="6.4" build=1
2223
MAINTAINER Miguel Moquillon "miguel.moquillon@silverpeas.org"
2324

2425
ENV TERM=xterm
2526
ENV TZ=Europe/Paris
2627
ENV DEBIAN_FRONTEND=noninteractive
2728

28-
# Parameters whose values are required for the tests to succeed
29+
# Parameters whose values are required yfor the tests to succeed
2930
ARG DEFAULT_LOCALE=fr_FR.UTF-8
30-
ARG MAVEN_VERSION=3.8.6
31-
ARG MAVEN_SHA=f790857f3b1f90ae8d16281f902c689e4f136ebe584aba45e4b1fa66c80cba826d3e0e52fdd04ed44b4c66f6d3fe3584a057c26dfcac544a60b301e6d0f91c26
32-
ARG WILDFLY_VERSION=26.1.2
31+
ARG MAVEN_VERSION=3.8.8
32+
ARG MAVEN_SHA=332088670d14fa9ff346e6858ca0acca304666596fec86eea89253bd496d3c90deae2be5091be199f48e09d46cec817c6419d5161fb4ee37871503f472765d00
33+
ARG WILDFLY_VERSION=26.1.3
3334
ARG JAVA_VERSION=11
3435
ARG GROOVY_VERSION=4.0.6
3536
ARG GROOVY_SHA=e3b541567e65787279f02031206589bcdf3cdaab9328d9e4d72ad23a86aa1053
@@ -42,8 +43,12 @@ ARG USER_ID=1000
4243
ARG GROUP_ID=1000
4344

4445
COPY src/maven-deps.zip /tmp/
46+
COPY src/mozilla-firefox /etc/apt/preferences.d/
4547

4648
RUN apt-get update \
49+
&& apt-get install -y software-properties-common \
50+
&& add-apt-repository -y ppa:mozillateam/ppa \
51+
&& apt-get update \
4752
&& apt-get install -y tzdata \
4853
&& apt-get install -y \
4954
apt-utils \

build.sh

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,56 @@ function checkNotEmpty() {
99
test "Z$1" != "Z" || die "Parameter is empty"
1010
}
1111

12+
name="silverpeas/silverdev"
1213
version=$(grep -oP '(?<=version=")[0-9]+.[0-9]+(.[0-9]+)?' Dockerfile)
1314
while [[ $# -gt 0 ]]; do
1415
key="$1"
1516
case $key in
16-
-h)
17-
echo "Usage: build.sh [-u USER_ID] [-g GROUP_ID] [-w WILDFLY_VERSION] [-j JAVA_VERSION] [-v IMAGE_VERSION]"
18-
echo "Build a Docker image from which a Docker container could be spawned to code and build"
19-
echo "within a compartmentalized environment some Silverpeas projects that can be shared "
20-
echo "between the container and the host."
21-
echo "with:"
22-
echo " -u USER_ID set the user identifier as USER_ID (it is recommended the USER_ID is"
23-
echo " your own user identifier in the host if the code source is shared"
24-
echo " between a Docker container and the host. By default 1000."
25-
echo " -g GROUP_ID set the group identifier as GROUP_ID (it is recommended the GROUP_ID is"
26-
echo " your own group identifier in the host if the code source is shared"
27-
echo " between a Docker container and the host. By default 1000."
28-
echo " -w WILDFLY_VERSION"
29-
echo " set the version of the Widfly distribution to use in the integration"
30-
echo " tests. By default, the latest supported version of Wildfly."
31-
echo " -j JAVA_VERSION"
32-
echo " set the version of the JDK to use for building, testing and running Silverpeas"
33-
echo " -v IMAGE_VERSION"
34-
echo " the version of the Docker image to build. Should be equal to the"
35-
echo " version of Silverpeas for which the Docker image is."
17+
-h|--help)
18+
w=`grep "ARG WILDFLY_VERSION" Dockerfile | cut -d '=' -f 2 | xargs`
19+
j=`grep "ARG JAVA_VERSION" Dockerfile | cut -d '=' -f 2 | xargs`
20+
u=`grep "ARG USER_ID" Dockerfile | cut -d '=' -f 2 | xargs`
21+
g=`grep "ARG GROUP_ID" Dockerfile | cut -d '=' -f 2 | xargs`
22+
echo """Usage: build.sh [-u USER_ID]
23+
[-g GROUP_ID]
24+
[-w WILDFLY_VERSION]
25+
[-j JAVA_VERSION]
26+
[-v IMAGE_VERSION]
27+
[-n IMAGE_NAME]
28+
29+
Build a Docker image from which a Docker container could be spawned to code and
30+
build within a compartmentalized environment some Silverpeas projects that can
31+
be shared between the container and the host.
32+
33+
With:
34+
-u USER_ID
35+
set the user identifier as USER_ID. The USER_ID should be your
36+
own user identifier on the host in the case some resources have
37+
to be shared between the Docker container and the host.
38+
By default $u.
39+
-g GROUP_ID
40+
set the group identifier as GROUP_ID. The GROUP_ID should be
41+
your own group identifier on the host in the case some
42+
resources have to be shared between the Docker container and
43+
the host.
44+
By default $g.
45+
-w WILDFLY_VERSION
46+
set the version of the Widfly distribution to use for running
47+
the integration tests.
48+
By default $w.
49+
-j JAVA_VERSION
50+
set the version of the JDK to use for building, testing and
51+
running Silverpeas.
52+
By default $j.
53+
-v IMAGE_VERSION
54+
the version of the Docker image to build. Should be equal to
55+
the version of Silverpeas for which the Docker image is.
56+
By default $version.
57+
-n IMAGE_NAME
58+
the name of the image to build. It's strongly not recommended
59+
to modify it.
60+
By default $name.
61+
"""
3662
exit 0
3763
;;
3864
-u)
@@ -64,6 +90,12 @@ while [[ $# -gt 0 ]]; do
6490
shift # past argument
6591
shift # past first value
6692
;;
93+
-n)
94+
checkNotEmpty "$2"
95+
name="$2"
96+
shift # past argument
97+
shift # past first value
98+
;;
6799
*)
68100
die "Unknown option: $1"
69101
;;
@@ -77,6 +109,6 @@ fi
77109

78110
# build the Docker image for building some of the Silverpeas projects
79111
docker build $user $group $wildfly_version $java_version \
80-
-t silverpeas/silverdev:$version \
112+
-t $name:$version \
81113
.
82114

run.sh

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,64 @@ function die() {
55
exit 1
66
}
77

8+
image_name="silverpeas/silverdev"
89
image_version=latest
910
name="silverdev-${image_version}"
1011
while [[ $# -gt 0 ]]; do
1112
key="$1"
1213
case $key in
13-
-h)
14-
echo "Usage: run.sh [-i IMAGE_VERSION] [-w WORKING_DIR] [-n NAME] [-s]"
15-
echo "Spawns and runs a container from the Docker image silverpeas/silverdev at a given version."
16-
echo ""
17-
echo "In order to build the projects in that container, the working directory of your projects"
18-
echo "could be mounted in the container. Your IDE, on the host, could be also accessible to the"
19-
echo "container by mounting the directory into which it is installed."
20-
echo "It checks if a Maven settings settings-docker.xml exist in order to use it in the container."
21-
echo "Otherwise, it is your settings.xml that will be used."
22-
echo "The following files or directories will be also used in the container: "
23-
echo " - The Maven security configuration settings-security.xml"
24-
echo " - The Git configuration .gitconfig"
25-
echo " - The ssh configuration directory .ssh"
26-
echo " - The GPG configuration directory .gnupg"
27-
echo ""
28-
echo "with:"
29-
echo " -i IMAGE_VERSION the version of the Docker image to instantiate. By default latest."
30-
echo " -w WORKING_DIR the path of your working directory to mount The working directory"
31-
echo " will be mounted to /home/silveruser/projects. By default nothing to"
32-
echo " mount."
33-
echo " -a APP_DIR the path of the directory in which your IDE is installed or the home"
34-
echo " directory of the IDE. It will be mounted to /home/silveruser/apps."
35-
echo " You can also by this way share your other programs to the container."
36-
echo " By default nothing to mount."
37-
echo " -n NAME a name to give to the container. By default silverdev-IMAGE_VERSION."
38-
echo " -s to share the local Maven repository of the host with the container."
14+
-h|--help)
15+
echo """Usage: run.sh [-i [IMAGE_NAME:]IMAGE_VERSION] [-w WORKING_DIR] [-n NAME] [-s]
16+
17+
Spawns and runs a container from the Docker image silverpeas/silverdev at a
18+
given version.
19+
20+
In order to build the Silverpeas projects in that container, you have two
21+
possible options:
22+
- Either mounting the working folder containing the projects in the host on the
23+
container;
24+
- Either fetching the projects from your SCM in the container.
25+
Your IDE, on the host, could be also accessible to the container by mounting on
26+
it the directory in which it is installed.
27+
28+
The script checks if a Maven settings file settings-docker.xml exists in order
29+
to use it in the container. Otherwise, your settings.xml will be used.
30+
31+
The following files or directories will be also used in the container:
32+
- The Maven security configuration settings-security.xml;
33+
- The Git configuration .gitconfig;
34+
- The ssh configuration directory .ssh;
35+
- The GPG configuration directory .gnupg;
36+
37+
With:
38+
-i [IMAGE_NAME:]IMAGE_VERSION
39+
the name and the version of the Docker image to instantiate.
40+
The name is the one with which you have built the Docker image.
41+
By default the name is silverpeas/silverdev.
42+
By default the version is latest.
43+
-w WORKING_DIR
44+
the path of your working directory to mount. The working folder
45+
will be mounted on the /home/silveruser/projects directory in
46+
the container.
47+
By default nothing to mount. You have to fetch yourself the
48+
projects.
49+
-a APP_DIR
50+
the path of the directory in which your IDE is installed or the
51+
home directory of the IDE. It will be mounted on the
52+
/home/silveruser/apps folder in the container. You can also by
53+
this way to share your other programs with the container.
54+
By default nothing to mount.
55+
-n NAME
56+
a name to give to the container.
57+
By default silverdev-IMAGE_VERSION.
58+
-s
59+
to share the local Maven repository of the host with the container.
60+
"""
3961
exit 0
4062
;;
4163
-i)
42-
image_version="$2"
64+
image_version=`echo "$2" | cut -d ':' -f 2`
65+
test "$2" = "$image_version" || image_name=`echo "$2" | cut -d ':' -f 1`
4366
shift # past argument
4467
shift # past value
4568
;;
@@ -83,5 +106,6 @@ docker run -it -e DISPLAY=${DISPLAY} ${working_dir} ${app_dir} ${maven_repo} \
83106
-v "$HOME"/.gitconfig:/home/silveruser/.gitconfig \
84107
-v "$HOME"/.ssh:/home/silveruser/.ssh \
85108
-v "$HOME"/.gnupg:/home/silveruser/.gnupg \
109+
--privileged \
86110
--name ${name} \
87-
silverpeas/silverdev:${image_version} /bin/bash
111+
${image_name}:${image_version} /bin/bash

src/mozilla-firefox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Package: *
2+
Pin: release o=LP-PPA-mozillateam
3+
Pin-Priority: 1001
4+
5+
Package: firefox
6+
Pin: version 1:1snap1-0ubuntu2
7+
Pin-Priority: -1
8+

0 commit comments

Comments
 (0)