From b490f2afaed316c7e39bec0b2f1c4a29463c8fb8 Mon Sep 17 00:00:00 2001 From: Anton Ovcharenko Date: Thu, 24 Nov 2022 22:21:37 +0200 Subject: [PATCH 1/3] add service dir path via env --- Dockerfile | 7 ++++--- DockerfileCentOS | 3 ++- DockerfileRedHat | 3 ++- files/configureFiles.pl | 3 ++- files/startService.sh | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a0f8d25..da26464 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG LICENSE_DIR=/var/lib/wsc/license +ARG SERVICE_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -65,6 +65,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} +ENV SERVICE_DIR=${SERVICE_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} @@ -88,7 +89,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $LICENSE_DIR \ + $SERVICE_DIR \ /var/run/nginx COPY $FILES_DIR/$APP_NAME_MASK $DEPLOYMENT_DIR/ @@ -101,7 +102,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $LICENSE_DIR $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/DockerfileCentOS b/DockerfileCentOS index 6027f24..a833c2c 100755 --- a/DockerfileCentOS +++ b/DockerfileCentOS @@ -23,7 +23,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG LICENSE_DIR=/var/lib/wsc/license +ARG SERVICE_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -63,6 +63,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} +ENV SERVICE_DIR=${SERVICE_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} diff --git a/DockerfileRedHat b/DockerfileRedHat index 6404f0e..01900e9 100644 --- a/DockerfileRedHat +++ b/DockerfileRedHat @@ -23,7 +23,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG LICENSE_DIR=/var/lib/wsc/license +ARG SERVICE_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -63,6 +63,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} +ENV SERVICE_DIR=${SERVICE_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} diff --git a/files/configureFiles.pl b/files/configureFiles.pl index 5143db3..7a089cd 100644 --- a/files/configureFiles.pl +++ b/files/configureFiles.pl @@ -108,7 +108,8 @@ sub configureSsl sub configureAppServerParams { - replaceFileContent('\d*', '0', "AppServerX.xml"); + replaceFileContent('\d*', '0', $server_config_path); + replaceFileContent('', "\n $ENV{'SERVICE_DIR'}", $server_config_path); } sub replaceFileContent diff --git a/files/startService.sh b/files/startService.sh index 561f4ee..4fbb54e 100755 --- a/files/startService.sh +++ b/files/startService.sh @@ -11,7 +11,7 @@ perl configureWebServer.pl perl configureFiles.pl # activate a license automatically -LicenseFile="${LICENSE_DIR}/license.xml" +LicenseFile="${SERVICE_DIR}/wsc/license/license.xml" if ! [ -f "${LicenseFile}" ]; then ./AppServerX -activateLicense ${LICENSE_TICKET_ID} -y fi From 38969dad1afade03c6f613e8d33a05a6a9b24d34 Mon Sep 17 00:00:00 2001 From: Anton Ovcharenko Date: Thu, 24 Nov 2022 23:27:52 +0200 Subject: [PATCH 2/3] create wsc folder and give permissions --- Dockerfile | 4 ++-- DockerfileCentOS | 4 ++-- DockerfileRedHat | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index da26464..99dd9c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,7 +89,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $SERVICE_DIR \ + $SERVICE_DIR/wsc \ /var/run/nginx COPY $FILES_DIR/$APP_NAME_MASK $DEPLOYMENT_DIR/ @@ -102,7 +102,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/DockerfileCentOS b/DockerfileCentOS index a833c2c..e769571 100755 --- a/DockerfileCentOS +++ b/DockerfileCentOS @@ -95,7 +95,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $LICENSE_DIR \ + $SERVICE_DIR/wsc \ $APP_SERVER_DIR \ /var/run/nginx @@ -109,7 +109,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $LICENSE_DIR $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/DockerfileRedHat b/DockerfileRedHat index 01900e9..e81a331 100644 --- a/DockerfileRedHat +++ b/DockerfileRedHat @@ -94,7 +94,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $LICENSE_DIR \ + $SERVICE_DIR/wsc \ $APP_SERVER_DIR \ /var/run/nginx @@ -108,7 +108,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $LICENSE_DIR $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME From 361aca6587b2138f7c2b68cc9ca15751674b1f4a Mon Sep 17 00:00:00 2001 From: Anton Ovcharenko Date: Fri, 25 Nov 2022 15:06:36 +0200 Subject: [PATCH 3/3] rename SERVICE_DIR to SERVICE_FILES_DIR --- Dockerfile | 8 ++++---- DockerfileCentOS | 8 ++++---- DockerfileRedHat | 8 ++++---- files/configureFiles.pl | 2 +- files/startService.sh | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99dd9c2..62bf0a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG SERVICE_DIR=/var/lib +ARG SERVICE_FILES_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -65,7 +65,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} -ENV SERVICE_DIR=${SERVICE_DIR} +ENV SERVICE_FILES_DIR=${SERVICE_FILES_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} @@ -89,7 +89,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $SERVICE_DIR/wsc \ + $SERVICE_FILES_DIR/wsc \ /var/run/nginx COPY $FILES_DIR/$APP_NAME_MASK $DEPLOYMENT_DIR/ @@ -102,7 +102,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_FILES_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/DockerfileCentOS b/DockerfileCentOS index e769571..4c242cb 100755 --- a/DockerfileCentOS +++ b/DockerfileCentOS @@ -23,7 +23,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG SERVICE_DIR=/var/lib +ARG SERVICE_FILES_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -63,7 +63,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} -ENV SERVICE_DIR=${SERVICE_DIR} +ENV SERVICE_FILES_DIR=${SERVICE_FILES_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} @@ -95,7 +95,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $SERVICE_DIR/wsc \ + $SERVICE_FILES_DIR/wsc \ $APP_SERVER_DIR \ /var/run/nginx @@ -109,7 +109,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_FILES_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/DockerfileRedHat b/DockerfileRedHat index e81a331..f83ed7e 100644 --- a/DockerfileRedHat +++ b/DockerfileRedHat @@ -23,7 +23,7 @@ ARG APP_ROOT_DIR=$DEPLOYMENT_DIR/$APP_ROOT_NAME ARG APP_SERVER_DIR=/opt/$APP_ROOT_NAME/AppServer ARG APP_NAME_MASK=wsc_app* ARG USER_NAME=wsc -ARG SERVICE_DIR=/var/lib +ARG SERVICE_FILES_DIR=/var/lib ARG USER_ID=2000 ARG GROUP_ID=2000 @@ -63,7 +63,7 @@ ENV VIRTUAL_DIR=${VIRTUAL_DIR} ENV WEB_SERVER_TYPE=2 ENV ACTIVATE_LICENSE=${ACTIVATE_LICENSE} ENV LICENSE_TICKET_ID=${LICENSE_TICKET_ID} -ENV SERVICE_DIR=${SERVICE_DIR} +ENV SERVICE_FILES_DIR=${SERVICE_FILES_DIR} ENV RESTART_WEB_SERVER=1 ENV CERT_DIR=${CERT_DIR} ENV CERT_KEY_NAME=${CERT_KEY_NAME} @@ -94,7 +94,7 @@ RUN groupadd --gid ${GROUP_ID} $USER_NAME && useradd --no-log-init --uid ${USER_ RUN mkdir -p $CUSTOM_DICTIONARIES_DIR \ $USER_DICTIONARIES_DIR \ - $SERVICE_DIR/wsc \ + $SERVICE_FILES_DIR/wsc \ $APP_SERVER_DIR \ /var/run/nginx @@ -108,7 +108,7 @@ RUN tar -xvf $DEPLOYMENT_DIR/$APP_NAME_MASK -C $DEPLOYMENT_DIR/ && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-0.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Child-1.log && \ ln -s /dev/stdout $APP_SERVER_DIR/Logs/Action.log && \ - chown -R ${USER_ID}:${GROUP_ID} $SERVICE_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR + chown -R ${USER_ID}:${GROUP_ID} $SERVICE_FILES_DIR/wsc $DICTIONARIES_DIR $APP_SERVER_DIR COPY $FILES_DIR/certificate/$CERT_KEY_NAME $CERT_DIR/$CERT_KEY_NAME COPY $FILES_DIR/certificate/$CERT_FILE_NAME $CERT_DIR/$CERT_FILE_NAME diff --git a/files/configureFiles.pl b/files/configureFiles.pl index 7a089cd..f237254 100644 --- a/files/configureFiles.pl +++ b/files/configureFiles.pl @@ -109,7 +109,7 @@ sub configureSsl sub configureAppServerParams { replaceFileContent('\d*', '0', $server_config_path); - replaceFileContent('', "\n $ENV{'SERVICE_DIR'}", $server_config_path); + replaceFileContent('', "\n $ENV{'SERVICE_FILES_DIR'}", $server_config_path); } sub replaceFileContent diff --git a/files/startService.sh b/files/startService.sh index 4fbb54e..3e0bf78 100755 --- a/files/startService.sh +++ b/files/startService.sh @@ -11,7 +11,7 @@ perl configureWebServer.pl perl configureFiles.pl # activate a license automatically -LicenseFile="${SERVICE_DIR}/wsc/license/license.xml" +LicenseFile="${SERVICE_FILES_DIR}/wsc/license/license.xml" if ! [ -f "${LicenseFile}" ]; then ./AppServerX -activateLicense ${LICENSE_TICKET_ID} -y fi