Skip to content

Commit c3054e4

Browse files
committed
Improve the Dockerfile and the run.sh script
1 parent e4e766a commit c3054e4

File tree

3 files changed

+43
-44
lines changed

3 files changed

+43
-44
lines changed

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ RUN apt-get update \
3737

3838
# Fetch and install SWFTools
3939
RUN wget -nc https://www.silverpeas.org/files/swftools-bin-0.9.2.zip \
40-
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 *swftools-bin-0.9.2.zip' | sha256sum - \
40+
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 swftools-bin-0.9.2.zip' | sha256sum -c --status - \
4141
&& unzip swftools-bin-0.9.2.zip -d / \
4242
&& rm swftools-bin-0.9.2.zip
4343

4444
# Fetch and install PDF2JSON
4545
RUN wget -nc https://www.silverpeas.org/files/pdf2json-bin-0.68.zip \
46-
&& echo 'eec849cdd75224f9d44c0999ed1fbe8764a773d8ab0cf7fff4bf922ab81c9f84 *pdf2json-bin-0.68.zip' | sha256sum - \
46+
&& echo 'eec849cdd75224f9d44c0999ed1fbe8764a773d8ab0cf7fff4bf922ab81c9f84 pdf2json-bin-0.68.zip' | sha256sum -c --status - \
4747
&& unzip pdf2json-bin-0.68.zip -d / \
4848
&& rm pdf2json-bin-0.68.zip
4949

@@ -96,7 +96,7 @@ ENV SILVERPEAS_VERSION=6.4
9696
ENV WILDFLY_VERSION=26.1.3
9797
LABEL name="Silverpeas 6.4" description="Image to install and to run Silverpeas 6.4" vendor="Silverpeas" version="6.4" build=1
9898

99-
# Fetch both Silverpeas and Wildfly and unpack them into /opt
99+
# Fetch both Silverpeas, Wildfly, and the JCR migration script and unpack them into /opt
100100
RUN wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?}.zip \
101101
&& wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?}.zip.asc \
102102
&& gpg --keyserver keys.openpgp.org --recv-keys 3F4657EF9C591F2FEA458FEBC19391EB3DF442B6 \
@@ -106,16 +106,14 @@ RUN wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-w
106106
&& unzip wildfly-${WILDFLY_VERSION}.Final.zip -d /opt \
107107
&& mv /opt/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?} /opt/silverpeas \
108108
&& mv /opt/wildfly-${WILDFLY_VERSION}.Final /opt/wildfly \
109+
&& wget -nc https://www.silverpeas.org/files/oak-migrate.zip \
110+
&& echo '02d21f69004f2d9e634e82ec062d94521bd6bc0385d7c0ddf9af261cb63afdbb oak-migrate.zip' | sha256sum -c --status - \
111+
&& mkdir -p /opt/oak-migration \
112+
&& unzip oak-migrate.zip -d /opt/oak-migration/ \
113+
&& chmod +x /opt/oak-migration/oak-migrate.sh \
109114
&& rm *.zip \
110115
&& mkdir -p /root/.m2
111116

112-
# Install the JCR migration script
113-
COPY src/oak-migrate.zip /opt/
114-
RUN mkdir /opt/oak-migration \
115-
&& unzip /opt/oak-migrate.zip -d /opt/oak-migration/ \
116-
&& chmod +x /opt/oak-migration/oak-migrate.sh \
117-
&& rm /opt/oak-migrate.zip
118-
119117
# Copy the Maven settings.xml required to install Silverpeas by fetching the software bundles from
120118
# the Silverpeas Nexus Repository
121119
COPY src/settings.xml /root/.m2/
@@ -131,11 +129,12 @@ COPY src/run.sh /opt/
131129
COPY src/converter.groovy ${SILVERPEAS_HOME}/configuration/silverpeas/
132130

