Last active
December 2, 2024 01:26
Revisions
-
zentetsukenz revised this gist
Oct 17, 2019 . 1 changed file with 22 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Docker ## Files and Folders. ```filesystem | @@ -27,7 +27,7 @@ Your docker/development folder contain Dockerfile for your development. Staging and Production have the same file, but their content will be different. For example, .env file which contain your secret. ### .env This file will be use as an application environment while deploying. **This file should be listed in your gitignore** @@ -40,7 +40,7 @@ SECRET_KEY_BASE=your_secret_key Please note that, your `SECRET_KEY_BASE` should never ever appear in your repository, I add it here because I have it in my .gitignore file. This file will later be copied to your remote host. ### app-env.conf Application environment. ```text @@ -49,7 +49,7 @@ Application environment. passenger_app_env production; ``` ### app.nginx.conf An Nginx configuration for your server. Please note that your ruby version at the last line must match your Docker file base image ruby version. @@ -66,7 +66,7 @@ server { } ``` ### Dockerfile Base image for your application. ```Dockerfile @@ -122,7 +122,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* Please note that, I swap database.yml with database.yml.sample because in my database.yml.sample contain postgres container port resolving which in my development, it's not necessary. ### database.yml.sample ```yml default: &default @@ -147,7 +147,7 @@ production: database: app_production ``` ### postgres-env.conf Just a postgres environment variable, so that your app can pickup your database. ```text @@ -156,7 +156,7 @@ env POSTGRES_PORT_5432_TCP_ADDR; env POSTGRES_PORT_5432_TCP_PORT; ``` ### rails-env.conf To set environment variable for your application while running. This related to your .env file. ```text @@ -165,13 +165,13 @@ env RAILS_ENV; env SECRET_KEY_BASE; ``` ## docker-compose.yml There are 3 docker-compose files. The normal one, docker-compose.yml is for you development. As for your staging and production, I separated it into 2 file because I would like let Capistrano be able to pickup staging and production compose file which inside contain some different things. ### docker-compose.staging.yml ```docker-compose.yml version: "2" @@ -201,7 +201,7 @@ services: image: postgres:9.5 ``` ### docker-compose.production.yml ``` version: "2" @@ -228,7 +228,7 @@ services: image: postgres:9.5 ``` # Capistrano If you are not familiar with Capistrano please visit their site, then do install it into your project. @@ -245,11 +245,11 @@ and create some user you use for deployment. I will call this guy "deploy" for t After "deploy" is able to connect to your server, then let's make some task for it to be able to run with Docker Compose smoothly. ## File These following files reside in lib/capistrano/tasks folder. ### setup.rake ```rake namespace :setup do @@ -277,7 +277,7 @@ set :env_file_path, 'docker/production/.env' ... ``` ### access_check.rake ```rake desc "Check that we can access everything" @@ -292,7 +292,7 @@ task :check_write_permissions do end ``` ### composing.rake ```rake namespace :composing do @@ -386,10 +386,10 @@ namespace :composing do end ``` ## Deploy configuration In your config/deploy.rb, you should have something like this. ### config/deploy.rb ```ruby ... @@ -433,18 +433,18 @@ cap production deploy Done. # Things that can be improved. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a [very nice guide](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) but haven't tried it once. # Acknowledgement. Thanks to a wonderful guys in Docker, Capistrano and Passenger Docker that they made these tools available for developer to automate things pretty easy. Also many thanks to some guides that I do not remember what it is. Without those guides, I won't be able to make these things complete and easy with just one command. # References. - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) - [Capistrano](https://github.com/capistrano/rails) -
zentetsukenz revised this gist
Sep 5, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -433,7 +433,7 @@ cap production deploy Done. #Things that can be improved. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a [very nice guide](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) but haven't tried it once. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -436,7 +436,7 @@ Done. #Things that can be improve. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a [very nice guide](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) but haven't tried it once. #Acknowledgement. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -436,7 +436,7 @@ Done. #Things that can be improve. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a [very nice](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) guide but haven't tried it once. #Acknowledgement. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 34 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Docker ##Files and Folders. ```filesystem | @@ -27,7 +27,8 @@ Files and Folders. Your docker/development folder contain Dockerfile for your development. Staging and Production have the same file, but their content will be different. For example, .env file which contain your secret. ###.env This file will be use as an application environment while deploying. **This file should be listed in your gitignore** @@ -39,15 +40,17 @@ SECRET_KEY_BASE=your_secret_key Please note that, your `SECRET_KEY_BASE` should never ever appear in your repository, I add it here because I have it in my .gitignore file. This file will later be copied to your remote host. ###app-env.conf Application environment. ```text # /etc/nginx/conf.d/00_app_env.conf # File will be overwritten if user runs the container with `-e PASSENGER_APP_ENV=...`! passenger_app_env production; ``` ###app.nginx.conf An Nginx configuration for your server. Please note that your ruby version at the last line must match your Docker file base image ruby version. ```nginx @@ -63,7 +66,8 @@ server { } ``` ###Dockerfile Base image for your application. ```Dockerfile FROM phusion/passenger-ruby23:latest @@ -118,7 +122,8 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* Please note that, I swap database.yml with database.yml.sample because in my database.yml.sample contain postgres container port resolving which in my development, it's not necessary. ###database.yml.sample ```yml default: &default adapter: postgresql @@ -142,29 +147,31 @@ production: database: app_production ``` ###postgres-env.conf Just a postgres environment variable, so that your app can pickup your database. ```text # /etc/nginx/main.d/postgres-env.conf: env POSTGRES_PORT_5432_TCP_ADDR; env POSTGRES_PORT_5432_TCP_PORT; ``` ###rails-env.conf To set environment variable for your application while running. This related to your .env file. ```text # /etc/nginx/main.d/rails-env.conf: env RAILS_ENV; env SECRET_KEY_BASE; ``` ##docker-compose.yml There are 3 docker-compose files. The normal one, docker-compose.yml is for you development. As for your staging and production, I separated it into 2 file because I would like let Capistrano be able to pickup staging and production compose file which inside contain some different things. ###docker-compose.staging.yml ```docker-compose.yml version: "2" @@ -194,7 +201,7 @@ services: image: postgres:9.5 ``` ###docker-compose.production.yml ``` version: "2" @@ -221,9 +228,7 @@ services: image: postgres:9.5 ``` #Capistrano If you are not familiar with Capistrano please visit their site, then do install it into your project. @@ -240,9 +245,12 @@ and create some user you use for deployment. I will call this guy "deploy" for t After "deploy" is able to connect to your server, then let's make some task for it to be able to run with Docker Compose smoothly. ##File These following files reside in lib/capistrano/tasks folder. ###setup.rake ```rake namespace :setup do desc "Upload .env file to shared folder" @@ -269,7 +277,8 @@ set :env_file_path, 'docker/production/.env' ... ``` ###access_check.rake ```rake desc "Check that we can access everything" task :check_write_permissions do @@ -283,7 +292,8 @@ task :check_write_permissions do end ``` ###composing.rake ```rake namespace :composing do desc "Build application images" @@ -376,9 +386,11 @@ namespace :composing do end ``` ##Deploy configuration In your config/deploy.rb, you should have something like this. ###config/deploy.rb ```ruby ... ... @@ -421,18 +433,18 @@ cap production deploy Done. #Things that can be improve. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a very nice guide but haven't tried it once [here](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) #Acknowledgement. Thanks to a wonderful guys in Docker, Capistrano and Passenger Docker that they made these tools available for developer to automate things pretty easy. Also many thanks to some guides that I do not remember what it is. Without those guides, I won't be able to make these things complete and easy with just one command. #References. - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) - [Capistrano](https://github.com/capistrano/rails) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #Docker Files and Folders. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ * Docker Files and Folders. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ *Docker Files and Folders. -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -421,8 +421,20 @@ cap production deploy Done. Things that can be improve. - Dockerfile, would be awesome if I can build my own image from scratch, which should be very small. - Scaling. Found a very nice guide but haven't tried it once [here](http://southworks.com/blog/2015/07/17/docker-compose-scaling-multi-container-applications/) Acknowledgement. Thanks to a wonderful guys in Docker, Capistrano and Passenger Docker that they made these tools available for developer to automate things pretty easy. Also many thanks to some guides that I do not remember what it is. Without those guides, I won't be able to make these things complete and easy with just one command. References. - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) - [Capistrano](https://github.com/capistrano/rails) - [Initial Server Setup(DGO)](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) - [Using Compose in production](https://docs.docker.com/compose/production/) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 72 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -115,6 +115,33 @@ RUN rake assets:precompile RAILS_ENV=production RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ``` Please note that, I swap database.yml with database.yml.sample because in my database.yml.sample contain postgres container port resolving which in my development, it's not necessary. database.yml.sample ```yml default: &default adapter: postgresql encoding: unicode pool: 5 timeout: 5000 username: postgres host: postgres port: <%= ENV['POSTGRES_PORT_5432_TCP_PORT'] %> development: <<: *default database: app_development test: <<: *default database: app_test production: <<: *default database: app_production ``` "postgres-env.conf", just a postgres environment variable, so that your app can pickup your database. ```text @@ -349,6 +376,51 @@ namespace :composing do end ``` Then in your config/deploy.rb, you should have something like this. config/deploy.rb ```ruby ... ... namespace :deploy do desc "Initialize application" task :initialize do invoke 'composing:build' invoke 'composing:database:up' invoke 'composing:database:create' invoke 'composing:database:migrate' end after :published, :restart do invoke 'composing:restart:web' invoke 'composing:database:migrate' end before :finished, :clear_containers do on roles(:app) do execute "docker ps -a -q -f status=exited | xargs -r docker rm -v" execute "docker images -f dangling=true -q | xargs -r docker rmi -f" end end end ``` The first time you deploy your application, your must run this command ``` cap production deploy:initialize ``` To make your database ready for your application. Then, the next time you deploy your application, just run command ``` cap production deploy ``` Done. References - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 91 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -256,7 +256,98 @@ task :check_write_permissions do end ``` composing.rake ```rake namespace :composing do desc "Build application images" task :build do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "build" ) end end end desc "Take down compose application containers" task :down do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "down" ) end end end namespace :restart do desc "Rebuild and restart web container" task :web do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "build", "web" ) execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "up", "-d", "--no-deps", "web" ) end end end end namespace :database do desc "Up database and make sure it's ready" task :up do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "up", "-d", "--no-deps", "postgres" ) end end sleep 5 end desc "Create database" task :create do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "run", "--rm", "web", "rake", "db:create" ) end end end desc "Migrate database" task :migrate do on roles(:app) do within current_path do execute("docker-compose", "--project-name=#{fetch(:application)}_#{fetch(:stage)}", "-f", "docker-compose.#{fetch(:stage)}.yml", "run", "--rm", "web", "rake", "db:migrate" ) end end end end end ``` References -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 50 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -210,7 +210,56 @@ First, make sure that you setup your remote host for Capistrano to be able to do using DigitalOcean, you should follow [Initial Server Setup](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) and create some user you use for deployment. I will call this guy "deploy" for the sake of simplicity. After "deploy" is able to connect to your server, then let's make some task for it to be able to run with Docker Compose smoothly. These following files reside in lib/capistrano/tasks folder. setup.rake ```rake namespace :setup do desc "Upload .env file to shared folder" task :env do on roles(:app) do upload! fetch(:env_file_path), [shared_path, fetch(:env_file_path)].join('/') end end namespace :check do desc "Task description" task :linked_files => fetch(:env_file_path) end end ``` env_file_path is set in config/deploy/production.rb with the path to .env file. ```ruby ... set :env_file_path, 'docker/production/.env' ... ``` access_check.rake ```rake desc "Check that we can access everything" task :check_write_permissions do on roles(:app) do |host| if test("[ -w #{fetch(:deploy_to)} ]") info "#{fetch(:deploy_to)} is writable on #{host}" else error "#{fetch(:deploy_to)} is not writable on #{host}" end end end ``` References - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) - [Capistrano](https://github.com/capistrano/rails) - [Initial Server Setup(DGO)](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 20 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ Docker Files and Folders. ```filesystem @@ -192,6 +194,23 @@ services: image: postgres:9.5 ``` ------------------------------------------------------------------------------------- Capistrano If you are not familiar with Capistrano please visit their site, then do install it into your project. After setup Capistrano, here is a steps to take to be able to deploy your app with just one command. ``` cap production deploy ``` First, make sure that you setup your remote host for Capistrano to be able to do things, e.g. if you're using DigitalOcean, you should follow [Initial Server Setup](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) and create some user you use for deployment. I will call this guy "deploy" for the sake of simplicity. References - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) - [Capistrano](https://github.com/capistrano/rails) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -147,7 +147,8 @@ services: dockerfile: docker/staging/Dockerfile env_file: docker/staging/.env # Map your desire staging port here, if you plan to run this in the same host without using # subdomain. ports: - "9876:80" depends_on: -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -147,7 +147,7 @@ services: dockerfile: docker/staging/Dockerfile env_file: docker/staging/.env # Map your desire staging port here, if you plan to run this in the same host without using subdomain. ports: - "9876:80" depends_on: -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 62 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -129,6 +129,68 @@ env RAILS_ENV; env SECRET_KEY_BASE; ``` docker-compose.yml There are 3 docker-compose files. The normal one, docker-compose.yml is for you development. As for your staging and production, I separated it into 2 file because I would like let Capistrano be able to pickup staging and production compose file which inside contain some different things. docker-compose.staging.yml ```docker-compose.yml version: "2" services: web: restart: always build: context: . dockerfile: docker/staging/Dockerfile env_file: docker/staging/.env # Map your desire staging port here, if you're gonna run this in the same host without using subdomain. ports: - "9876:80" depends_on: - postgres postgres: image: postgres:9.5 ports: - "5432" volumes_from: - data data: image: postgres:9.5 ``` docker-compose.production.yml ``` version: "2" services: web: restart: always build: context: . dockerfile: docker/production/Dockerfile env_file: docker/production/.env ports: - "80:80" depends_on: - postgres postgres: image: postgres:9.5 ports: - "5432" volumes_from: - data data: image: postgres:9.5 ``` References - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker) -
zentetsukenz revised this gist
Sep 4, 2016 . 1 changed file with 14 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,16 +6,20 @@ Files and Folders. |... |\_ docker | | | |\_ development | |\_ staging | \_ production | | | |\_ .env | |\_ app-env.onf | |\_ app.nginx.conf | |\_ Dockerfile | |\_ postgres-env.conf | \_ rails-env.conf | |\_ docker-compose.yml |\_ docker-compose.staging.yml \_ docker-compose.production.yml ``` Your docker/development folder contain Dockerfile for your development. Staging and Production have the same file, but -
zentetsukenz created this gist
Sep 4, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,130 @@ Files and Folders. ```filesystem | |\_ app |... |\_ docker | | |\_ development |\_ staging \_ production | |\_ .env |\_ app-env.onf |\_ app.nginx.conf |\_ Dockerfile |\_ postgres-env.conf \_ rails-env.conf ``` Your docker/development folder contain Dockerfile for your development. Staging and Production have the same file, but their content will be different. For example, .env file which contain your secret. ".env", This file will be use as an application environment while deploying. **This file should be listed in your gitignore** ```text RAILS_ENV=production SECRET_KEY_BASE=your_secret_key ``` Please note that, your `SECRET_KEY_BASE` should never ever appear in your repository, I add it here because I have it in my .gitignore file. This file will later be copied to your remote host. "app-env.conf", application environment. ```text # /etc/nginx/conf.d/00_app_env.conf # File will be overwritten if user runs the container with `-e PASSENGER_APP_ENV=...`! passenger_app_env production; ``` "app.nginx.conf", an Nginx configuration for your server. Please note that your ruby version at the last line must match your Docker file base image ruby version. ```nginx # /etc/nginx/sites-enabled/app.nginx.conf: server { listen 80; root /home/app/your_app_name/public; passenger_enabled on; passenger_user app; passenger_ruby /usr/bin/ruby2.3; } ``` "Dockerfile", base image for your application. ```Dockerfile FROM phusion/passenger-ruby23:latest MAINTAINER Wiwatta Mongkhonchit "[email protected]" # Set correct environment variables. ENV HOME /root # Use baseimage-docker's init process. CMD ["/sbin/my_init"] # Expose Nginx HTTP service EXPOSE 80 # Start Nginx / Passenger RUN rm -f /etc/service/nginx/down # Remove the default site RUN rm /etc/nginx/sites-enabled/default # Nginx App setup ADD docker/staging/app.nginx.conf /etc/nginx/sites-enabled/app.nginx.conf ADD docker/staging/postgres-env.conf /etc/nginx/main.d/postgres-env.conf ADD docker/staging/rails-env.conf /etc/nginx/main.d/rails-env.conf ADD docker/staging/app-env.conf /etc/nginx/conf.d/00_app_env.conf # Update for security reason RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" # Gem caching WORKDIR /tmp ADD Gemfile /tmp/ ADD Gemfile.lock /tmp/ RUN bundle install --jobs 20 --retry 5 # App setup # # This is your application setup steps, you should also do what you need to do here to make your # application working for production environment. # WORKDIR /home/app/your_app_name ADD . /home/app/your_app_name RUN rm -f config/database.yml RUN mv config/database.yml.sample config/database.yml RUN chown -R app:app /home/app/your_app_name RUN rake assets:precompile RAILS_ENV=production # Clean up APT when done. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ``` "postgres-env.conf", just a postgres environment variable, so that your app can pickup your database. ```text # /etc/nginx/main.d/postgres-env.conf: env POSTGRES_PORT_5432_TCP_ADDR; env POSTGRES_PORT_5432_TCP_PORT; ``` "rails-env.conf", To set environment variable for your application while running. This related to your .env file. ```text # /etc/nginx/main.d/rails-env.conf: env RAILS_ENV; env SECRET_KEY_BASE; ``` References - [Phusion Passenger Docker](https://github.com/phusion/passenger-docker)