Skip to content

dakotalightning/docker-rails

Repository files navigation

README - Docker version

circleci

Example is at rails.koda.io using digitalocean.com and repo docker.io/dakotalightning/docker-rails

Docker requirement

If you don't have docker on your local machine get started is a good place to start. It has gotten allot easier to get start, docker has managed to get everything you need in the Docker toolbox. Once you have docker all installed.

After clone run setup (you only need to run this once)

$ ./setup.sh

After any changes to the Dockerfile

docker-compose build
docker-compose up

check your docker-machine ip docker-machine env default used to access the container locally

when ready to push to production, create the production image

$ docker build -t dakotalightning/koda-rails -f Dockerfile.production .

push the image to a repo, I'm using docker.io since its free for public repositories

docker push dakotalightning/koda-rails

server flow

This is what I did for digitalocean.com I'm not sure if it is the right way, it works I'm looking into it this ...

  1. ssh into the server droplet

  2. install docker-compose

    pull the docker-production.yml on the server

     wget https://raw.githubusercontent.com/dakotalightning/koda.rails/docker/docker-production.yml -O docker-compose.yml
    
  3. start up docker-compose

     docker-compose up
    

    docker-compose will pull in the images automatically from the docker-compose.yml file

  4. in another window run this to get the database, this will run rake and --rm remove the container once its done.

     docker-compose run --name rake --rm web rake db:setup
    

    from my understanding you want to use --rm flag when running docker-compose run. Every run will start up a new container ex: web_run_1 web_run_2 web_run_3 etc.

  5. ctrl+c to stop the containers

  6. run docker-compose start to start the containers in the background

  7. run docker-compose ps to see them running

        Name                 Command               State            Ports          
     -----------------------------------------------------------------------------
    

    dockerrails_db_1 /entrypoint.sh mysqld Up 0.0.0.0:13306->3306/tcp
    dockerrails_nginx_1 nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp dockerrails_redis_1 /entrypoint.sh redis-server Up 0.0.0.0:6379->6379/tcp
    dockerrails_web_1 bash -c rm -f tmp/pids/ser ... Up 0.0.0.0:3000->3000/tcp

  8. go to the url of the droplet provided on digitalocean

notes

deploy-images | bash -s

this will be worked into job somwhere?

curl -sSL https://raw.githubusercontent.com/dakotalightning/docker-rails/master/deploy-server | bash -s

testing

  • circle ci for testing and deployment of images
  • webhook? to deploy bot to pull new images and set new container?