133131
# Assemble Silverpeas
134-
RUN sed -i -e "s/SILVERPEAS_VERSION/${SILVERPEAS_VERSION}/g" ${SILVERPEAS_HOME}/bin/silverpeas.gradle \
135-
&& echo "Construct Silverpeas ${SILVERPEAS_VERSION}" \
136-
&& ./silverpeas assemble || eval "cat ../log/build-* && exit 1" \
137-
&& rm ../log/build-* \
138-
&& touch .install
132+
RUN set -eux; \
133+
sed -i -e "s/SILVERPEAS_VERSION/${SILVERPEAS_VERSION}/g" ${SILVERPEAS_HOME}/bin/silverpeas.gradle; \
134+
echo "Construct Silverpeas ${SILVERPEAS_VERSION}"; \
135+
./silverpeas assemble || (cat ../log/build-* && exit 1); \
136+
rm ../log/build-*; \
137+
touch .install;
139138

140139
#
141140
# Expose image entries. By default, when running, the container will set up Silverpeas and Wildfly
@@ -149,5 +148,5 @@ EXPOSE 8000 9990
149148
# the data, the properties and the workflow definitions that are produced in Silverpeas.
150149
VOLUME ["/opt/silverpeas/log", "/opt/silverpeas/data", "/opt/silverpeas/properties", "/opt/silverpeas/xmlcomponents/workflows"]
151150

152-
# What to execute by default when running the container
151+
# What to execute by default when running the container.
153152
CMD ["/opt/run.sh"]

Dockerfile.template

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ RUN apt-get update \
3737

3838
# Fetch and install SWFTools
3939
RUN wget -nc https://www.silverpeas.org/files/swftools-bin-0.9.2.zip \
40-
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 *swftools-bin-0.9.2.zip' | sha256sum - \
40+
&& echo 'd40bd091c84bde2872f2733a3c767b3a686c8e8477a3af3a96ef347cf05c5e43 swftools-bin-0.9.2.zip' | sha256sum -c --status - \
4141
&& unzip swftools-bin-0.9.2.zip -d / \
4242
&& rm swftools-bin-0.9.2.zip
4343

4444
# Fetch and install PDF2JSON
4545
RUN wget -nc https://www.silverpeas.org/files/pdf2json-bin-0.68.zip \
46-
&& echo 'eec849cdd75224f9d44c0999ed1fbe8764a773d8ab0cf7fff4bf922ab81c9f84 *pdf2json-bin-0.68.zip' | sha256sum - \
46+
&& echo 'eec849cdd75224f9d44c0999ed1fbe8764a773d8ab0cf7fff4bf922ab81c9f84 pdf2json-bin-0.68.zip' | sha256sum -c --status - \
4747
&& unzip pdf2json-bin-0.68.zip -d / \
4848
&& rm pdf2json-bin-0.68.zip
4949

@@ -96,7 +96,7 @@ ENV SILVERPEAS_VERSION=TARGET_SILVERPEAS_VERSION
9696
ENV WILDFLY_VERSION=TARGET_WILDFLY_VERSION
9797
LABEL name="Silverpeas TARGET_SILVERPEAS_VERSION" description="Image to install and to run Silverpeas TARGET_SILVERPEAS_VERSION" vendor="Silverpeas" version="TARGET_SILVERPEAS_VERSION" build=1
9898

99-
# Fetch both Silverpeas and Wildfly and unpack them into /opt
99+
# Fetch both Silverpeas, Wildfly, and the JCR migration script and unpack them into /opt
100100
RUN wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?}.zip \
101101
&& wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?}.zip.asc \
102102
&& gpg --keyserver keys.openpgp.org --recv-keys 3F4657EF9C591F2FEA458FEBC19391EB3DF442B6 \
@@ -106,16 +106,14 @@ RUN wget -nc https://www.silverpeas.org/files/silverpeas-${SILVERPEAS_VERSION}-w
106106
&& unzip wildfly-${WILDFLY_VERSION}.Final.zip -d /opt \
107107
&& mv /opt/silverpeas-${SILVERPEAS_VERSION}-wildfly${WILDFLY_VERSION%.?.?} /opt/silverpeas \
108108
&& mv /opt/wildfly-${WILDFLY_VERSION}.Final /opt/wildfly \
109+
&& wget -nc https://www.silverpeas.org/files/oak-migrate.zip \
110+
&& echo '02d21f69004f2d9e634e82ec062d94521bd6bc0385d7c0ddf9af261cb63afdbb oak-migrate.zip' | sha256sum -c --status - \
111+
&& mkdir -p /opt/oak-migration \
112+
&& unzip oak-migrate.zip -d /opt/oak-migration/ \
113+
&& chmod +x /opt/oak-migration/oak-migrate.sh \
109114
&& rm *.zip \
110115
&& mkdir -p /root/.m2
111116

