Home > Software engineering >  Docker-Compose with Commandbox cannot change web root
Docker-Compose with Commandbox cannot change web root

Time:02-25

I'm using docker-compose to launch a commandbox lucee container and a mysql contianer.

I'd like to change the web root of the lucee server, to keep all my non-public files hidden (server.json etc, cfmigrations resources folder)

I've followed the docs and updated my server.json directory listing of /app folder

This is my project structure:

project structure

It seems like the server.json file is being ignored or at least the web.webroot property, but I've tried both of these settings, and neither solve the problem

- APP_DIR=/app/public
- BOX_SERVER_WEB_WEBROOT=/app/public

The commandbox docs suggest changing APP_DIR to fix the web root, "APP_DIR - Application directory (web root)." https://hub.docker.com/r/ortussolutions/commandbox/

But if I do that, I get an error about the startup script being in the wrong place, which to me looks like it should be fixed: https://github.com/Ortus-Solutions/docker-commandbox/issues/55

The BOX_SERVER_WEB_WEBROOT is in the same way server.json is (or at least that property). I've tried setting the following env vars as well (both upper and lower case) and it makes no diffence, but bear in mind server.json changes the webroot for me whe

  • BOX_SERVER_WEB_WEBROOT=./public
  • BOX_SERVER_WEB_WEBROOT=/app/public
  • BOX_SERVER_WEB_WEBROOT=public

The output as the web container starts up:

Set verboseErrors = true

INFO: CF Engine defined as [email protected] 189

INFO: Convention .cfconfig.json found at /app/.cfconfig.json

INFO: Server Home Directory set to: /usr/local/lib/serverHome

 √ | Installing ALL dependencies

   | √ | Installing package [forgebox:[email protected]]

   | √ | Installing package [forgebox:[email protected]]

   |   | √ | Installing package [forgebox:cfmigrations@^2.0.0]

   |   |   | √ | Installing package [forgebox:qb@^8.0.0]

   |   |   |   | √ | Installing package [forgebox:cbpaginator@^2.4.0]

  [[ -n '' ]]

  [[ -n '' ]]

INFO: Generating server startup script

 √ | Starting Server

   |------------------------------

   | start server in - /app/

   | server name - app

   | server config file - /app//server.json

   | WAR/zip archive already installed.

   | Found CFConfig JSON in ".cfconfig.json" file in web root by convention

   | .

   | Importing luceeserver config from [/app/.cfconfig.json]

   | Config transferred!

   | Setting OS environment variable [cfconfig_adminPassword] into luceeser

   | ver

   | [adminPassword] set.

   | Setting OS environment variable [cfconfig_robustExceptionEnabled] into

   |  luceeserver

   | [robustExceptionEnabled] set.

   | Start script for shell [bash] generated at: /app/server-start.sh

   | Server start command: 

   |     /opt/java/openjdk/bin/java 

   |     -jar /usr/local/lib/CommandBox/lib/runwar-4.5.1.jar 

   |     --background=false 

   |     --host 0.0.0.0 

   |     --stop-port 42777 

   |     --processname app [lucee 5.3.8 189] 

   |     --log-dir /usr/local/lib/serverHome//logs 

   |     --server-name app 

   |     --tray-enable false 

   |     --dock-enable true 

   |     --directoryindex true 

   |     --timeout 240 

   |     --proxy-peeraddress true 

   |     --cookie-secure false 

   |     --cookie-httponly false 

   |     --pid-file /usr/local/lib/serverHome//.pid.txt 

   |     --gzip-enable true 

   |     --cfengine-name lucee 

   |     -war /app/ 

   |     --web-xml-path /usr/local/lib/serverHome/WEB-INF/web.xml 

   |     --http-enable true 

   |     --ssl-enable true 

   |     --ajp-enable false 

   |     --http2-enable true 

   |     --open-browser false 

   |     --open-url https://0.0.0.0:443 

   |     --port 80 

   |     --ssl-port 443 

   |     --urlrewrite-enable false 

   |     --predicate-file /usr/local/lib/serverHome//.predicateFile.txt

   | Dry run specified, exiting without starting server.

   |------------------------------

   | √ | Setting Server Profile to [production]

   |   |-----------------------------------------------------

   |   | Profile set from secure by default

   |   | Block CF Admin disabled

   |   | Block Sensitive Paths enabled

   |   | Block Flash Remoting enabled

   |   | Directory Browsing enabled

   |   |-----------------------------------------------------

