intercity / intercity-next

Web control panel to deploy apps on your servers (with Dokku)
https://intercity.io/
MIT License
116 stars 23 forks source link

Initial attempt at Docker package #237

Closed michiels closed 4 years ago

michiels commented 6 years ago

This PR contains an initial prototype to package Intercity as a Docker stack. A simple Dockerfile has been added for hosting regular Rails apps with asset compilation. A docker-compose.yml file is added so that you can set up a full Intercity + Redis + Postgres stack while developing, but this can also be used while deploying.

The deployment direction this PR introduces in the future would be as follows:

  1. We publish intercity-next contaimer images to Docker Hub/store on every release.
  2. We provide a docker-compose.yml file (possibily as part of intercity-cli) to launch an Intercity instance which will pull down Redis, Postgres and run Intercity + the Sidekiq worker inside Intercity container.

How you can already use this PR:

  1. Install Docker for your platform. The official Docker Mac client is great.

  2. Start a local development Stack via:

    docker-compose run web rake db:create
    docker-compose run web rake db:schema:load
    docker-compose up
  3. Profit and view your local Intercity instance on http://localhost:3000

Happy to further discuss how we could take this further and what additional tooling/scripts/CLIs we might want to offer for easy installation and upgrading. I can imagine that:

intercity-server install

can just use docker-compose under the hood to get an Intercity environment up&running on a server.

jvanbaarsen commented 6 years ago

@michiels Interesting! Thanks for taking a stab at this. How would this deal with the configuration that we currently do in the app.yml from the intercity-docker package? For example setting up Let's Encrypt etc?

michiels commented 6 years ago

@jvanbaarsen As far as I can see now, all the configuration that happens in app.yml (looking at https://github.com/intercity/intercity-docker/blob/master/samples/app.yml) can (or should) be done in docker-compose.yml, most importantly setting the ENV vars.

michiels commented 6 years ago

Ah! Maybe one discussion comment regarding nginx/letsencrypt setup. I think the Intercity Docker image in itself should stay clear of what's running in front of it. We can offer the the installation CLI to install nginx or configure nginx and/or letsencrypt. So not by configuring those inside the container itself, but by allowing the host to manage this itself.

That way an Intercity instance can be easily ran alongside Dokku for example.

michiels commented 6 years ago

I've added to the docker-compose.yml a setup that should be fully production-worthy, including persistent storage for PostgreSQL and Redis.

jvanbaarsen commented 6 years ago

@michiels One of the design criteria for me with intercity-docker (The current one) was that no dependencies outside of Docker should be installed on the server. For me the preference would remain to keep that in place.

michiels commented 6 years ago

@jvanbaarsen Allright, we can discover that direction too by adding multiple dependencies to the same container. But you're going to have an nginx on the host system always if you want to allow multiple apps to be hosted on a server. So this new docker-compose thing takes the Docker philosophy into account that can also be launched on Docker Swarm setups. In the current intercity-docker it uses Docker more as a package manager instead of using Docker's fundamentals.

I would say we can just prototype various directions and see which one works best. We can also have two flavors run side-by-side.

jvanbaarsen commented 6 years ago

@michiels Yep sounds good. If it's ok with you I want to keep this PR open so I can test run this locally also. I probably have time for this next week.

michiels commented 6 years ago

@jvanbaarsen Yes that's fine. This PR is not meant to be quickly reviewed and closed, but to propose a direction we can test over time.

jvanbaarsen commented 6 years ago

@michiels Ok cool :-) Let's see how we can iterate over this :-) I would love to get rid of intercity-docker at some point.

michiels commented 6 years ago

@jvanbaarsen I think with this way, upgrading and installing Intercity is very easy. What I imagine a CLI to do:

  1. Ask you (or show you how) to configure your setup by configuring the ENV vars
  2. Run docker-compose to launch the Intercity stack
  3. Set up (or use currently installed) an nginx with LetsEncrypt in front of it

We can still debate wether nginx should be run from inside the Intercity container or from a different container or on the host. That last option would be the ideal Dockerized way of working.

For the end user there would be no difference, other than perhaps the bonus to run Intercity alongside of other applications on the server.

michiels commented 6 years ago

@jvanbaarsen One thing that's quite cool to already try out is local development. I'll push a commit to a seperate branch in a bit where you can use this Docker Compose file for local development.

That means that someone only has to have Docker installed on their local machine, and have the Git repo checked oud. No need to install Redis, Postgres or even run bundler. You can just do docker-compose run -P 3000:3000 web and you will have an instant fully-fledged dev environment with Redis and PG setup.