-
-
Save kubicek/58f2dddc7b8f823ba73923693efa64c1 to your computer and use it in GitHub Desktop.
version: '3.1' | |
services: | |
db: | |
image: postgres:alpine | |
restart: always | |
environment: | |
- POSTGRES_USER=postgres | |
- POSTGRES_PASSWORD=postgres | |
ports: | |
- '5432:5432' | |
volumes: | |
- postgres:/var/lib/postgresql/data | |
redis: | |
image: redis:6.2-alpine | |
restart: always | |
ports: | |
- '6379:6379' | |
command: redis-server --save 20 1 --loglevel warning | |
volumes: | |
- redis:/data | |
web: | |
build: . | |
tty: true | |
environment: | |
- REDIS_URL=redis://redis:6379 | |
- DATABASE_URL=postgres://postgres:postgres@db:5432/web | |
volumes: | |
- .:/myapp | |
ports: | |
- "3000:3000" | |
depends_on: | |
- db | |
- redis | |
volumes: | |
postgres: | |
driver: local | |
redis: | |
driver: local |
FROM ruby:3 | |
# based on https://github.com/timbru31/docker-ruby-node/blob/master/3.1/16/Dockerfile | |
RUN curl -sL https://deb.nodesource.com/setup_17.x | bash -\ | |
&& apt-get update -qq && apt-get install -qq --no-install-recommends \ | |
postgresql-client nodejs redis-tools \ | |
&& apt-get upgrade -qq \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/*\ | |
&& npm install -g yarn | |
RUN mkdir /myapp | |
WORKDIR /myapp | |
COPY Gemfile /myapp/Gemfile | |
COPY Gemfile.lock /myapp/Gemfile.lock | |
RUN bundle install | |
COPY . /myapp | |
RUN yarn install | |
EXPOSE 3000 | |
CMD "bin/dev" |
# This template: | |
# * commits new generated rails skeleton, | |
# * fetches latest bullettrain template sources and stores | |
# it in separate commit | |
# * sets up docker-compose | |
# Usage: rails new myapp -m https://gist.githubusercontent.com/kubicek/58f2dddc7b8f823ba73923693efa64c1/raw/template.rb | |
# template source based on: https://github.com/mattbrictson/rails-template | |
def rails_version | |
@rails_version ||= Gem::Version.new(Rails::VERSION::STRING) | |
end | |
def rails_7_0_0? | |
Gem::Requirement.new("= 7.0.0").satisfied_by? rails_version | |
end | |
unless rails_7_0_0? | |
puts "Please use Rails 7.0.0 by executing rails _7.0.0_ new" | |
end | |
def commit_skeleton | |
git add: "." | |
# git commit will fail if user.email is not configured | |
begin | |
git commit: %( -m 'Rails 7.0.0 generated skeleton' ) | |
rescue StandardError => e | |
puts e.message | |
end | |
end | |
def commit_bullettrain | |
git clone: "--depth 1 "+ | |
"https://github.com/bullet-train-co/bullet_train origin" | |
# create folders | |
run "git --git-dir origin/.git diff --name-only | xargs -n 1 dirname | xargs mkdir -p" | |
# copy files | |
run "git --git-dir origin/.git diff --name-only | xargs -L1 -I % cp ./origin/% ./%" | |
run "rm -rf origin" | |
git add: "." | |
git commit: '-m "Added bullet_train based on #`git --git-dir origin/.git rev-parse --short HEAD`"' | |
end | |
def configure_bullettrain | |
# from bullettrains bin/configure | |
require "active_support/inflector" | |
human = ask "What is the name of your new application in title case? (e.g. \"Some Great Application\")" | |
variable = ActiveSupport::Inflector.parameterize(human, separator: '_') | |
environment_variable = ActiveSupport::Inflector.parameterize(human, separator: '_').upcase | |
class_name = variable.classify | |
kebab_case = variable.tr("_", "-") | |
puts "" | |
say "Replacing instances of \"Untitled Application\" with \"#{human}\" throughout the codebase.", :green | |
gsub_file("./.circleci/config.yml", "untitled_application", variable) | |
gsub_file("./config/database.yml", "untitled_application", variable) | |
gsub_file("./config/database.yml", "UNTITLED_APPLICATION", environment_variable) | |
gsub_file("./config/cable.yml", "untitled_application", variable) | |
gsub_file("./config/initializers/session_store.rb", "untitled_application", variable) | |
gsub_file("./config/environments/production.rb", "untitled_application", variable) | |
gsub_file("./config/application.rb", "UntitledApplication", class_name) | |
# TODO: gsub_file("./config/locales/en/application.en.yml", "Untitled Application", human, /name/) | |
gsub_file("./config/locales/en/application.en.yml", "untitled_application", variable) | |
# TODO: gsub_file("./config/locales/en/application.en.yml", "untitled application", human.downcase, /keywords/) | |
gsub_file("./config/locales/en/user_mailer.en.yml", "Untitled Application", human) | |
say | |
say "Moving `./README.example.md` to `./README.md`.", :green | |
run "mv ./README.example.md ./README.md" | |
# We can only do this after the README is moved into place. | |
gsub_file("./README.md", "Untitled Application", human) | |
git add: "." | |
git commit: %( -m 'Configured bullettrain' ) | |
end | |
def commit_docker | |
get "https://gist.githubusercontent.com/kubicek/58f2dddc7b8f823ba73923693efa64c1/raw/Dockerfile", "Dockerfile" | |
get "https://gist.githubusercontent.com/kubicek/58f2dddc7b8f823ba73923693efa64c1/raw/docker-compose.yml", "docker-compose.yml" | |
say "Applying changes for docker" | |
gsub_file("Procfile.dev","-p 3000","-p 3000 -b 0.0.0.0") | |
insert_into_file "config/cable.yml", " url: <%= ENV.fetch(\"REDIS_URL\") %>\n", :after => "adapter: redis\n" | |
git add: "." | |
git commit: %( -m 'Added docker' ) | |
end | |
after_bundle do | |
git :init | |
commit_skeleton | |
commit_bullettrain | |
configure_bullettrain | |
commit_docker | |
say | |
say "Bullettrain app successfully created!", :blue | |
say | |
say "To get started with your new app:", :green | |
say " cd #{original_app_name}" | |
say | |
say " docker compose build" | |
say " docker compose run web bin/setup" | |
say " docker compose up" | |
end |
Hi, I tried this Dockerfile but got the following error - wonder if you have any suggestions:
[linux/amd64 build 7/10] RUN bundle install && rm -rf ~/.bundle/ "/usr/local/bundle"/ruby//cache "/usr/local/bundle"/ruby//bundler/gems/*/.git && bundle exec bootsnap precompile --gemfile:
'
248.5 /usr/local/bin/bundle:25:in `
248.5
248.5 An error occurred while installing charlock_holmes (0.7.7), and Bundler cannot
248.5 continue.
248.5
248.5 In Gemfile:
248.5 bullet_train-api was resolved to 1.6.2, which depends on
248.5 bullet_train was resolved to 1.6.2, which depends on
248.5 extended_email_reply_parser was resolved to 0.5.1, which depends on
248.5 charlock_holmes
Dockerfile:37
36 | COPY --link Gemfile Gemfile.lock ./
37 | >>> RUN bundle install &&
38 | >>> rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby//cache "${BUNDLE_PATH}"/ruby//bundler/gems/*/.git &&
39 | >>> bundle exec bootsnap precompile --gemfile
40 |
ERROR: failed to solve: process "/bin/sh -c bundle install && rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby//cache "${BUNDLE_PATH}"/ruby//bundler/gems/*/.git && bundle exec bootsnap precompile --gemfile" did not complete successfully: exit code: 5
I also noticed the following in the logs:
DEBUG [1f77a6d4] #9 [linux/arm64 2/9] RUN curl -sL https://deb.nodesource.com/setup_17.x | bash - && apt-get update -qq && apt-get install -qq --no-install-recommends postgresql-client nodejs redis-tools && apt-get upgrade -qq && apt-get clean && rm -rf /var/lib/apt/lists/* && npm install -g yarn
DEBUG [1f77a6d4] #9 22.17
DEBUG [1f77a6d4] #9 22.18 ================================================================================
DEBUG [1f77a6d4] #9 22.18 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
DEBUG [1f77a6d4] #9 22.18 ================================================================================
DEBUG [1f77a6d4] #9 22.18
DEBUG [1f77a6d4] #9 22.18 SCRIPT DEPRECATION WARNING
DEBUG [1f77a6d4] #9 22.18
DEBUG [1f77a6d4] #9 22.18
DEBUG [1f77a6d4] #9 22.18 This script, located at https://deb.nodesource.com/setup_X, used to
DEBUG [1f77a6d4] #9 22.19 install Node.js is deprecated now and will eventually be made inactive.
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19 Please visit the NodeSource distributions Github and follow the
DEBUG [1f77a6d4] #9 22.19 instructions to migrate your repo.
DEBUG [1f77a6d4] #9 22.19 https://github.com/nodesource/distributions
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19 The NodeSource Node.js Linux distributions GitHub repository contains
DEBUG [1f77a6d4] #9 22.19 information about which versions of Node.js and which Linux distributions
DEBUG [1f77a6d4] #9 22.19 are supported and how to install it.
DEBUG [1f77a6d4] #9 22.19 https://github.com/nodesource/distributions
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19 SCRIPT DEPRECATION WARNING
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19 ================================================================================
DEBUG [1f77a6d4] #9 22.19 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
DEBUG [1f77a6d4] #9 22.19 ================================================================================
DEBUG [1f77a6d4] #9 22.19
DEBUG [1f77a6d4] #9 22.19 TO AVOID THIS WAIT MIGRATE THE SCRIPT
DEBUG [1f77a6d4] #9 22.19 Continuing in 60 seconds (press Ctrl-C to abort) ...
For whatever reason! I was getting "glob" module not found when running "docker-compose up". It failed at Procfile.dev line 3
js: yarn build --watch
.I've updated the "web" volumes (below) to get it working. I'm not sure if this is the best way thought.