Home / DevOps Setup for Compiled Sites
DevOps Setup for Compiled Sites
Customize the Compilation Process (compile_site.sh)
By default, the compilation process follows the following steps:
Create a template from the site on the node compilation server. This includes the site, theme, and components used to compile the site, but does not include any content.
Compile the template. This will compile the site for each language that it’s been translated into as well as create detail pages for each content item it encounters during the compile.
Upload the compiled static files to the server as a single zip file. It will remove any existing static files before attempting the upload.
Publish the static files for the site. The site has already been published, so only the static files uploaded to the site are included in this job.
Once all the steps are done, the log for the compile is uploaded to the site in the server so that it can be downloaded from the site properties.
While this will work for all sites, you can take advantage of what you know about your site by creating a custom compile_site.sh file. This file can be used in various way, including:
- You may know that several components aren’t going to be compiled and so exclude those components. Or there are folders in the theme that aren’t required for compilation, so you don’t want to slow the compilation process by downloading those folders.
- You can take this further by compiling languages, or even pages, in parallel to speed up the compilation step. Or you could download the previously compiled pages and only compile a subset of pages for your site.
Develop Your compile_site.sh File
To customize the compilation flow, you can create your own compile_site.sh file. This file is uploaded to the site folder and, if it exists, will be used instead of the default compilation flow.
There’s a default version of this file available under your cec source folder:
cec-src/samples/compile_site.sh
Since the file runs cec
commands, it will need to be copied to the ‘cec-src’ folder.
Once you’ve copied the file, run it to compile your site:
./compile_site.sh --sitename sampleSite --server sampleServer --folder \pwd --channeltoken sampleChannelToken
If you run this command, it will run through the list of default steps above.
You can now edit this file and change how your site is compiled.
Include the Default Site Locale
When you compile a site, the default flow won’t include the default site locale in the URL. For example, if the default locale for your site was ‘es-MX’ when you compiled the site, you could access the site without including ‘es-MX’ in the URL.
However, if you are compiling for multiple locales, you may want ‘es-MX’ to be included.
This is handled with the --includeLocale
or -l
compilation option.
To include the default locale for your compilation, you would update the compile-template
command to include the -l
option:
cec compile-template ${TEMPLATE_NAME} -s ${REGISTERED_SERVER} -c ${CHANNEL_TOKEN} -n ${SITE_NAME} ${SECURE_SITE_OPTION} -t published -v -i -l > job1.log 2>&1 &
Parallel Compilation
There’s only one compile-template
command in the compile_site.sh file. You can extend this so that you can compile languages or pages in parallel in order to speed up the compilation step.
For example, to compile several languages in parallel, you can restrict each compilation to a subset of the available languages for the site. If your site was to be compiled in ‘de-DE,fr-FR,es-MX,zh-CN’, then you could create two compilation processes and wait until both complete before continuing. This can be done with the —localeGroupor -g
option, which will restrict each compilation to a subset of locales.
cec compile-template ${TEMPLATE_NAME} -s ${REGISTERED_SERVER} -c ${CHANNEL_TOKEN} -n ${SITE_NAME} ${SECURE_SITE_OPTION} -t published -v -i -g de-DE,fr-FR > job1.log 2>&1 &
cec compile-template ${TEMPLATE_NAME} -s ${REGISTERED_SERVER} -c ${CHANNEL_TOKEN} -n ${SITE_NAME} ${SECURE_SITE_OPTION} -t published -v -i -g ex-MX,zh-CN > job2.log 2>&1 &
You’ll also need to include the output from both job1.log and job2.log each run in the main log:
cat job1.log job2.log
rm -f job1.log job2.log
Use Your compile_site.sh File
Once you’ve developed and tested your compile_site.sh, to use your file when compiling a site, upload this file to the server using the cec upload-file
toolkit command:
cec upload-file ./compile_site.sh --folder site:sampleSite --server sampleServer
Once the file has been added to the root folder for the site, when the site is compiled from the web interface, this file will be used to compile the site.
To remove the file and return to the default behavior, use the cec delete-file
command:
cec delete-file site:sampleSite/compile_site.sh --server sampleServer
Use the Content Toolkit to Set Up CI/CD Pipeline
Coming soon…
Site Compilation Notes
Site compilation optimizes the overall site delivery experience by pre-generating HTML pages instead of constructing them with script in the client browser. There are a few things to keep in mind about site compilation, though, including:
- Site compilation servers are a shared resource. As such, they support queues of compilation jobs to process. It is possible for lengthy compilation jobs to consume the pool of compilation servers, causing subsequent jobs to wait until the previous jobs are finished. If this is a persistent issue in your environment, contact your Support representative.
- Depending upon the size of the site, compilation can take time. Performance can be improved by executing compilation tasks in parallel.
- Compilation jobs “time out” after 4 hours. If a compilation job takes longer than this, then it will be terminated.
DevOps Setup for Compiled Sites
July 2023
Copyright © 2021, 2023, Oracle and/or its affiliates.
Primary Author: Oracle Corporation