Skip to content

Commit e08f20e

Browse files
committed
Update the Dockerfile and the script to build an image from it
1 parent 9cce354 commit e08f20e

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ ARG JAVA_VERSION=11
2626
ARG USER_ID=1000
2727
ARG GROUP_ID=1000
2828

29+
ENV DEBIAN_FRONTEND=noninteractive
30+
2931
COPY src/maven-deps.zip /tmp/
3032

3133
RUN apt-get update && apt-get install -y \
@@ -66,7 +68,7 @@ RUN apt-get update && apt-get install -y \
6668
&& rm -f /tmp/apache-maven.tar.gz \
6769
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn \
6870
&& unzip /tmp/maven-deps.zip -d /home/silveruser/ \
69-
&& chown -R silveruser:users /home/silveruser/.m2 \
71+
&& chown -R silveruser:silveruser /home/silveruser/.m2 \
7072
&& curl -fsSL -o /tmp/swftools-bin-0.9.2.zip https://www.silverpeas.org/files/swftools-bin-0.9.2.zip \
7173
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 *swftools-bin-0.9.2.zip' | sha256sum - \
7274
&& unzip /tmp/swftools-bin-0.9.2.zip -d / \
@@ -87,6 +89,9 @@ RUN apt-get update && apt-get install -y \
8789
COPY src/inputrc /home/silveruser/.inputrc
8890
COPY src/settings.xml /home/silveruser/.m2/
8991

92+
RUN chown silveruser:silveruser /home/silveruser/.inputrc \
93+
&& chown silveruser:silveruser /home/silveruser/.m2/settings.xml
94+
9095
ENV LANG ${DEFAULT_LOCALE}
9196
ENV LANGUAGE ${DEFAULT_LOCALE}
9297
ENV LC_ALL ${DEFAULT_LOCALE}

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@ To create an image, just do:
1313

1414
$ ./build.sh
1515

16-
this will build an image to work on the latest version of Silverpeas as defined in the `Dockerfile`
17-
with the tag `silverpeas/silverdev:latest`.
16+
this will build an image to work on the latest version of Silverpeas and with the latest supported
17+
version of Wildfly as defined in the `Dockerfile` with the tag `silverpeas/silverdev:latest`.
1818

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:
19+
To specify both a given version of Wildfly (for instance Wildfly 10.1.0) to use and the version of
20+
the image to set, just do:
2121

22-
$ ./build.sh -v 6.0 10.1.0
22+
$ ./build.sh -w 10.1.0 -v 6.0
2323

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
24+
This will build a Docker image with the tag `silverpeas/silverdev:6.0`. By convention, the version of
25+
the Docker image should be the same of the version of Silverpeas for which the image is dedicated. It
26+
is mainly for information so what, by doing so, it will be easy for the developer to switch between
27+
different containers, each of them prepared for a different version of Silverpeas.
28+
Nevertheless, the version of Wildfly passed as argument is important because a Wildfly distribution
29+
preconfigured for the integration tests will be downloaded and in general, for each version of Silverpeas
3130
(stable or in-development version) matches a given version of Wildfly.
3231

3332
The image is created to start a container with a default user (`silveruser`). 1000 is his identifier
3433
and `users` (group identifier 100) is its main group.
3534
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
35+
container(s), it is required that the identifier of your account in your host is the same that the
3736
identifier of the default user in the container. In the case your user identifier isn't 1000, then you have to
3837
create an image by specifying the identifier in the command line as following (here, in our example,
3938
the user identifier is 1026):

build.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ while [[ $# -gt 0 ]]; do
1414
key="$1"
1515
case $key in
1616
-h)
17-
echo "Usage: build.sh [-u USER_ID] [-g GROUP_ID] -v [SILVERPEAS_VERSION WILDFLY_VERSION]"
17+
echo "Usage: build.sh [-u USER_ID] [-g GROUP_ID] [-w WILDFLY_VERSION] [-v IMAGE_VERSION]"
1818
echo "Build a Docker image from which a Docker container could be spawned to code and build"
1919
echo "within a compartmentalized environment some Silverpeas projects that can be shared "
2020
echo "between the container and the host."
@@ -25,10 +25,12 @@ while [[ $# -gt 0 ]]; do
2525
echo " -g GROUP_ID set the group identifier as GROUP_ID (it is recommended the GROUP_ID is"
2626
echo " your own group identifier in the host if the code source is shared"
2727
echo " between a Docker container and the host. By default 1000."
28-
echo " -v SILVERPEAS_VERSION WILDFLY_VERSION"
29-
echo " set both the version of Silverpeas and of the Widfly distribution for"
30-
echo " which a docker container will be spawn to work on theses versions."
31-
echo " By default, the latest version in development of Silverpeas"
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 " -v IMAGE_VERSION"
32+
echo " the version of the Docker image to build. Should be equal to the"
33+
echo " version of Silverpeas for which the Docker image is."
3234
exit 0
3335
;;
3436
-u)
@@ -41,15 +43,18 @@ while [[ $# -gt 0 ]]; do
4143
shift # past argument
4244
shift # past value
4345
;;
46+
-w)
47+
checkNotEmpty "$2"
48+
wildfly_version="--build-arg WILDFLY_VERSION=$2"
49+
shift # past argument
50+
shift # past first value
51+
;;
4452
-v)
53+
checkNotEmpty "$2"
4554
silverpeas_version="$2"
46-
wildfly_version="$3"
47-
checkNotEmpty ${silverpeas_version}
48-
checkNotEmpty ${wildfly_version}
4955
version=1
5056
shift # past argument
5157
shift # past first value
52-
shift # past second value
5358
;;
5459
*)
5560
die "Unknown option: $1"
@@ -60,12 +65,11 @@ done
6065

6166
# build the Docker image for building some of the Silverpeas projects
6267
if [[ ${version} -eq 1 ]]; then
63-
docker build ${user} ${group} \
64-
--build-arg WILDFLY_VERSION=${wildfly_version} \
68+
docker build ${user} ${group} ${wildfly_version} \
6569
-t silverpeas/silverdev:${silverpeas_version} \
6670
.
6771
else
68-
docker build ${user} ${group} \
72+
docker build ${user} ${group} ${wildfly_version} \
6973
-t silverpeas/silverdev:latest \
7074
.
7175
fi

run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ while [[ $# -gt 0 ]]; do
2424
echo ""
2525
echo "with:"
2626
echo " -i IMAGE_VERSION the version of the Docker image to instantiate. By default latest."
27-
echo " -g WORKING_DIR the path of your working directory to mount The working directory"
27+
echo " -w WORKING_DIR the path of your working directory to mount The working directory"
2828
echo " will be mounted to /home/silveruser/projects. By default nothing to"
2929
echo " mount."
3030
echo " -n NAME a name to give to the container. By default silverdev-IMAGE_VERSION."
@@ -63,4 +63,4 @@ docker run -it ${working_dir} -v "${settings}":/home/silveruser/.m2/settings.xml
6363
-v "$HOME"/.ssh:/home/silveruser/.ssh \
6464
-v "$HOME"/.gnupg:/home/silveruser/.gnupg \
6565
--name ${name} \
66-
silverpeas/silverdev:${image_version} /bin/bash
66+
silverpeas/silverdev:${image_version} /bin/bash

0 commit comments

Comments
 (0)