112-
# Install the JCR migration script
113-
COPY src/oak-migrate.zip /opt/
114-
RUN mkdir /opt/oak-migration \
115-
&& unzip /opt/oak-migrate.zip -d /opt/oak-migration/ \
116-
&& chmod +x /opt/oak-migration/oak-migrate.sh \
117-
&& rm /opt/oak-migrate.zip
118-
119117
# Copy the Maven settings.xml required to install Silverpeas by fetching the software bundles from
120118
# the Silverpeas Nexus Repository
121119
COPY src/settings.xml /root/.m2/
@@ -131,11 +129,12 @@ COPY src/run.sh /opt/
131129
COPY src/converter.groovy ${SILVERPEAS_HOME}/configuration/silverpeas/
132130

133131
# Assemble Silverpeas
134-
RUN sed -i -e "s/SILVERPEAS_VERSION/${SILVERPEAS_VERSION}/g" ${SILVERPEAS_HOME}/bin/silverpeas.gradle \
135-
&& echo "Construct Silverpeas ${SILVERPEAS_VERSION}" \
136-
&& ./silverpeas assemble || eval "cat ../log/build-* && exit 1" \
137-
&& rm ../log/build-* \
138-
&& touch .install
132+
RUN set -eux; \
133+
sed -i -e "s/SILVERPEAS_VERSION/${SILVERPEAS_VERSION}/g" ${SILVERPEAS_HOME}/bin/silverpeas.gradle; \
134+
echo "Construct Silverpeas ${SILVERPEAS_VERSION}"; \
135+
./silverpeas assemble || (cat ../log/build-* && exit 1); \
136+
rm ../log/build-*; \
137+
touch .install;
139138

140139
#
141140
# Expose image entries. By default, when running, the container will set up Silverpeas and Wildfly
@@ -149,5 +148,5 @@ EXPOSE 8000 9990
149148
# the data, the properties and the workflow definitions that are produced in Silverpeas.
150149
VOLUME ["/opt/silverpeas/log", "/opt/silverpeas/data", "/opt/silverpeas/properties", "/opt/silverpeas/xmlcomponents/workflows"]
151150

152-
# What to execute by default when running the container
151+
# What to execute by default when running the container.
153152
CMD ["/opt/run.sh"]

src/run.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -e
99
# Creates the Silverpeas global configuration file config.properties from the environment variables
1010
# set in the Docker image
1111
pre_install() {
12-
if [ -f ${SILVERPEAS_HOME}/configuration/config.properties ]; then
12+
if [ -f "${SILVERPEAS_HOME}/configuration/config.properties" ]; then
1313
echo "The configuration file ${SILVERPEAS_HOME}/configuration/config.properties already exists. Does nothing"
1414
return
1515
fi
@@ -33,14 +33,14 @@ DB_NAME = $dbname
3333
DB_USER = $dbuser
3434
DB_PASSWORD = $dbpassword
3535
EOF
36-
test "Z${dbport}" = "Z" || echo "DB_PORT_$dbtype = $dbport" >> ${SILVERPEAS_HOME}/configuration/config.properties
36+
test "Z${dbport}" = "Z" || echo "DB_PORT_$dbtype = $dbport" >> "${SILVERPEAS_HOME}/configuration/config.properties"
3737
fi
3838
}
3939

4040
# Start Silverpeas
4141
start_silverpeas() {
4242
echo "Start Silverpeas..."
43-
exec ${JBOSS_HOME}/bin/standalone.sh -b 0.0.0.0 -c standalone-full.xml
43+
exec "${JBOSS_HOME}/bin/standalone.sh" -b 0.0.0.0 -c standalone-full.xml
4444
}
4545

