Does Lucee have a tool to compile files

Coldfusion comes with cfcompile.bat to compile code. Does Lucee have something similar

1 Like

Lucee does support creating archives via the admin, which are zip files that can be loaded as mappings

+1. It would be nice to have a method of triggering compilation of code in the webroot or specific paths/mappings.

It would allow us to trigger a compile during a Docker image build, then when the application is run nothing ever needs to be compiled during runtime on the servers. This would improve app startup time and reduce resource usage on servers when a container starts.

I’ve tried packaging an entire app as a Lucee archive, but I found the performance of the archive to be the same or very slightly slower (1-3%) than not using an archive and having “Inspect Templates” set to once. It seems that not using an archive and having “Inspect Templates” set to never gives a performance boost of up to about a 20%. It was quite a while ago I did these tests

So if we can have a nice pre-compilation option for builds, and if we can get Inspect Templates controllable via an environment variable so that it can easily be set to “never” (https://lucee.daemonite.io/t/configuring-settings-performance-caching/2331/6?u=justincarter) then we have a nice combination for having even better app startup/runtime performance :slight_smile:

1 Like

Someone started a CommandBox command to do just this once, but I think they never finished. The biggest issue with pre-compiled .cfm/c templates is the bytecode inside of them can be unique to a specific version of Lucee. That means code compile by Lucee x might not run on Lucee x-1 or x+1 which really limits the usefulness as a general purpose deployment mechanism for public libs.

Now, I would be interested in this feature for my own apps, but the lack of scriptability outside of a web based admin that requires a running server is so laughable I can’t even bring myself to bother trying. This has been pointed out and the dev team seems to have little interest in doing anything about it. And from what I’ve seen, there are serious issues with doing simple things like mapping a mapping to your web root and not just a sub folder. I’ve seen questions like that come and go on mailing lists with no official response which is enough to keep me at bay.

We do that on our Docker build… Whilst building we spin up Lucee and run a healthcheck that sets all the non-runtime information up, timezone, utf-8 etc, and one of the tasks is to add some mappings and compile the code.

public boolean function compileMapping (required string Mapping) output=false {
		local.Settings = {
			"Action": "compileMapping",
			"Type": "web",
			"Password": Variables.LuceePassword,
			"virtual": Arguments.Mapping,
			"stoponerror": 0
		};
		admin attributecollection=local.Settings;
		return true;
	}

Then we set the inspectTemplate to never

Nice one :slight_smile: Do you do that with a Server.cfc that you remove at the end of the build after you’re done with it, or do you have to put this in the application code / a Server.cfc that is always in your image?

Ideally it would be nice to have a method of doing this that doesn’t require any extra files or application code changes, nor the Lucee admin password. e.g RUN compile.sh.

No, in our Dockerfile we spin up Lucee and run our Healthcheck app

# Spin up lucee and run the healthcheck
RUN $CATALINA_HOME/bin/healthcheck.sh

Which then starts lucee and curls the healthcheck app.

In this app it then sets the server up, as I said pre-runtime stuff, which adds mappings, compiles, sets UTF etc.

The server then shuts down, the rest of the Dockerfile runs, basically sorting some rights out and making sure it’s not running as a root user. Then it’s ready for deployment.

The image is then deployed to staging/production and a similar healthcheck is called as part of the kubernetes readiness/liveness cycle that then sets up the runtime information such as datasources as this information can be passed in as environmentals.

1 Like

Ahh cool. That gives me a couple of ideas for uses of Server.cfc vs a separate Application scoped app to achieve different things.

I could have a play in the Lucee base image to see if there was an easy way to provide some generic hooks, but I’m also guessing that if you use mappings then you need to compile each of them, rather than just one folder like the webroot. The sticking point for me then is still the Lucee admin password to be able to use the cfadmin tag, as long as I can set it temporarily without affecting someone’s own Lucee server XML configuration then there’s probably a way forward, I’ll need to refresh my memory on whether we added Env vars / Java props for that. Don’t mind me, just thinking out loud here / writing things down for future reference really :slight_smile:

1 Like