{"id":18123322,"url":"https://github.com/jay-johnson/docker-rails-app","last_synced_at":"2025-04-06T12:45:45.755Z","repository":{"id":72596174,"uuid":"46818094","full_name":"jay-johnson/docker-rails-app","owner":"jay-johnson","description":"Rails App - Phase 2 - With Docker Integration for Demonstrating Travis CI","archived":false,"fork":false,"pushed_at":"2015-11-25T22:34:20.000Z","size":66,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T18:51:29.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jay-johnson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-24T20:56:21.000Z","updated_at":"2017-07-07T13:14:12.000Z","dependencies_parsed_at":"2023-02-26T21:00:38.137Z","dependency_job_id":null,"html_url":"https://github.com/jay-johnson/docker-rails-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-rails-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-rails-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-rails-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-rails-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jay-johnson","download_url":"https://codeload.github.com/jay-johnson/docker-rails-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485253,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T07:09:16.248Z","updated_at":"2025-04-06T12:45:45.717Z","avatar_url":"https://github.com/jay-johnson.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Local Rails Development running in Docker and integrated with Travis \n\n[![Travis](https://travis-ci.org/jay-johnson/docker-rails-app.svg)](https://travis-ci.org/jay-johnson/docker-rails-app.svg)\n\nThis repository is an example for showing how to setup a local development environment with docker hosting a rails application running inside a container image. It also uses Travis CI (https://travis-ci.org/jay-johnson/docker-rails-app) for Docker container building and then running the tests against the rails application from inside the container.\n\n### Install\n\nMake sure your environment has these components:\n\n```\n$ rails -v\nRails 4.2.4\n$ ruby -v\nruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]\n$ \n```\n\n### How to build\n\n```\ndocker build -t demo-rails .\n```\n\n### How to use the existing image\n\nThe latest Docker image is also stored publicly on Docker Hub: https://hub.docker.com/r/jayjohnson/rails-app/\n\nPull the latest with:\n\n```\ndocker pull jayjohnson/rails-app\n```\n\n### How to run\n\n```\ndocker-rails-app$ docker run -it -d --publish 0.0.0.0:3000:3000 --name=demo-rails demo-rails\ned72180c1c65fd4a2bd9be8f26437a5b19f04c1d7dba5715fde9661412092641\ndocker-rails-app$ docker ps\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES\ned72180c1c65        demo-rails         \"/bin/sh -c /opt/acti\"   6 seconds ago       Up 4 seconds        0.0.0.0:3000-\u003e3000/tcp   demo-rails\ndocker-rails-app$ \n```\n\n### How to ssh into the container\n\n```\ndocker exec -t -i demo-rails /bin/bash\n```\n\n### How to stop\n\n```\ndocker-rails-app$ docker stop demo-rails\ndemo-rails\ndocker-rails-app$\n```\n\n### How to stop, remove, build, and start\n\n```\n$ docker stop demo-rails; docker rm demo-rails; docker build -t demo-rails .; docker run -it -d --publish 0.0.0.0:3000:3000 --name=demo-rails demo-rails\n```\n\n### Confirm the application is hosting the welcome page\n\n```\ndocker-rails-app$ curl http://localhost:3000/welcome/index | grep Hello\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n100  1429  100  1429    0     0  21544      0 --:--:-- --:--:-- --:--:-- 21651\n\u003cp\u003eHello World!\u003c/p\u003e\ndocker-rails-app$ \n```\n\n### Pulling the latest from inside a running container\n\n```\nroot@b4f1ab122d82:/opt/webapp# git pull\nremote: Counting objects: 3, done.\nremote: Compressing objects: 100% (1/1), done.\nremote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0\nUnpacking objects: 100% (3/3), done.\nFrom https://github.com/jay-johnson/docker-rails-app\n   63aba06..ca307ad  master     -\u003e origin/master\nFirst, rewinding head to replay your work on top of it...\nFast-forwarded master to ca307ada38bdae1a07a96d808166dac7381da630.\nroot@b4f1ab122d82:/opt/webapp# \n```\n\n### View the App\n\nOpen a browser for:\n\n```\nhttp://localhost:3000/welcome/index\n```\n\n### Running the Hello World Rake Test:\n\n```\nbundle exec rake test TEST=test/controllers/hello_world_test.rb\n```\n\n### Setting up Travis CI with an after_success hook\n\n1. Authentication\n\n  Travis needs to know how to authenticate with the repository account on Docker Hub. You can either set these as environment variables on the repository in Travis or encrypt them:\n\n  ```\n  $ gem install travis\n  $ travis encrypt DOCKER_EMAIL=email@gmail.com\n  $ travis encrypt DOCKER_USERNAME=username\n  $ travis encrypt DOCKER_PASSWORD=password\n  ```\n\n1. Add the credentials to the .travis.yml file as\n\n  ```\n  env:\n    global:\n      - secure: \"UkF2CHX0lUZ...VI/LE=\" # DOCKER_EMAIL\n      - secure: \"Z3fdBNPt5hR...VI/LE=\" # DOCKER_USERNAME\n      - secure: \"F4XbD6WybHC...VI/LE=\" # DOCKER_PASSWORD\n      - COMMIT=${TRAVIS_COMMIT::8}\n  ```\n\n1. Add the after_success to the .travis.yml\n\n  ```\n  after_success:\n    - docker login -e $DOCKER_EMAIL -u $DOCKER_USERNAME -p $DOCKER_PASSWORD\n    - export REPO=\u003cyou repo name\u003e/\u003cyour container image name\u003e\n    - export TAG=`if [ \"$TRAVIS_BRANCH\" == \"master\" ]; then echo \"latest\"; else echo $TRAVIS_BRANCH ; fi`\n    - docker build -f Dockerfile -t $REPO:$COMMIT .\n    - docker tag $REPO:$COMMIT $REPO:$TAG\n    - docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER\n    - docker push $REPO\n  ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-rails-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjay-johnson%2Fdocker-rails-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-rails-app/lists"}