4646
# Stop Silverpeas
@@ -57,7 +57,7 @@ stop_silverpeas() {
5757
# For doing we have to find out where the JCR home directory is located.
5858
migrate_jcr() {
5959
# figure out the data home directory (by default it is into the Silverpeas home directory)
60-
data_home=`grep "SILVERPEAS_DATA_HOME=" ${SILVERPEAS_HOME}/configuration/config.properties | cut -d '=' -f 2 | xargs`
60+
data_home=`grep "SILVERPEAS_DATA_HOME[ ]*=" "${SILVERPEAS_HOME}/configuration/config.properties" | cut -d '=' -f 2 | xargs`
6161
if [ "Z${data_home}" = "Z" ]; then
6262
data_home="${SILVERPEAS_HOME}/data"
6363
else
@@ -66,7 +66,7 @@ migrate_jcr() {
6666
fi
6767

6868
# figure out now the JCR home directory (by default it is located into the data home directory)
69-
jcr_home=`grep "JCR_HOME[ ]*=" ${SILVERPEAS_HOME}/configuration/config.properties | cut -d '=' -f 2 | xargs`
69+
jcr_home=`grep "JCR_HOME[ ]*=" "${SILVERPEAS_HOME}/configuration/config.properties" | cut -d '=' -f 2 | xargs`
7070
if [ "Z${jcr_home}" = "Z" ]; then
7171
jcr_home="${data_home}/jcr"
7272
else
@@ -77,27 +77,28 @@ migrate_jcr() {
7777
jcr_dir=`dirname ${jcr_home}`
7878
if [ -d "${jcr_dir}/jackrabbit" ] && [ ! -d "${jcr_dir}/jcr/segmentstore" ]; then
7979
echo "Migrate the JCR from Apache Jackrabbit 2 to Apache Jackrabbit Oak..."
80-
/opt/oak-migration/oak-migrate.sh "${jcr_dir}/jackrabbit" "${jcr_dir}/jcr"
81-
test $? -eq 0 || exit 1
80+
if ! /opt/oak-migration/oak-migrate.sh "$jcr_dir/jackrabbit" "$jcr_dir/jcr"; then
81+
exit 1
82+
fi
8283
fi
8384
}
8485

8586
trap 'stop_silverpeas' SIGTERM SIGKILL SIGQUIT
8687

87-
if [ -f ${SILVERPEAS_HOME}/bin/.install ]; then
88+
if [ -f "${SILVERPEAS_HOME}/bin/.install" ]; then
8889
pre_install
89-
if [ -f ${SILVERPEAS_HOME}/configuration/config.properties ]; then
90+
if [ -f "${SILVERPEAS_HOME}/configuration/config.properties" ]; then
9091
echo "First start: set up Silverpeas..."
9192
set +e
9293
./silverpeas install
9394
if [ $? -eq 0 ]; then
94-
rm ${SILVERPEAS_HOME}/bin/.install
95+
rm "${SILVERPEAS_HOME}/bin/.install"
9596
migrate_jcr
9697
test ${PING_ON} = 1 && curl -k -i --head https://www.silverpeas.org/ping
9798
else
9899
echo "Error while setting up Silverpeas"
99100
echo
100-
for f in ${SILVERPEAS_HOME}/log/build-*; do
101+
for f in "${SILVERPEAS_HOME}"/log/build-*; do
101102
cat $f
102103
done
103104
exit 1
@@ -109,7 +110,7 @@ if [ -f ${SILVERPEAS_HOME}/bin/.install ]; then
109110
fi
110111
fi
111112

112-
if [ -f ${SILVERPEAS_HOME}/configuration/config.properties ] && [ ! -e ${SILVERPEAS_HOME}/bin/.install ]; then
113+
if [ -f "${SILVERPEAS_HOME}/configuration/config.properties" ] && [ ! -e "${SILVERPEAS_HOME}/bin/.install" ]; then
113114
start_silverpeas
114115
else
115116
echo "A failure has occurred in the setting up of Silverpeas! No start!"

0 commit comments

Comments
 (0)