Skip to content

Instantly share code, notes, and snippets.

@modius
Created November 9, 2015 05:45
Show Gist options
  • Save modius/cf759699ccaa40f1734b to your computer and use it in GitHub Desktop.
Save modius/cf759699ccaa40f1734b to your computer and use it in GitHub Desktop.
Daemonite Workbench Template Notes

Docker Workbench Template

Docker it up!

Move your FarCry application into a Docker based environment, by creating an environment project.

Project

TLDR;

  • Start with a completely blank git repo
  • Copy base templates
  • Update all submodules
  • configure nginx
  • start up environment
  • configure lucee app server
  • commit relevant changes

Environment Repo

Create a Git repo in the format CLIENT-env-PROJECT where:

  • CLIENT is the 3-5 letter short code for a client, and;
  • PROJECT is the name of the application or project

Set an origin for the repo at Bitbucket or Github.

Copy base templates

Look up a recent "best practice" project and copy across the static templates as the basis for the project.

For example, copy the following files from gpml-env-prime or chelsea-docker:

  • Vagrantfile
  • Dockerfile
  • ./config -- everything, except ./ssh and ./sql
  • ./logs -- just the empty directories with .gitignore
  • ./code/README.md
  • ./code/plugins/README.md
  • ./code/projects/README.md

Create submodules

Under the ./code directory create the following git submodules:

  • ./code/core for farcrycore/core
  • ./code/plugins/pluginname for each plugin used by the project
  • ./code/projects/projectname for the app project itself

Configure the NGINX web server

TLDR;

  • configure nginx server web root
  • enable lucee admin

Set the project www root

Edit the base NGINX config for your project at ./config/nginx/conf.d/default.conf

  • Update web server root to the farcry project www

For example:

root   /var/www/farcry/projects/gpml/www;

Expose Lucee admin for setup

The Lucee admin is blocked from public access by default as a security measure. You will need to temporarily remove this block in order to configure the Lucee server for your environment.

Comment out the /lucee location directive:

#location /lucee {
#	deny  all;
#}

Do not commit this change to version control, as we do not want it in production.

Set up Lucee application server

TLDR;

  • Update admin for mappings
  • copy configs into repo; lucee-web and lucee-server

Start up environment

Make sure everything is working at this point, and then configure Lucee admin.

$ vagrant up dockerhost
$ vagrant up lucee
$ open http://hostname:0000/lucee/admin/web.cfm

This will build the Docker images locally for the first time -- it has to transfer about 500Mb off the internet so be patient.

Login with password docker.

Update Mappings

Go to Lucee admin mappings. You will need to update the mapping for the webroot at / to match the location of your project webroot.

Update Datasource

Configure any datasources using environment ENV variables.

Create Lucee Configs

By default changing the Lucee admin should be updating your config/lucee/lucee-web.xml.cfm -- this will end up being the production Lucee config. Anything that is specific to an environment other than production should be specified using environment variables; for example, the datasources.

Keep mucking around here until you have your application working.

Commit changes to repo

Commit all your changes to the Git repo.

Make sure you discard the NGINX conf chunk that enables the Lucee admin; you do not want to expose the admin in production.

Troubleshooting

If you are running with the Daemon Workbench format you should be able to re-provision the virtual machine:

vagrant provision

Alternatively, you can log onto the Boot2Docker instance and interact with Docker directly.

vagrant ssh onto boot2docker and cleanup hanging containers/images:

docker rm $(docker ps -a -q) <-- remove all stopped containers
docker images -q --filter "dangling=true" | xargs docker rmi <-- remove all untagged images

Or the nuclear option:

docker rm -f $(docker ps -aq) <-- remove all containers
docker rmi -f $(docker images -q) <-- remove all images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment