https://docs.docker.com/installation/
On OS X you can use Boot2Docker, or use Vagrant to spin up an empty Ubuntu machine (or whatever OS your production environment will run on).
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "docker"
config.vm.network :forwarded_port, host: 8080, guest: 8080
end
http://www.fig.sh/install.html
Fig allows you to write a configuration file to manage the building/running/linking of your docker images/containers. We'll be using this fig.yml
configuration for our project.
# fig.yml
web:
build: .
command: lapis server
ports:
- "8080:8080"
volumes:
- .:/code
links:
- postgres
redis:
image: postgres
Run lapis new
to create the basic configuration/applications files.
$ lapis new
wrote nginx.conf
wrote mime.types
wrote app.moon
We'll need to tell Lapis where/how to connect to the database. Since we're using the default port (5432), and user (postgres), we don't need to explicitly declare them in config.moon, but we will need to declare the database (postgres) which is the default database created by postgres.
-- config.moon
config = require "lapis.config"
config {"development", "production"}, ->
postgres ->
backend "pgmoon"
host "postgres"
database "postgres"
When linking one container to another, Docker automatically creates an entry in the hosts file of the main container pointing to the IP of the linked container. This allows us to use "postgres" as the database host in the config.moon file instead of its IP. The problem is that nginx's resolver does not use the /etc/hosts
file. So we'll need to figure out some other way to get the database IP, which I haven't figured out yet, stay tuned.
Run moonc -w .
to watch the directory for changes and compile .moon files to .lua