Skip to content

Commit

Permalink
update to ContentBox 6 and use a single Dockerfile+matrix for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed Dec 20, 2023
1 parent 77cc5af commit 64bced0
Show file tree
Hide file tree
Showing 32 changed files with 1,012 additions and 661 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ jobs:
strategy:
matrix:
include:
- BUILD_IMAGE_DOCKERFILE : Dockerfile
- BASE_IMAGE: ortussolutions/commandbox
BUILD_IMAGE_TAG: latest
- BUILD_IMAGE_DOCKERFILE : variants/Lucee5.Dockerfile
CFENGINE: [email protected]+38
- BASE_IMAGE: ortussolutions/commandbox
BUILD_IMAGE_TAG: lucee5
- BUILD_IMAGE_DOCKERFILE : variants/Adobe2016.Dockerfile
BUILD_IMAGE_TAG: adobe2016
- BUILD_IMAGE_DOCKERFILE : variants/Adobe2018.Dockerfile
CFENGINE: [email protected]+38
- BASE_IMAGE: ortussolutions/commandbox:adobe2018
BUILD_IMAGE_TAG: adobe2018
- BUILD_IMAGE_DOCKERFILE : variants/Adobe2021.Dockerfile
CFENGINE: adobe@2018
- BASE_IMAGE: ortussolutions/commandbox:adobe2021
BUILD_IMAGE_TAG: adobe2021

CFENGINE: adobe@2021
- BASE_IMAGE: ortussolutions/commandbox:adobe2023
BUILD_IMAGE_TAG: adobe2023
CFENGINE: adobe@2023
# Alpine builds
# Note: No JDK builders currently support alpine with ARM
- BUILD_IMAGE_DOCKERFILE : variants/Alpine.Dockerfile
- BASE_IMAGE: ortussolutions/commandbox:alpine
BUILD_IMAGE_TAG: alpine
CFENGINE: [email protected]+38
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -47,7 +52,7 @@ jobs:
env:
DOCKER_IMAGE : ortussolutions/contentbox
BUILD_IMAGE_TAG: ${{ matrix.BUILD_IMAGE_TAG }}
IMAGE_VERSION: 5.6.1
IMAGE_VERSION: 6.0.1
run: |
# Tag Builds
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand Down
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Seed it on a specific CommandBox Image Version
# https://hub.docker.com/r/ortussolutions/commandbox/tags
FROM ortussolutions/commandbox
ARG BASE_IMAGE=ortussolutions/commandbox
FROM ${BASE_IMAGE}

# Labels
LABEL version="@version@"
Expand All @@ -9,8 +10,9 @@ LABEL maintainer "Luis Majano <[email protected]>"
LABEL repository "https://github.com/Ortus-Solutions/docker-contentbox"

# Incoming Secrets/Vars From Build Process
ARG IMAGE_VERSION=5.6.0
ARG IMAGE_VERSION=6.0.1
ARG TAGS=ortussolutions/contentbox:test
ARG [email protected]+38

# Copy over our app resources which brings lots of goodness like session distribution,
# db env vars, caching, etc.
Expand All @@ -28,8 +30,11 @@ RUN ${BUILD_DIR}/contentbox/contentbox-setup.sh
# ContentBox Run
CMD ${BUILD_DIR}/contentbox/contentbox-run.sh

# WARM UP THE SERVER
RUN ${BUILD_DIR}/util/warmup-server.sh

# Healthcheck environment variables
ENV HEALTHCHECK_URI "http://127.0.0.1:${PORT}/index.cfm"

# Our healthcheck interval doesn't allow dynamic intervals - Default is 20s intervals with 15 retries
HEALTHCHECK --interval=30s --timeout=30s --retries=2 --start-period=60s CMD curl --fail ${HEALTHCHECK_URI} || exit 1
HEALTHCHECK --interval=30s --timeout=30s --retries=2 --start-period=60s CMD curl --fail ${HEALTHCHECK_URI} || exit 1
22 changes: 21 additions & 1 deletion build/contentbox-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,27 @@ rm -f ${APP_DIR}/server.json

