Skip to content

Commit 55216d2

Browse files
committed
Merge branch 'development'
2 parents c7da83b + ecf6fef commit 55216d2

8 files changed

Lines changed: 28 additions & 59 deletions

File tree

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ USER root
44

55
RUN apt-get update && \
66
apt-get upgrade -y perl && \
7-
apt-get install -y --no-install-recommends nginx default-jre && \
7+
apt-get install -y --no-install-recommends nginx default-jre openssl && \
88
apt-get clean && \
99
rm -rf /var/lib/apt/lists/* && \
1010
rm -rf /etc/nginx/sites-enabled/default /var/www/html/* && \
@@ -165,8 +165,8 @@ COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} $WPR_DICTIONARIES_DIR $WPR_D
165165
COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} /etc/nginx/conf.d/wscservice.conf /etc/nginx/conf.d/wscservice.conf
166166
COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} /etc/nginx/nginx.conf /etc/nginx/nginx.conf
167167

168-
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/$WPR_CERT_KEY_NAME $WPR_CERT_DIR/$WPR_CERT_KEY_NAME
169-
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/$WPR_CERT_FILE_NAME $WPR_CERT_DIR/$WPR_CERT_FILE_NAME
168+
RUN mkdir -p $WPR_CERT_DIR && chown ${WPR_FILE_OWNER} $WPR_CERT_DIR
169+
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/ $WPR_CERT_DIR/
170170
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/configure* $WPR_APP_SERVER_DIR/
171171
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/startService.sh $WPR_APP_SERVER_DIR
172172

Dockerfile.redhat

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ RUN yum update -y --skip-broken && \
66
yum module enable nginx:1.24 -y && \
77
yum install -y nginx \
88
java-17-openjdk-devel \
9-
perl && \
9+
perl \
10+
openssl && \
1011
yum remove -y webkit2gtk3-jsc \
1112
python-setuptools \
1213
python-urllib3 \
@@ -170,8 +171,8 @@ COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} $WPR_DICTIONARIES_DIR $WPR_D
170171
COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} /etc/nginx/conf.d/wscservice.conf /etc/nginx/conf.d/wscservice.conf
171172
COPY --from=wpr_installer --chown=${WPR_FILE_OWNER} /etc/nginx/nginx.conf /etc/nginx/nginx.conf
172173

173-
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/$WPR_CERT_KEY_NAME $WPR_CERT_DIR/$WPR_CERT_KEY_NAME
174-
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/$WPR_CERT_FILE_NAME $WPR_CERT_DIR/$WPR_CERT_FILE_NAME
174+
RUN mkdir -p $WPR_CERT_DIR && chown ${WPR_FILE_OWNER} $WPR_CERT_DIR
175+
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/certificate/ $WPR_CERT_DIR/
175176
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/configure* $WPR_APP_SERVER_DIR/
176177
COPY --chown=${WPR_FILE_OWNER} $WPR_FILES_DIR/startService.sh $WPR_APP_SERVER_DIR
177178

Dockerfile.ubuntu-prebuilt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ USER root
6161

6262
RUN apt-get update && \
6363
apt-get upgrade -y perl && \
64-
apt-get install -y --no-install-recommends nginx default-jre && \
64+
apt-get install -y --no-install-recommends nginx default-jre openssl && \
6565
apt-get clean && \
6666
rm -rf /var/lib/apt/lists/* && \
6767
rm -rf /etc/nginx/sites-enabled/default /var/www/html/* && \
@@ -164,7 +164,7 @@ COPY --from=wpr_install_languages --chown=${WPR_USER_ID}:${WPR_GROUP_ID} /var/li
164164
COPY --from=wpr_install_languages --chown=${WPR_USER_ID}:${WPR_GROUP_ID} /etc/nginx/conf.d/wscservice.conf /etc/nginx/conf.d/wscservice.conf
165165
COPY --from=wpr_install_languages --chown=${WPR_USER_ID}:${WPR_GROUP_ID} /etc/nginx/nginx.conf /etc/nginx/nginx.conf
166166
COPY --from=wpr_install_languages --chown=${WPR_USER_ID}:${WPR_GROUP_ID} /dictionaries ${WPR_DICTIONARIES_DIR}
167-
COPY --from=wpr_install_languages --chown=${WPR_USER_ID}:${WPR_GROUP_ID} /certificate ${WPR_CERT_DIR}
167+
RUN mkdir -p $WPR_CERT_DIR && chown ${WPR_USER_ID}:${WPR_GROUP_ID} $WPR_CERT_DIR
168168

169169
RUN mkdir -p /var/run/nginx && \
170170
chown -R ${WPR_USER_ID}:${WPR_GROUP_ID} /etc/nginx \

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ ARG WPR_WEB_PORT
2929
ARG WPR_DOMAIN_NAME=localhost
3030
ARG WPR_VIRTUAL_DIR=wscservice
3131
ARG WPR_LICENSE_TICKET_ID
32-
ARG WPR_PRODUCTS=4
33-
ARG WPR_INSTALL_SAMPLES=1
3432
```
3533
* Choose languages to be installed:
3634
```
@@ -69,7 +67,7 @@ ARG WPR_PROXY_PASSWORD=password
6967

7068
For details on the available options, refer to [Automated Installing WebSpellChecker on Linux](https://docs.webspellchecker.net/display/WebSpellCheckerServer55x/Automated+Installing+WebSpellChecker+on+Linux) guide.
7169

72-
4. If you need to use SSL (access the service via HTTPS), put your SSL certificate and key files to the `wproofreader-docker/files/certificate` directory. You need to rename your certificate files to `cert.pem` and `key.pem` accordingly.
70+
4. SSL certificates (optional). If you need to use SSL (access the service via HTTPS) with your own certificates, put your SSL certificate and key files in the `wproofreader-docker/files/certificate` directory. By default, the expected filenames are `cert.pem` and `key.pem`, but you can customize them with the `WPR_CERT_FILE_NAME` and `WPR_CERT_KEY_NAME` build arguments. The files will be baked into the image at build time. Alternatively, you can mount certificates at runtime (see [Create and run Docker container](#create-and-run-docker-container)). If HTTPS is enabled and no certificates are provided, self-signed certificates will be generated automatically at container startup.
7371

7472
5. Build a Docker image using the command below:
7573

@@ -146,8 +144,10 @@ where:
146144

147145
* `-d` start a container in detached mode.
148146
* `-p 80:8080` map the host port `80:` and the exposed port of container `8080`, where port `8080` is a web server port (by default, NGINX). With the SSL connection, you must use port `443` like `-p 443:8443`.
149-
* `-v <shared_dictionaries_directory>:/dictionaries` mount a shared directory where user and company custom dictionaries will be created and stored. Upon initial launch, the mounted directory may be empty. All essential subdirectories and files will be generated during initialization of the container. This is required to save the dictionaries among different containers. **Note!** The container user needs to have read and write permissions to the shared dictionary directory.
150-
* `-v <certificate_directory_path>:/certificate` mount a shared directory where your SSL certificates are located. Use this option if you plan to work under SSL and you want to use a specific certificate for this container. The names of the files must be `cert.pem` and `key.pem`. If not specified, the default test SSL certificate (e.g. `ssl-cert-snakeoil`) shipped with Ubuntu will be used. **Note!** The container user must have read permissions for the certificate files.
147+
* `-v <shared_dictionaries_directory>:/dictionaries` mount a shared directory where user and company custom dictionaries will be created and stored. Upon initial launch, the mounted directory may be empty. All essential subdirectories and files will be generated during initialization of the container. This is required to save the dictionaries among different containers.
148+
Note: The container user needs to have read and write permissions to the shared dictionary directory.
149+
* `-v <certificate_directory_path>:/certificate` mount a shared directory where your SSL certificates are located. Use this option if you plan to work under SSL and you want to use a specific certificate for this container. By default, the expected filenames are `cert.pem` and `key.pem` (configurable via `WPR_CERT_FILE_NAME` and `WPR_CERT_KEY_NAME`). If no certificates are provided (neither baked in at build time nor mounted at runtime), self-signed certificates will be generated automatically when the container starts with HTTPS enabled.
150+
Note: The container user must have read permissions for the certificate files.
151151
* `local/wsc_app:x.x.x` the tag of WebSpellChecker Server Docker image.
152152

153153
Alternatively, these parameters can be changed on the container running by passing them as environment variables:
@@ -292,7 +292,7 @@ Notes:
292292
- WPR_DOMAIN_NAME=localhost
293293
- WPR_VIRTUAL_DIR=wscservice
294294
```
295-
3. For HTTPS communication you have to provide your certificate file and key, as a pair of files named `cert.pem` and `key.pem`, respectively. If, for instance, they are kept in a folder `/home/user/certificate`, one should add the following section to `docker-compose.yml`:
295+
3. For HTTPS communication you can provide your certificate file and key, as a pair of files named `cert.pem` and `key.pem` by default (configurable via `WPR_CERT_FILE_NAME` and `WPR_CERT_KEY_NAME`). If no certificates are mounted, self-signed certificates will be generated automatically at startup. To use your own certificates — for instance, if they are kept in a folder `/home/user/certificate` add the following section to `docker-compose.yml`:
296296
```yaml
297297
volumes:
298298
- /home/user/certificate:/certificate

files/certificate/.gitkeep

Whitespace-only changes.

files/certificate/cert.pem

Lines changed: 0 additions & 17 deletions
This file was deleted.

files/certificate/key.pem

Lines changed: 0 additions & 28 deletions
This file was deleted.

files/startService.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ if ! [ -f "${LicenseFile}" ]; then
2525
./AppServerX -activateLicense ${WPR_LICENSE_TICKET_ID} -y
2626
fi
2727

28+
# Generate self-signed certificates if HTTPS is enabled and no certs are provided
29+
if [ "$WPR_PROTOCOL" = "1" ]; then
30+
if [ ! -f "${WPR_CERT_DIR}/${WPR_CERT_FILE_NAME}" ] || [ ! -f "${WPR_CERT_DIR}/${WPR_CERT_KEY_NAME}" ]; then
31+
echo "$(date '+%m/%d/%y:%H:%M:%S.%3N') No SSL certificates found. Generating self-signed certificate for CN=${WPR_DOMAIN_NAME:-localhost}..."
32+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
33+
-keyout "${WPR_CERT_DIR}/${WPR_CERT_KEY_NAME}" \
34+
-out "${WPR_CERT_DIR}/${WPR_CERT_FILE_NAME}" \
35+
-subj "/CN=${WPR_DOMAIN_NAME:-localhost}" 2>/dev/null
36+
echo "$(date '+%m/%d/%y:%H:%M:%S.%3N') Self-signed certificate created: ${WPR_CERT_DIR}/${WPR_CERT_FILE_NAME}, ${WPR_CERT_DIR}/${WPR_CERT_KEY_NAME}"
37+
echo "$(date '+%m/%d/%y:%H:%M:%S.%3N') For production, mount real certificates to ${WPR_CERT_DIR}/"
38+
fi
39+
fi
40+
2841
#start NGINX for Ubuntu or Centos
2942
nginx
3043

0 commit comments

Comments
 (0)