Lucee Docker File breakdown: lucee/lucee51-nginx


#1

LAS provides a series of official Docker images for the Lucee server running on Apache Tomcat. They’re production ready, and are used daily by teams to serve Lucee based solutions.

You can rely on these base images within your own project, or copy the approach as a starting point for building your own image from scratch. As the maintainers of the images, we thought it might be helpful to breakdown the reasoning behind the layers.

Dockerfile for Lucee 5.1 with NGINX

This popular Docker image incorporates a Debian / OpenJDK / Apache Tomcat stack with Lucee server and NGINX web server installed. We also have a vanilla Lucee image without NGINX you might find interesting.

FROM lucee/lucee51:latest

MAINTAINER Daemonites <hello@daemon.com.au>

# Install nginx and supervisord
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
RUN echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list
RUN apt-get update && \
	DEBIAN_FRONTEND=noninteractive apt-get install -y \
		nginx \
		supervisor && \
	apt-get clean && \
	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Copy default nginx config files
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/

# Copy supervisord.conf
COPY supervisord.conf /etc/supervisor/conf.d/

# Provide test page
RUN mkdir -p /var/www
COPY index.cfm /var/www/
ONBUILD RUN rm -rf /var/www/*

# Expose HTTP and HTTPS ports
EXPOSE 80 443

# Engage
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]

Let’s break it all down.

Based off the Lucee image

FROM lucee/lucee51:latest
MAINTAINER Daemonites <hello@daemon.com.au>

The compound image uses the lucee/lucee51 as a base image.

Install NGINX

# Install nginx and supervisord
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
RUN echo "deb http://nginx.org/packages/debian/ jessie nginx" >> /etc/apt/sources.list
RUN apt-get update && \
	DEBIAN_FRONTEND=noninteractive apt-get install -y \
		nginx \
		supervisor && \
	apt-get clean && \
	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Nothing special here just a straight up install of NGINX for Debian.

# Copy default nginx config files
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/

Our default NGINX configs secure the Lucee admin and proxy requests for CFML to Lucee on Tomcat. It’s very common to override one or all of these in your project Dockerfile.

The magic of Supervisor

# Copy supervisord.conf
COPY supervisord.conf /etc/supervisor/conf.d/

Containers are only supposed to run one process. Supervisor is the magic process that runs the other two processes; Tomcat/Lucee and NGINX.

We also set up some handy logging settings to push combined console logs to the containers STDOUT.

Build Test Page

# Provide test page
RUN mkdir -p /var/www
COPY index.cfm /var/www/
ONBUILD RUN rm -rf /var/www/*

We create a simple test page to assist in the build process; it helps to be able to see if the server is running properly. Note, the ONBUILD command deletes this page as soon as you use the image to build your own project.

Expose Ports

# Expose HTTP and HTTPS ports
EXPOSE 80 443

We open ports 80 and 443 for traffic through to NGINX.

Start-up Supervisord

# Engage
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]

When the container spins up with start the Supervisor process that in turn takes care of Tomcat and NGINX.


Lucee Docker File breakdown: lucee/lucee51
#4

#5