INFO: Starting server using generated script: /usr/local/bin/startup.sh

[INFO ] runwar.server: Starting RunWAR 4.5.1

[INFO ] runwar.server: HTTP2 Enabled:true

[INFO ] runwar.server: Enabling SSL protocol on port 443

[INFO ] runwar.server: HTTP ajpEnable:false

[INFO ] runwar.server: HTTP warFile exists:true

[INFO ] runwar.server: HTTP warFile isDirectory:true

[INFO ] runwar.server: HTTP background:false

[INFO ] runwar.server: Adding additional lib dir of: /usr/local/lib/serverHome/WEB-INF/lib

[INFO ] runwar.server: ******************************************************************************

[INFO ] runwar.server: Starting - port:80 stop-port:42777 warpath:file:/app/

[INFO ] runwar.server: context: /  -  version: 4.5.1

[INFO ] runwar.server: web-dirs: ["\/app"]

[INFO ] runwar.server: Log Directory: /usr/local/lib/serverHome/logs

[INFO ] runwar.server: ******************************************************************************

[INFO ] runwar.server: XNIO-Option CONNECTION_LOW_WATER:1000000

[INFO ] runwar.server: XNIO-Option CORK:true

[INFO ] runwar.server: XNIO-Option WORKER_TASK_MAX_THREADS:30

[INFO ] runwar.server: XNIO-Option WORKER_IO_THREADS:8

[INFO ] runwar.server: XNIO-Option TCP_NODELAY:true

[INFO ] runwar.server: XNIO-Option WORKER_TASK_CORE_THREADS:30

[INFO ] runwar.server: XNIO-Option CONNECTION_HIGH_WATER:1000000

[INFO ] runwar.config: Parsing '/usr/local/lib/serverHome/WEB-INF/web.xml'

[INFO ] runwar.server: Extensions allowed by the default servlet for static files: 3gp,3gpp,7z,ai,aif,aiff,asf,asx,atom,au,avi,bin,bmp,btm,cco,crt,css,csv,deb,der,dmg,doc,docx,eot,eps,flv,font,gif,hqx,htc,htm,html,ico,img,ini,iso,jad,jng,jnlp,jpeg,jpg,js,json,kar,kml,kmz,m3u8,m4a,m4v,map,mid,midi,mml,mng,mov,mp3,mp4,mpeg,mpeg4,mpg,msi,msm,msp,ogg,otf,pdb,pdf,pem,pl,pm,png,ppt,pptx,prc,ps,psd,ra,rar,rpm,rss,rtf,run,sea,shtml,sit,svg,svgz,swf,tar,tcl,tif,tiff,tk,ts,ttf,txt,wav,wbmp,webm,webp,wmf,wml,wmlc,wmv,woff,woff2,xhtml,xls,xlsx,xml,xpi,xspf,zip,aifc,aac,apk,bak,bk,bz2,cdr,cmx,dat,dtd,eml,fla,gz,gzip,ipa,ia,indd,hey,lz,maf,markdown,md,mkv,mp1,mp2,mpe,odt,ott,odg,odf,ots,pps,pot,pmd,pub,raw,sdd,tsv,xcf,yml,yaml

[INFO ] runwar.server: welcome pages in deployment manager: [index.cfm, index.lucee, index.html, index.htm]

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender (file:/usr/local/lib/serverHome/WEB-INF/lib/lucee.jar) to method java.net.URLClassLoader.addURL(java.net.URL)

WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

[INFO ] runwar.server: Direct Buffers: true

[INFO ] runwar.server: ******************************************************************************

[INFO ] runwar.server: *** starting 'stop' listener thread - Host: 0.0.0.0 - Socket: 42777

[INFO ] runwar.server: ******************************************************************************

[INFO ] runwar.server: Server is up - http-port:80 https-port:443 stop-port:42777 PID:286 version 4.5.1

This is all fairly new to me so I might have done something completely wrong, I'm wondering if it's a problem with the folder nesting, although I've tried rearranging it and can't come up with a working solution.

CodePudding user response:

You're using a pre-warmed image

image: ortussolutions/commandbox:lucee5

That means the server has already been started and "locked in" to all its settings, including the web root. Use the vanilla commandbox image that has never had a server started, that way when you warm up the image, you'll be starting it with your settings the first time.

To set a custom web root, you'll want to add this to your docker file

ENV APP_DIR=/app/public
  • Related