My Elixir + Phoenix homepage, as deployed via Kubernetes.
The development environment uses Docker. This allows entire devleopment environments to be prebuilt and uploaded to the cloud. All you have to do is download the prebuilt images to your local machine and run them. Not bad, right?
First, install Docker by following the instructions for Mac, Linux, or Windows.
You'll also need Docker Compose, which is a convenient way to manage the several Docker containers required to run the app. We're using it here instead of Foreman, which you may be familiar with if you've done this Rails thing before. Mac and Windows users get Compose automatically with the Docker desktop kits, but Linux users will have to install it separately by running the following commands:
# Again, this is only necessary for Linux users
$ curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
# This should return 1.13.0
$ docker-compose --version
There is a Thor-based CLI which wraps most relevant Docker commands so you don't have to remember all the flags and switches. Since it runs on your local machine, you'll have to install Ruby and a gem locally to use it:
$ gem install dctl_rb
Download the prebuilt images to your local machine:
dctl pull
To allow database content to be persisted when the database image is destroyed, it must be saved on your local machine. Run this command to setup the database directories locally (this is a one-time thing--you won't have to do this again on your current machine).
dctl dbsetup
Almost there! Just run this command and you're up and running
dctl up
You should be able to visit localhost:4001 and see the app.
Also be sure to checkout the dctl_rb gem for more documentation and general tips for using docker in a development environment.
Secrets are stored encrypted in the repo. To decrypt them, you need the secret
key. It's stored as Secret access key [twitch]
in the Homepage
1password vault. Copy
it to your clipboard, then run this:
# Make sure you're in the app's root directory
pbpaste > apps/twitch/config/master.key
You can edit the secret file by running mix env.decrypt
and then opening
config/.env
with your editor.
When you're done, run mix env.encrypt
to regenerate config/.env.enc
with
your changes.