Skip to content

jutonz/homepage

Repository files navigation

My Elixir + Phoenix homepage, as deployed via Kubernetes.

Getting started

1. Install Docker

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

2. Install the CLI

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

3. Pull images and setup the database

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

4. Finally, start the app

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.

Secret management

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. Fill in the secret by running this:

  # Make sure you're in the app's root directory
  echo -n "[secret-key]" > apps/twitch/config/master.key

Editing secrets

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.