-
-
Save mosleymos/a89d9ee55e8e5952a41afb6d668e80cd to your computer and use it in GitHub Desktop.
Revisions
-
davidtolsma revised this gist
Jan 2, 2021 . No changes.There are no files selected for viewing
-
davidtolsma revised this gist
Jan 2, 2021 . No changes.There are no files selected for viewing
-
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -101,7 +101,7 @@ YAML end inject_into_file 'docker/rails/Dockerfile' do <<-YAML FROM ruby:2.7.2 WORKDIR /app -
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -115,7 +115,7 @@ RUN apt-get update && apt-get install -y \ apt-get update && apt-get install -y nodejs yarn COPY Gemfile . # COPY Gemfile.lock . RUN gem install bundler RUN gem update bundler RUN bundle install --jobs 5 -
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -58,7 +58,7 @@ server { listen 80; server_name localhost; root /app/public; location / { proxy_pass http://app; -
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -5,7 +5,7 @@ # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq # requires config/sidekiq.yml config/initializers/sidekiq.rb cable/config.ru create_file 'docker/nginx/Dockerfile' do <<~YAML YAML -
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -5,7 +5,7 @@ # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq # requires config/sidekiq.yml cable/config.ru create_file 'docker/nginx/Dockerfile' do <<~YAML YAML -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 3 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 @@ -1,4 +1,7 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw' # This sets up docker for rails with nginx, postgres, redis, sidekiq, and action_cable # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 1 addition 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 @@ -2,6 +2,7 @@ # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq # requires config/sidekiq.yml create_file 'docker/nginx/Dockerfile' do <<~YAML YAML -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 3 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 @@ -1,4 +1,7 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw' # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq create_file 'docker/nginx/Dockerfile' do <<~YAML YAML -
davidtolsma renamed this gist
Jan 2, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 2 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 @@ -94,7 +94,7 @@ end inject_into_file 'docker/rails/Dockerfile' do <<-YAML FROM ruby:2.6 WORKDIR /app @@ -109,7 +109,7 @@ COPY Gemfile . COPY Gemfile.lock . RUN gem install bundler RUN gem update bundler RUN bundle install --jobs 5 -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 1 addition 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 @@ -109,6 +109,7 @@ COPY Gemfile . COPY Gemfile.lock . RUN gem isntall bundler RUN gem update bundler RUN bundle install --jobs 5 -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 6 additions and 5 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 @@ -4,10 +4,6 @@ YAML end inject_into_file 'docker/nginx/Dockerfile' do <<~YAML # ./docker/web/Dockerfile # Base image: @@ -41,6 +37,11 @@ YAML end create_file 'docker/nginx/nginx.conf' do <<~YAML YAML end inject_into_file 'docker/nginx/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; @@ -74,7 +75,6 @@ client_max_body_size 4G; keepalive_timeout 10; } YAML end @@ -131,6 +131,7 @@ YAML end create_file 'docker-compose.yml' do <<~YAML version: "3.8" services: -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 53 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 @@ -78,6 +78,59 @@ YAML end create_file 'docker/postgres/Dockerfile' do <<~YAML YAML end inject_into_file 'docker/postgres/Dockerfile' do <<-YAML FROM postgres YAML end create_file 'docker/rails/Dockerfile' do <<~YAML YAML end inject_into_file 'docker/rails/Dockerfile' do <<-YAML FROM ruby:2.7 WORKDIR /app RUN apt-get update && apt-get install -y \ curl \ build-essential \ libpq-dev && \ curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update && apt-get install -y nodejs yarn COPY Gemfile . COPY Gemfile.lock . RUN gem update bundler RUN bundle install --jobs 5 COPY package.json . COPY yarn.lock . RUN yarn install EXPOSE 3000 CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] YAML end create_file 'docker/redis/Dockerfile' do <<~YAML YAML end inject_into_file 'docker/redis/Dockerfile' do <<-YAML FROM redis:5-alpine YAML end create_file 'docker-compose.yml' do <<~YAML version: "3.8" services: -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 7 additions and 3 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,10 +1,14 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw' create_file 'docker/nginx/Dockerfile' do <<~YAML YAML end create_file 'docker/nginx/nginx.conf' do <<~YAML YAML end inject_into_file 'docker/nginx/Dockerfile' do <<~YAML # ./docker/web/Dockerfile # Base image: FROM nginx @@ -37,7 +41,7 @@ YAML end inject_into_file 'docker/nginx/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; } -
davidtolsma revised this gist
Jan 2, 2021 . 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 @@ -37,7 +37,7 @@ YAML end create_file 'docker/nginx--/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; } -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 1 addition and 72 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 @@ -38,7 +38,7 @@ end create_file 'docker/nginx/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; } @@ -71,77 +71,6 @@ keepalive_timeout 10; } YAML end -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 1 addition and 5 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 @@ -4,10 +4,6 @@ YAML end create_file 'docker/nginx/Dockerfile' do <<~YAML # ./docker/web/Dockerfile # Base image: @@ -41,7 +37,7 @@ YAML end create_file 'docker/nginx/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; } -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 4 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 @@ -4,6 +4,10 @@ YAML end create_file 'docker/nginx/.keep' do <<~YAML YAML end create_file 'docker/nginx/Dockerfile' do <<~YAML # ./docker/web/Dockerfile # Base image: -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 141 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 @@ -4,6 +4,147 @@ YAML end create_file 'docker/nginx/Dockerfile' do <<~YAML # ./docker/web/Dockerfile # Base image: FROM nginx # Install dependencies RUN apt-get update -qq && apt-get -y install apache2-utils # establish where Nginx should look for files ENV RAILS_ROOT /app # Set our working directory inside the image WORKDIR $RAILS_ROOT # create log directory RUN mkdir -p log # copy over static assets COPY public public/ # Copy Nginx config template COPY docker/nginx/nginx.conf /tmp/docker.nginx # substitute variable references in the Nginx config template for real values from the environment # put the final config in its place RUN envsubst '$RAILS_ROOT' < /tmp/docker.nginx > /etc/nginx/conf.d/default.conf EXPOSE 80 # Use the "exec" form of CMD so Nginx shuts down gracefully on SIGTERM (i.e. `docker stop`) CMD [ "nginx", "-g", "daemon off;" ] YAML end create_file 'docker/nging/nginx.conf' do <<~YAML upstream app { server app:3000 fail_timeout=0; } server { listen 80; server_name localhost; root /usr/src/app/public; location / { proxy_pass http://app; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Host $host; } location /cable { proxy_pass http://app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; break; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } # upstream rails_app { # server app:3000; # } # # Default server # server { # # define your domain # # server_name localhost; # listen 80; # # listen 443 ssl; # # ssl_certificate $RAILS_ROOT/secret/ssl_certificates/myapp.com.crt; # # ssl_certificate_key $RAILS_ROOT/secret/ssl_certificates/myapp.com.key; # # define the public application root # root $RAILS_ROOT/public; # index index.html; # # define where Nginx should write its logs # access_log $RAILS_ROOT/log/nginx.access.log; # error_log $RAILS_ROOT/log/nginx.error.log; # # deny requests for files that should never be accessed # location ~ /\. { # deny all; # } # location ~* ^.+\.(rb|log)$ { # deny all; # } # # serve static (compiled) assets directly if they exist (for rails production) # location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ { # try_files $uri @rails; # access_log off; # gzip_static on; # to serve pre-gzipped version # expires max; # add_header Cache-Control public; # # Some browsers still send conditional-GET requests if there's a # # Last-Modified header or an ETag header even if they haven't # # reached the expiry date sent in the Expires header. # add_header Last-Modified ""; # add_header ETag ""; # break; # } # # send non-static file requests to the app server # location / { # try_files $uri @rails; # } # location /cable { # } # location @rails { # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header Host $http_host; # proxy_redirect off; # proxy_pass http://rails_app; # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "Upgrade"; # proxy_set_header Host $host; # } # } YAML end create_file 'docker-compose.yml' do <<~YAML version: "3.8" services: -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 1 addition and 3 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,8 +1,6 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw' create_file 'docker/.keep' do <<~YAML YAML end -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 6 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 @@ -6,6 +6,12 @@ YAML end create_file 'docker-compose.yml' do <<~YAML version: "3.8" services: YAML end inject_into_file 'docker-compose.yml' do <<-YAML db: container_name: db -
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 8 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,4 +1,4 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw' create_file 'docker-compose.yml' do <<~YAML version: "3.8" @@ -22,6 +22,7 @@ POSTGRES_PASSWORD: example POSTGRES_USER: user POSTGRES_DB: app YAML end @@ -48,6 +49,7 @@ DB_NAME: app DB_PASSWORD: example DB_HOST: db YAML end @@ -67,6 +69,7 @@ restart: always volumes: - ".:/app" YAML end @@ -83,6 +86,7 @@ - "6379:6379" volumes: - "redis:/data" YAML end @@ -98,6 +102,7 @@ - "6380:6380" volumes: - "sidekiq_redis:/data" YAML end @@ -115,6 +120,7 @@ - sidekiq_redis volumes: - '.:/app' YAML end @@ -133,6 +139,7 @@ - '28080:28080' volumes: - '.:/app' YAML end -
davidtolsma renamed this gist
Jan 2, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davidtolsma revised this gist
Jan 2, 2021 . No changes.There are no files selected for viewing
-
davidtolsma revised this gist
Jan 2, 2021 . No changes.There are no files selected for viewing
-
davidtolsma revised this gist
Jan 2, 2021 . 1 changed file with 139 additions and 21 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,28 +1,146 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54' create_file 'docker-compose.yml' do <<~YAML version: "3.8" services: YAML end inject_into_file 'docker-compose.yml' do <<-YAML db: container_name: db image: "postgres" build: context: . dockerfile: ./docker/postgres/Dockerfile ports: - 5432:5432 volumes: - "postgres:/var/lib/postgresql/data" restart: always environment: POSTGRES_PASSWORD: example POSTGRES_USER: user POSTGRES_DB: app YAML end inject_into_file 'docker-compose.yml' do <<-YAML app: container_name: app image: "rails" build: context: . dockerfile: ./docker/rails/Dockerfile # command: 'bash -c ''bundle exec puma -C config/puma.rb''' command: /bin/bash -c "rm -f /tmp/server.pid && bundle exec rails server -b 0.0.0.0 -P /tmp/server.pid" volumes: - ".:/app" ports: - "3000:3000" depends_on: - db - redis - sidekiq - sidekiq_redis environment: DB_USER: user DB_NAME: app DB_PASSWORD: example DB_HOST: db YAML end inject_into_file 'docker-compose.yml' do <<-YAML http: container_name: http image: "nginx" ports: - 80:80 - 443:443 depends_on: - app build: context: . dockerfile: ./docker/nginx/Dockerfile # # command: /bin/bash -c "rm -f /tmp/server.pid && bundle exec rails server -b 0.0.0.0 -P /tmp/server.pid" restart: always volumes: - ".:/app" YAML end inject_into_file 'docker-compose.yml' do <<-YAML redis: container_name: redis image: "redis" build: context: . dockerfile: ./docker/redis/Dockerfile command: redis-server ports: - "6379:6379" volumes: - "redis:/data" YAML end inject_into_file 'docker-compose.yml' do <<-YAML sidekiq_redis: container_name: sidekiq_redis image: "redis" build: context: . dockerfile: ./docker/redis/Dockerfile command: "redis-server --port 6380" ports: - "6380:6380" volumes: - "sidekiq_redis:/data" YAML end inject_into_file 'docker-compose.yml' do <<-YAML sidekiq: container_name: sidekiq image: "sidekiq" build: context: . dockerfile: ./docker/rails/Dockerfile command: bundle exec sidekiq -C config/sidekiq.yml depends_on: - db - sidekiq_redis volumes: - '.:/app' YAML end inject_into_file 'docker-compose.yml' do <<-YAML cable: container_name: cable image: "cable" build: context: . dockerfile: ./docker/rails/Dockerfile command: puma -p 28080 cable/config.ru depends_on: - redis ports: - '28080:28080' volumes: - '.:/app' YAML end inject_into_file 'docker-compose.yml' do <<-YAML volumes: redis: sidekiq_redis: postgres: YAML end -
davidtolsma created this gist
Jan 2, 2021 .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,28 @@ # rails app:template LOCATION='https://gist.github.com/davidtolsma/b59c85845a76b47d0cb94dc88f340d28' def ask_with_default(prompt, default) value = ask("#{prompt} (default: #{default})") value.present? ? value : default end run "bundle add 'friendly_id'" rails_command "generate friendly_id" while yes?("Do you want to use Friendly ID with an existing model?") do model_name = ask_with_default("Model Name:", "Post") attribute = ask_with_default("Attribute:", "name") if model_name && attribute # We generate a migration to add the friendly id slug column. generate(:migration, "AddSlugTo#{model_name.titleize.pluralize}", "slug:uniq") string = <<~RUBY extend FriendlyId friendly_id :#{attribute}, use: :slugged RUBY # Inject the friendly id methods into the class. inject_into_file "app/models/#{model_name.downcase}.rb", string, after: "class #{model_name.titleize} < ApplicationRecord\n" end end # Run migrations for newly generated migrations rails_command "db:migrate"