-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
353 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/.bundle | ||
/.vscode | ||
/coverage | ||
|
||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
/tmp/pids/* | ||
!/tmp/pids/ | ||
!/tmp/pids/.keep | ||
|
||
/storage/* | ||
!/storage/.keep | ||
|
||
/public/assets | ||
.byebug_history | ||
|
||
/config/master.key | ||
|
||
/public/packs | ||
/public/packs-test | ||
/node_modules | ||
/yarn-error.log | ||
yarn-debug.log* | ||
.yarn-integrity | ||
|
||
/config/credentials/development.key | ||
/config/credentials/test.key |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM ruby:2.7.2-alpine | ||
|
||
ENV APP_PATH /var/app | ||
ENV BUNDLE_VERSION 2.2.10 | ||
ENV BUNDLE_PATH /usr/local/bundle/gems | ||
ENV TMP_PATH /tmp/ | ||
ENV RAILS_LOG_TO_STDOUT true | ||
ENV RAILS_PORT 3000 | ||
|
||
# install dependencies for application | ||
RUN apk -U add --no-cache \ | ||
build-base \ | ||
git \ | ||
postgresql-dev \ | ||
postgresql-client \ | ||
libxml2-dev \ | ||
libxslt-dev \ | ||
nodejs \ | ||
yarn \ | ||
imagemagick \ | ||
tzdata \ | ||
less \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& mkdir -p $APP_PATH | ||
|
||
RUN gem install bundler --version "$BUNDLE_VERSION" \ | ||
&& rm -rf $GEM_HOME/cache/* | ||
|
||
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install -j $(nproc) --retry=4 | ||
|
||
COPY . ./var/app/ | ||
|
||
RUN bundle exec rails assets:precompile | ||
|
||
# navigate to app directory | ||
WORKDIR $APP_PATH | ||
|
||
EXPOSE $RAILS_PORT | ||
|
||
ENTRYPOINT [ "bundle", "exec" ] |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM ruby:2.7.2-alpine | ||
|
||
ENV APP_PATH /var/app | ||
ENV BUNDLE_VERSION 2.2.10 | ||
ENV BUNDLE_PATH /usr/local/bundle/gems | ||
ENV TMP_PATH /tmp/ | ||
ENV RAILS_LOG_TO_STDOUT true | ||
ENV RAILS_PORT 3000 | ||
|
||
# copy entrypoint scripts and grant execution permissions | ||
COPY ./dev-docker-entrypoint.sh /usr/local/bin/dev-entrypoint.sh | ||
COPY ./test-docker-entrypoint.sh /usr/local/bin/test-entrypoint.sh | ||
RUN chmod +x /usr/local/bin/dev-entrypoint.sh && chmod +x /usr/local/bin/test-entrypoint.sh | ||
|
||
# install dependencies for application | ||
RUN apk -U add --no-cache \ | ||
build-base \ | ||
git \ | ||
postgresql-dev \ | ||
postgresql-client \ | ||
libxml2-dev \ | ||
libxslt-dev \ | ||
nodejs \ | ||
yarn \ | ||
imagemagick \ | ||
tzdata \ | ||
less \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& mkdir -p $APP_PATH | ||
|
||
RUN gem install bundler --version "$BUNDLE_VERSION" \ | ||
&& rm -rf $GEM_HOME/cache/* | ||
|
||
# navigate to app directory | ||
WORKDIR $APP_PATH | ||
|
||
EXPOSE $RAILS_PORT | ||
|
||
ENTRYPOINT [ "bundle", "exec" ] |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# https://stackoverflow.com/a/14061796/2237879 | ||
# | ||
# This hack allows you to run make commands with any set of arguments. | ||
# | ||
# For example, these lines are the same: | ||
# > make g devise:install | ||
# > bundle exec rails generate devise:install | ||
# And these: | ||
# > make add-migration add_deleted_at_to_users deleted_at:datetime | ||
# > bundle exec rails g migration add_deleted_at_to_users deleted_at:datetime | ||
# And these: | ||
# > make add-model Order user:references record:references{polymorphic} | ||
# > bundle exec rails g model Order user:references record:references{polymorphic} | ||
# | ||
RUN_ARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS)) | ||
|
||
add-migration: | ||
docker-compose run --rm detonate_app rails g migration $(RUN_ARGS) | ||
|
||
add-model: | ||
docker-compose run --rm detonate_app rails g model $(RUN_ARGS) | ||
|
||
db-create: | ||
docker-compose run --rm detonate_app rails db:create | ||
|
||
db-migrate: | ||
docker-compose run --rm detonate_app rails db:migrate | ||
|
||
db-rollback: | ||
docker-compose run --rm detonate_app rails db:rollback | ||
|
||
lint-ruby: | ||
docker-compose run --rm detonate_app rubocop -a | ||
|
||
lint-security: | ||
docker-compose run --rm detonate_app brakeman | ||
|
||
ci: | ||
docker-compose run --rm detonate_test rspec | ||
|
||
run-console: | ||
docker-compose run --rm detonate_app rails console | ||
|
||
run-generate: | ||
docker-compose run --rm detonate_app rails generate $(RUN_ARGS) | ||
|
||
run-rails: | ||
docker-compose up detonate_app | ||
|
||
run-sidekiq: | ||
docker-compose up detonate_worker | ||
|
||
run: | ||
docker-compose up | ||
|
||
build: | ||
docker-compose build | ||
|
||
down: | ||
docker-compose down | ||
|
||
kill: | ||
docker-compose kill | ||
|
||
c: run-console | ||
|
||
g: run-generate | ||
|
||
s: run |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,20 @@ | ||
default: &default | ||
port: 5432 | ||
adapter: postgresql | ||
encoding: unicode | ||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | ||
url: <%= ENV['DATABASE_URL'] %> | ||
|
||
development: | ||
<<: *default | ||
database: detonate_development | ||
username: postgres | ||
host: localhost | ||
port: 5432 | ||
# Minimum log levels, in increasing order: | ||
# debug5, debug4, debug3, debug2, debug1, | ||
# log, notice, warning, error, fatal, and panic | ||
# Defaults to warning. | ||
#min_messages: notice | ||
host: detonate_db | ||
min_messages: notice | ||
|
||
test: | ||
<<: *default | ||
username: "postgres" | ||
password: "" | ||
database: detonate_test | ||
|
||
# As with config/credentials.yml, you never want to store sensitive information, | ||
# like your database password, in your source code. If your source code is | ||
# ever seen by anyone, they now have access to your database. | ||
# | ||
# Instead, provide the password or a full connection URL as an environment | ||
# variable when you boot the app. For example: | ||
# | ||
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" | ||
# | ||
# If the connection URL is provided in the special DATABASE_URL environment | ||
# variable, Rails will automatically merge its configuration values on top of | ||
# the values provided in this file. Alternatively, you can specify a connection | ||
# URL environment variable explicitly: | ||
# | ||
# production: | ||
# url: <%= ENV['MY_APP_DATABASE_URL'] %> | ||
# | ||
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database | ||
# for a full overview on how database connection configuration can be specified. | ||
# | ||
production: | ||
<<: *default | ||
database: detonate_production | ||
username: detonate | ||
password: <%= ENV['DETONATE_DATABASE_PASSWORD'] %> |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
schedule_file = "config/schedule.yml" | ||
schedule_file = 'config/schedule.yml' | ||
|
||
if File.exist?(schedule_file) && Sidekiq.server? | ||
Sidekiq::Cron::Job.load_from_hash(YAML.load_file(schedule_file)) | ||
end | ||
|
||
# Sidekiq.configure_server do |config| | ||
# config.redis = { url: 'redis://localhost:6379/0', namespace: "app3_sidekiq_#{Rails.env}" } | ||
# end | ||
Sidekiq.configure_server do |config| | ||
config.redis = { namespace: "detonate_sidekiq_#{Rails.env}" } | ||
end | ||
|
||
# Sidekiq.configure_client do |config| | ||
# config.redis = { url: 'redis://localhost:6379/0', namespace: "app3_sidekiq_#{Rails.env}" } | ||
# end | ||
Sidekiq.configure_client do |config| | ||
config.redis = { namespace: "detonate_sidekiq_#{Rails.env}" } | ||
end | ||
|
||
Sidekiq::Extensions.enable_delay! | ||
Sidekiq::Extensions.enable_delay! |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
echo "Environment: $RAILS_ENV" | ||
echo "DATABASE_URL: $DATABASE_URL" | ||
|
||
# install missing gems | ||
bundle check || bundle install --jobs 20 --retry 5 | ||
|
||
# Remove pre-existing puma/passenger server.pid | ||
rm -f $APP_PATH/tmp/pids/server.pid || true | ||
|
||
# run passed commands | ||
bundle exec ${@} |
Oops, something went wrong.