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

Docker Compose for local development #238

Closed michiels closed 5 years ago

michiels commented 6 years ago

This PR is an addition to #237 and updates the proposed docker-compose.yml file to work for local Intercity development.

This would mean that you don't have to install & configure Redis or Postgresql to run and develop Intercity locally. This is because the current working directory with the Git repository is mounted in the app directory in the container to run. So any changes you make on your local harddrive will be applied in the running container. Result: instant dev environment!

How it works:

  1. Have Docker installed for your platform
  2. Pull down the Git repository and switch to this branch
  3. Run this command to start your local dev environment:

    $ docker-compose run -p 3000:3000 web
  4. Profit! You'll keep seeing the output from the local Puma server for debugging.

No need to have Postgres or Redis running on your host machine. Also benefit: Your Redis DB won't be shared between apps anymore so you always have a clean Redis queue for your Sidekiq jobs..

If you also want to start Redis:

$ docker-compose run sidekiq

Changes

Todo

jvanbaarsen commented 6 years ago

@michiels Looks great! Can you add a few steps to the README on how to get this running for your local dev? Also can you explain how the following works:

michiels commented 6 years ago

@jvanbaarsen Yep! Good one. Will add a "Developing via Docker" or something like that to the README.

jvanbaarsen commented 6 years ago

@michiels Can you also add a line to the CHANGELOG?

michiels commented 6 years ago

@jvanbaarsen Check out my latest changes. There's quite some commits after me testing all regular Rails commands to be executed like running tests, doing db migrations and modifying the Gemfile.

I've chosen to explain in README.md that you can take the route to open up a shell session in the local development container. That is the fastest/easiest way for many people to use the regular rails commands without having to type docker-compose for commands like docker-compose run web rails db:migrate all the time. Keeping one shell session to the container open while developing also reduced the need to stop/start the container all the time when you would run only individual commands in them.

jvanbaarsen commented 6 years ago

@michiels I just tried running the container but got this error when doing the first docker-compose:

--2018-01-16 08:52:36--  https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Connecting to bitbucket.org (bitbucket.org)|104.192.143.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://bbuseruploads.s3.amazonaws.com/fd96ed93-2b32-46a7-9d2b-ecbc0988516a/downloads/396e7977-71fd-4592-8723-495ca4cfa7cc/phantomjs-2.1.1-linux-x86_64.tar.bz2?Signature=GOYk%2BSO3n6DdQ3P4upLnWXUR3k0%3D&Expires=1516093791&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-2.1.1-linux-x86_64.tar.bz2%22 [following]
converted 'https://bbuseruploads.s3.amazonaws.com/fd96ed93-2b32-46a7-9d2b-ecbc0988516a/downloads/396e7977-71fd-4592-8723-495ca4cfa7cc/phantomjs-2.1.1-linux-x86_64.tar.bz2?Signature=GOYk%2BSO3n6DdQ3P4upLnWXUR3k0%3D&Expires=1516093791&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-2.1.1-linux-x86_64.tar.bz2%22' (ANSI_X3.4-1968) -> 'https://bbuseruploads.s3.amazonaws.com/fd96ed93-2b32-46a7-9d2b-ecbc0988516a/downloads/396e7977-71fd-4592-8723-495ca4cfa7cc/phantomjs-2.1.1-linux-x86_64.tar.bz2?Signature=GOYk+SO3n6DdQ3P4upLnWXUR3k0=&Expires=1516093791&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment; filename="phantomjs-2.1.1-linux-x86_64.tar.bz2"' (UTF-8)
20 redirections exceeded.
michiels commented 6 years ago

@jvanbaarsen Allright! I can check. Can you try to run the wget on your own workstation (not in a container).

jvanbaarsen commented 6 years ago

@michiels That seems to be working.

michiels commented 6 years ago

@jvanbaarsen Ok, i'm going to check in my docker-compose. What happens when you run docker-compose build in the repository? Same thing?

michiels commented 6 years ago

@jvanbaarsen I'm getting the same. I'm checking what's going on.

michiels commented 6 years ago

@jvanbaarsen Turns out the URL I used was old and deprecated. Latest commits update the binary URL for phantomjs and are working here.

jvanbaarsen commented 6 years ago

@michiels When trying to run docker-compose up I get an access-denied error for the IC container.

michiels commented 6 years ago

@jvanbaarsen Can you screenshot/post the full output?

jvanbaarsen commented 6 years ago

image I did do a Docker login. Can it be that you need to mark the image as public?

michiels commented 6 years ago

@jvanbaarsen That's odd, it shouldn't try and fetch the image from remote, but it should build your local directory. Can you try "docker-compose build" first and then do "docker-compose up" again? Could be that I need to update the README for this case.