# Copy over our resources
echo ">INFO: Copying over ContentBox Container Overrides"
cp -rvf ${BUILD_DIR}/contentbox-app/* ${APP_DIR}
cp -rvf ${BUILD_DIR}/contentbox-app/config/* ${APP_DIR}/config/
cp -vf ${BUILD_DIR}/contentbox-app/Application.cfc ${APP_DIR}/Application.cfc

SERVER_FILE=${BUILD_DIR}/contentbox-app/engines/[email protected]

case $CFENGINE in

adobe@2018)
SERVER_FILE=${BUILD_DIR}/contentbox-app/engines/[email protected]
;;

adobe@2021)
SERVER_FILE=${BUILD_DIR}/contentbox-app/engines/[email protected]
;;

adobe@2023)
SERVER_FILE=${BUILD_DIR}/contentbox-app/engines/[email protected]
;;
esac

cp -vf $SERVER_FILE ${APP_DIR}/server.json

# Debug the App Dir
#echo "Final App Dir"
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

----
## [6.0.1] - Unreleased

## [5.6.1] - Unreleased
### Changed
* Updated Lucee Engine to 5.3.9
* Moved ACF2021 CFPM_INSTALL environment variable to before server warmup, to make sure extensions are seeded

## [5.6.0] - 2022-03-12

Expand Down
136 changes: 49 additions & 87 deletions resources/app/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@
* Application Bootstrap
*/
component {
/**
* --------------------------------------------------------------------------
* NON COMMANDBOX INSTALLS
* --------------------------------------------------------------------------
* If you are NOT using CommandBox as your server, then set the variable to true
* and ContentBox will load the `.env` environment file that is needed for operation.
* Without this, your NON CommandBox ContentBox install will fail.
*/
this._loadDynamicEnvironment = false;

request.$coldboxUtil = new coldbox.system.core.util.Util();
request.$envHelper = new coldbox.system.core.delegates.Env();

/**
* --------------------------------------------------------------------------
* Application Properties: Modify as you see fit!
* --------------------------------------------------------------------------
*/
// Application properties, modify as you see fit
this.name = "ContentBox-Docker-" & request.$coldboxUtil.getSystemSetting( "hostname", "" );
this.name = "ContentBox-Docker-" & request.$envHelper.getSystemSetting( "hostname", "" );
this.sessionManagement = true;
this.sessionTimeout = createTimespan( 0, 1, 0, 0 );
this.setClientCookies = true;
Expand All @@ -39,7 +30,7 @@ component {
* --------------------------------------------------------------------------
*/

// buffer the output of a tag/function body to output in case of a exception
// buffer the output of a tag/function body to output in case of a exception
this.bufferOutput = true;
// Activate Gzip Compression
this.compression = false;
Expand All @@ -54,18 +45,19 @@ component {
* --------------------------------------------------------------------------
* Modify only if you need to, else default them.
*/
COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() );
COLDBOX_APP_MAPPING = "";
COLDBOX_CONFIG_FILE = "";
COLDBOX_APP_KEY = "";
COLDBOX_FAIL_FAST = true;
COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() );
COLDBOX_APP_MAPPING = "";
COLDBOX_WEB_MAPPING = "";
COLDBOX_CONFIG_FILE = "";
COLDBOX_APP_KEY = "";
COLDBOX_FAIL_FAST = true;

/**
* --------------------------------------------------------------------------
* Location Mappings
* --------------------------------------------------------------------------
* - cbApp : Quick reference to root application
* - coldbox : Where ColdBox library is installed
* - cbApp : Quick reference to this application root
* - coldbox : Where ColdBox is installed
* - contentbox : Where the ContentBox module root is installed
* - cborm : Where the cborm library is installed: Needed for ORM Event Handling.
*/
Expand All @@ -74,6 +66,11 @@ component {
this.mappings[ "/contentbox" ] = COLDBOX_APP_ROOT_PATH & "modules/contentbox";
this.mappings[ "/cborm" ] = this.mappings[ "/contentbox" ] & "/modules/contentbox-deps/modules/cborm";

/**
* Custom Datasource Dynamic configs before ORM definitions exist.
**/
include "config/datasourceMixins.cfm";

/**
* --------------------------------------------------------------------------
* ORM + Datasource Settings
Expand All @@ -83,18 +80,8 @@ component {
* So Make sure you select one.
*/

/**
* Custom Datasource Dynamic configs before ORM definitions exist.
**/
include "config/datasourceMixins.cfm";

// Normal ContentBox ENV Loading
if( this._loadDynamicEnvironment ){
loadEnv();
}

// THE CONTENTBOX DATASOURCE NAME
this.datasource = request.$coldboxUtil.getSystemSetting( "DATASOURCE_NAME", "contentbox" );
this.datasource = request.$envHelper.getSystemSetting( "DATASOURCE_NAME", "contentbox" );
// ORM SETTINGS
this.ormEnabled = true;
// cfformat-ignore-start
Expand All @@ -106,16 +93,18 @@ component {
// The ContentBox Core Entities
"modules/contentbox/models",
// Custom Module Entities
"modules_app"
"modules_app",
// Custom Module User Entities
"modules/contentbox/modules_user"
],
// THE DIALECT OF YOUR DATABASE OR LET HIBERNATE FIGURE IT OUT, UP TO YOU TO CONFIGURE.
dialect : request.$coldboxUtil.getSystemSetting( "ORM_DIALECT", "" ),
dialect : request.$envHelper.getSystemSetting( "ORM_DIALECT", "" ),
// DO NOT REMOVE THE FOLLOWING LINE OR AUTO-UPDATES MIGHT FAIL.
dbcreate : "update",
secondarycacheenabled : request.$coldboxUtil.getSystemSetting( "ORM_SECONDARY_CACHE", false ),
cacheprovider : request.$coldboxUtil.getSystemSetting( "ORM_SECONDARY_CACHE", "ehCache" ),
logSQL : request.$coldboxUtil.getSystemSetting( "ORM_LOGSQL", false ),
sqlScript : request.$coldboxUtil.getSystemSetting( "ORM_SQL_SCRIPT", "" ),
secondarycacheenabled : request.$envHelper.getSystemSetting( "ORM_SECONDARY_CACHE", false ),
cacheprovider : request.$envHelper.getSystemSetting( "ORM_SECONDARY_CACHE", "ehCache" ),
logSQL : request.$envHelper.getSystemSetting( "ORM_LOGSQL", false ),
sqlScript : request.$envHelper.getSystemSetting( "ORM_SQL_SCRIPT", "" ),
// ORM SESSION MANAGEMENT SETTINGS, DO NOT CHANGE
flushAtRequestEnd : false,
autoManageSession : false,
Expand All @@ -131,44 +120,43 @@ component {

/************************************** METHODS *********************************************/

// application start
public boolean function onApplicationStart(){
// Set a high timeout for any orm updates
boolean function onApplicationStart(){
setting requestTimeout ="300";
application.cbBootstrap= new coldbox.system.Bootstrap(
COLDBOX_CONFIG_FILE,
COLDBOX_APP_ROOT_PATH,
COLDBOX_APP_KEY,
COLDBOX_APP_MAPPING
COLDBOX_APP_MAPPING,
COLDBOX_FAIL_FAST,
COLDBOX_WEB_MAPPING
);
application.cbBootstrap.loadColdbox();
return true;
}

// request start
public boolean function onRequestStart( string targetPage ){
boolean function onRequestStart( string targetPage ){
// In case bootstrap or controller are missing, perform a manual restart
if (
!structKeyExists( application, "cbBootstrap" )
isNull( application.cbBootstrap )
||
!structKeyExists( application, "cbController" )
isNull( application.cbController )
) {
if( this._loadDynamicEnvironment ){
loadEnv( force : true );
if ( this.cbLoadDynamicEnvironment ) {
loadEnv( force: true );
}
reinitApplication();
}

// Development Reinit + ORM Reloads
if (
structKeyExists( application, "cbController" )
!isNull( application.cbController )
&&
application.cbController.getSetting( "environment" ) == "development"
&&
application.cbBootstrap.isFWReinit()
) {
if( this._loadDynamicEnvironment ){
loadEnv( force : true );
if ( this.cbLoadDynamicEnvironment ) {
loadEnv( force: true );
}
if ( structKeyExists( server, "lucee" ) ) {
pagePoolClear();
Expand All @@ -182,59 +170,33 @@ component {
return true;
}

public void function onSessionStart(){
if ( structKeyExists( application, "cbBootstrap" ) ) {
function onSessionStart(){
if ( !isNull( application.cbBootstrap ) ) {
application.cbBootStrap.onSessionStart();
}
}

public void function onSessionEnd( struct sessionScope, struct appScope ){
function onSessionEnd( struct sessionScope, struct appScope ){
arguments.appScope.cbBootStrap.onSessionEnd( argumentCollection = arguments );
}

public boolean function onMissingTemplate( template ){
boolean function onMissingTemplate( template ){
return application.cbBootstrap.onMissingTemplate( argumentCollection = arguments );
}

function onApplicationEnd( struct appScope ){
arguments.appScope.cbBootstrap.onApplicationEnd( arguments.appScope );
}

/*****************************************************************************************************/
/************************************** APP HELPERS **************************************************/
/*****************************************************************************************************/

/**
* Application Reinitialization
**/
private void function reinitApplication(){
// Run onAppStart
onApplicationStart();
}

/**
* This method is only called if you are in a NON CommandBox install.
*/
private void function loadEnv( boolean force = false){
var javaSystem = createObject( "java", "java.lang.System" );
var value = javaSystem.getProperty( "contentbox_runtime_env" );
// If not loaded, lock and load.
if ( isNull( value ) || arguments.force ) {
lock
name="contentbox_runtime_env"
timeout="15"
throwOnTimeout="true"
type="exclusive"
{
// Double lock
if( isNull( javaSystem.getProperty( "contentbox_runtime_env" ) ) || arguments.force ){
// Load .env file
var props = createObject( "java", "java.util.Properties" ).init();
props.load(
createObject( "java", "java.io.FileInputStream" ).init( expandPath( "/.env" ) )
);
// Iterate and add
var availableProps = props.propertyNames();
while( availableProps.hasNext() ){
var propName = availableProps.next();
javaSystem.setProperty( propName, props.getProperty( propName ) );
}
javaSystem.setProperty( "contentbox_runtime_env", true );
} // end double lock
} // end lock
} // end lock check
}

}
23 changes: 23 additions & 0 deletions resources/app/config/Application.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!---
********************************************************************************
ContentBox - A Modular Content Platform
Copyright 2012 by Luis Majano and Ortus Solutions, Corp
www.ortussolutions.com
********************************************************************************
Apache License, Version 2.0
Copyright Since [2012] [Luis Majano and Ortus Solutions,Corp]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************** --->
<cfabort>
Loading

0 comments on commit 64bced0

Please sign in to comment.