Edit online

Running the Publishing Engine Docker Image on AWS

Read time: 4 minute(s)

You can create an EC2 instance on the Amazon Cloud Computing AWS platform, run the publishing there if changes are detected in a Git project, and publish the content to the same platform.

Create an Account on AWS
Sign in to create an account on AWS.
Create an EC2 Instance
Create an EC2 Instance on AWS.
Configure the Security Group and Install a Web Server
Configure the Security Group associated to the EC2 instance to allow for HTTP or HTTPS connections and install a web server.
Connect to the EC2 Instance
Use the AWS Instance Connect to open a console in the web browser to the instance.
Install Git in the EC2 instance
Run this command in the console to install git:
sudo yum install git
Install Docker in the EC2 Instance
Run this command in the console to install Docker and start the Docker daemon:
sudo yum install docker
sudo systemctl start docker
Clone the Git Project
Create a local clone of the Git project by running this command in the console:
git clone https://github.com/oxygenxml/blog.git
Create the Docker Image
Change directory to the folder containing the Dockerfile and run Docker to create an image.
cd blog/build
sudo docker image build -t oxygen-publishing-engine:1.0 .
Save the Oxygen Publishing Engine License to a file
Save the Oxygen Publishing Engine license key to a file (for example, in /home/ec2-user/licensekey.txt).
Run a Container Based on the Docker Image to Publish
sudo docker run -e LICENSE_KEY="$(</home/ec2-user/licensekey.txt)" \
--rm --name dita-ot-publish\
-v /home/ec2-user/blog/:/src  \
oxygen-publishing-engine:1.0 \
-p /src/blog-project.xml \
-o /src/out \
-f webhelp-responsive -v
Copy the Published Content to the HTTP Web Server's Folder
cp -rf /home/ec2-user/blog/out/site/* /var/www/html/
Script to Update the Repository And Publish If Necessary
Create a script (for example, named pullPublish.sh) with the contents:
#! /bin/sh
cd /home/ec2-user/blog
git -C . remote update &> /dev/null
checkgit=`git -C . status`

if [[ ! "$checkgit" =~ "up to date" ]]; then
    # Pull
    git -C . pull
    # And publish
    sudo docker run -it -e LICENSE_KEY="$(</home/ec2-user/licensekey.txt)" -v /home/ec2-user/blog/:/src  oxygen-publishing-engine:1.0 -p /src/blog-project.xml -o /src/out -f webhelp-responsive -v
    # Move web site to web server's folder.
    rm -rf /var/www/html/*
    mv -f /home/ec2-user/blog/out/site/* /var/www/html/
fi
Schedule Script to Run Every 10 Minutes
Edit the crontab file:
cd /etc
sudo vi crontab
and add to the file:
*/10 * * * * /home/ec2-user/pullPublish.sh