Blog Archives - 1 Record(s)

Remove Filter Year: '2024' - Month: '5'

CommandBox 6 Multisite Docker with MOD_CFML

Follow along in the video https://www.youtube.com/watch?v=eVmMw5TAwcc

Clone this repo: https://github.com/ortus-Solutions/docker-commandbox

git clone https://github.com/ortus-Solutions/docker-commandbox

We first need to modify the install-commandbox.sh. file located in build/util/install-commandbox.sh

On around line 25 you will see box config set server.singleServerMode=true we need to change that to false:

box config set server.singleServerMode=false

On around line 29 just after the initial box conf set server.daults... add the following:

box server set ModCFML.enable=true
box server set ModCFML.sharedKey=my-secret
box server set web.ajp.enable=true web.ajp.port=8009

NOTE: You need to make note of the sharedKey as it will be used later and I HIGHLY suggest you change this shareKey for security reasons.


The next step is to get the docker image up on dockerhub.io. You will need an account there, please sign up at https://hub.docker.com/ You can skip this step if you're familiar with Docker and know how to pull the image locally

From the terminal in the same folder as the git repo above enter the following to build the docker image.

docker build -f builds/debian/Lucee5.Dockerfile -t YOURUSERNAME/mycommandbox . --build-arg COMMANDBOX_VERSION=6.0.1

Next you will need to login to docker from the terminal using docker login, enter your credentials and now you're ready to push your image.

To push your image type in docker push YOURUSERNAME/mycommandbox

Your image should now appear on Docker Hub.

For the next steps I'm going to use a program called Portainer. Instructions for getting this installed in docker can be found at https://docs.portainer.io/start/install-ce/server/docker/linux

Copy the lucee.conf, and lucee-proxy.conf file from https://viviotech.github.io/mod_cfml/install-nginx.html into the /var/www/nginx/ directory.

You then need to create your sites config in /var/nginx/conf.d/

sample site1.com.conf file

server {
  listen 80;
  server_name site1.com;
  root /var/www/site1.com/;

  set $lucee_context "site1.com";
  include lucee.conf;
}

You need to create a new stack in portainer with the following information.

version: '3.4'    
services:
  web:
    image: nginx
    volumes:
      - /var/nginx/conf.d/:/etc/nginx/conf.d/
      - /var/nginx/lucee.conf:/etc/nginx/lucee.conf
      - /var/nginx/lucee-proxy.conf:/etc/nginx/lucee-proxy.conf
      - /var/www/:/var/www/

    ports:
      - 80:80
      - 443:443
  app:
    image: YOURUSERNAME/mycommandbox

    # Ports
    ports:
      - 8885:8080
    volumes:
      - /var/www/:/var/www/
      
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:8080/"]
      interval: 30s
      timeout: 10s
      retries: 5
#      start_period: 180s
      
      # Deployment Configuration
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 0s
        failure_action: continue
        order: start-first
      restart_policy:
        condition: on-failure
        delay: 5s

*IMPORTANT: Be sure to check your image on docker hub to make sure it's private and not public. You should also setup appropriate firewalls on DigitalOcean droplet

USE THIS AS A GUIDE ONLY. IT COMES WITHOUT WARRANTY