### Dockerfile for Tiered Application Build and Optimization Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This Dockerfile provides a more advanced example for building a production-ready image optimized for startup. It copies core application files, then copies tier-specific configuration files, installs dependencies using `box install`, runs a custom setup script, removes build artifacts, and sets a specific healthcheck URI for server validation. ```dockerfile FROM ortussolutions/commandbox:lucee5 ARG CI_ENVIRONMENT_NAME # Copy application files to root COPY ./ ${APP_DIR}/ # Copy tier-only files over COPY ./build/env/${CI_ENVIRONMENT_NAME}/tier/ ${APP_DIR}/ # Install our box.json dependencies RUN cd ${APP_DIR} && box install # Warm up and validate our server RUN ${APP_DIR}/build/env/setup-env.sh # Remove our build directory from our deployable image RUN rm -rf ${APP_DIR}/build # Set our healthcheck to a non-framework route - in this case we only need to know that CFML pages are being served ENV HEALTHCHECK_URI "http://127.0.0.1:${PORT}/config/Routes.cfm" ``` -------------------------------- ### Customizing Docker Image with CommandBox Extension in Dockerfile Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This Dockerfile snippet shows how to build a custom image by extending a base CommandBox image. It demonstrates adding build arguments, installing a CommandBox package (like a cache extension) using `box install`, scoping argument values to environment variables for extension activation, and warming up the server to ensure the extension is active. ```dockerfile FROM ortussolutions/commandbox:lucee5 ARG REDIS_EMAIL ARG REDIS_LICENSE_KEY ARG REDIS_ACTIVATION_CODE # Install the Ortus Redis cache extension from Forgebox RUN box install 5C558CC6-1E67-4776-96A60F9726D580F1 # Scope in our args for extension activation REDIS_EXTENSION_EMAIL=$REDIS_EMAIL REDIS_EXTENSION_LICENSE_KEY=$REDIS_LICENSE_KEY REDIS_EXTENSION_ACTIVATION_CODE=$REDIS_ACTIVATION_CODE REDIS_EXTENSION_SERVER_TYPE=Production # WARM UP THE SERVER WITH THE NEW EXTENSION RUN ${BUILD_DIR}/util/warmup-server.sh ``` -------------------------------- ### Running CommandBox Docker Container - Bash Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This command runs a new Docker container from the CommandBox image, mapping local application code into the container and forwarding default HTTP/HTTPS ports. It starts the CommandBox server inside the container with the mounted application. ```bash docker run -p 8080:8080 -p 8443:8443 -v "/path/to/your/app:/app" ortussolutions/commandbox ``` -------------------------------- ### Finalizing Startup Script in Single-Stage Build - Dockerfile Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This Dockerfile shows how to generate the finalized startup script (`startup-final.sh`) within a single build stage. It temporarily sets the `FINALIZE_STARTUP` environment variable to `true`, executes the standard run script (`$BUILD_DIR/run.sh`) which will generate the finalized script instead of starting the server, and then unsets the variable. The resulting image contains the optimized startup script. ```Dockerfile FROM ortussolutions/commandbox:lucee5 # Generate the finalized startup script and exit RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP ``` -------------------------------- ### Creating Multi-Stage CommandBox Production Image - Dockerfile Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This Dockerfile defines a two-stage build. The first stage (`workbench`) uses the full CommandBox image to generate a finalized startup script and application files. The second stage (`app`) uses a minimal JRE image, copies the required files and the finalized script from the first stage, sets up the working directory, healthcheck, and entrypoint to use the generated script for faster startup. ```Dockerfile FROM ortussolutions/commandbox:lucee5 as workbench # Generate the startup script only ENV FINALIZE_STARTUP true RUN $BUILD_DIR/run.sh # Eclipse Temurin Focal image is the smallest OpenJDK image on that the same kernel used in the base image. # For most apps, this should work to run your applications FROM eclipse-temurin:11-jre-jammy as app # COPY our generated files COPY --from=workbench /app /app COPY --from=workbench /usr/local/lib/serverHome /usr/local/lib/serverHome RUN mkdir -p /usr/local/lib/CommandBox/lib COPY --from=workbench /usr/local/lib/CommandBox/lib/runwar-4.0.5.jar /usr/local/lib/CommandBox/lib/runwar-4.0.5.jar COPY --from=workbench /usr/local/bin/startup-final.sh /usr/local/bin/run.sh # Restore working directory environment ENV APP_DIR /app WORKDIR $APP_DIR # Restore the healthcheck, since that doesn't transfer from the first stage ENV HEALTHCHECK_URI "http://127.0.0.1:${PORT}/" HEALTHCHECK --interval=20s --timeout=30s --retries=15 CMD curl --fail ${HEALTHCHECK_URI} || exit 1 CMD /usr/local/bin/run.sh ``` -------------------------------- ### Basic Dockerfile for Copying Application Files Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This simple Dockerfile demonstrates extending a CommandBox base image and copying application source files from the build context into the container's application directory (`${APP_DIR}`). This is a basic approach for preparing an image with your application code. ```dockerfile FROM ortussolutions/commandbox:lucee5 # Copy application files to root COPY ./ ${APP_DIR}/ ``` -------------------------------- ### Running CommandBox Docker Container with Custom Ports - Bash Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This command runs a CommandBox Docker container, mapping local application code and forwarding custom HTTP/HTTPS ports. It also uses environment variables to configure the server inside the container to listen on the specified ports. ```bash docker run -p 80:80 -p 443:443 -e "PORT=80" -e "SSL_PORT=443" -v "/path/to/your/app:/app" ortussolutions/commandbox ``` -------------------------------- ### Using Docker Secrets with Prefix Placeholder in YAML Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This YAML snippet demonstrates how to configure a Docker service in `docker-compose.yml` to use a Docker secret by specifying a placeholder (`<>`) as the value for an environment variable. The secret's value is defined separately and sourced from a file, which is expanded at runtime. ```yaml version: '3.1' services: sut: environment: - IMAGE_TESTING_IN_PROGRESS=true #- ENV_SECRETS_DEBUG # uncomment to debug the placeholder replacements # this is a placeholder that will be replaced at runtime with the secret value - TEST_DOCKER_SECRET=<> ... secrets: test_docker_secret: # this is the file containing the secret value file: ./build/tests/secrets/test_docker_secret ``` -------------------------------- ### Pulling CommandBox Docker Image - Bash Source: https://github.com/ortus-solutions/docker-commandbox/blob/development/README.md This command pulls the latest version of the official CommandBox Docker image from Docker Hub to your local machine. It is the first step required before running a container based on this image. ```bash docker pull ortussolutions/commandbox ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.