-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to generate config files
- Loading branch information
Showing
5 changed files
with
132 additions
and
1 deletion.
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
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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dip | ||
class Generator < Thor::Group | ||
include Thor::Actions | ||
|
||
class_option :ruby, default: "latest" | ||
class_option :postgres, default: false | ||
class_option :appraisal, default: false | ||
|
||
def self.source_root | ||
File.join(__dir__, "templates") | ||
end | ||
|
||
def create_docker_compose_config | ||
template("docker-compose.yml.tt", File.join("tmp", "docker-compose.yml")) | ||
end | ||
|
||
def create_dip_config | ||
template("dip.yml.tt", File.join("tmp", "dip.yml")) | ||
end | ||
end | ||
end |
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,49 @@ | ||
version: '2' | ||
|
||
environment: | ||
BUNDLE_GEMFILE: /app/Gemfile | ||
|
||
compose: | ||
files: | ||
- docker-compose.yml | ||
|
||
interaction: | ||
app: | ||
service: app | ||
subcommands: | ||
bash: | ||
command: /usr/bin/bash | ||
console: | ||
command: ./bin/console | ||
clean: | ||
command: rm -rf Gemfile.lock<%= " gemfiles/*.gemfile.*" if options["appraisal"] %> | ||
|
||
bundle: | ||
service: app | ||
command: bundle | ||
|
||
<%- if options["appraisal"] -%> | ||
appraisal: | ||
service: app | ||
command: bundle exec appraisal | ||
|
||
<%- end -%> | ||
rspec: | ||
service: app | ||
<%- if options["appraisal"] -%> | ||
command: bundle exec appraisal bundle exec rspec | ||
<%- else -%> | ||
command: bundle exec rspec | ||
<%- end -%> | ||
|
||
rubocop: | ||
service: app | ||
command: bundle exec rubocop | ||
compose_run_options: [no-deps] | ||
|
||
provision: | ||
- dip app clean | ||
- dip bundle install | ||
<%- if options["appraisal"] -%> | ||
- dip appraisal install | ||
<%- end -%> |
34 changes: 34 additions & 0 deletions
34
lib/dip/generators/ruby/gem/templates/docker-compose.yml.tt
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,34 @@ | ||
version: '3.4' | ||
|
||
services: | ||
app: | ||
image: ruby:<%= options["ruby"] %> | ||
environment: | ||
BUNDLE_PATH: /bundle | ||
BUNDLE_CONFIG: /app/.bundle/config | ||
<%- if options["postgres"] -%> | ||
DB_HOST: db | ||
DB_NAME: docker | ||
DB_USERNAME: postgres | ||
<%- end -%> | ||
command: bash | ||
working_dir: /app | ||
volumes: | ||
- .:/app:cached | ||
- bundler_data:/bundle | ||
tmpfs: | ||
- /tmp | ||
<%- if options["postgres"] -%> | ||
depends_on: | ||
- db | ||
<%- end -%> | ||
|
||
<%- if options["postgres"] -%> | ||
db: | ||
image: postgres:<%= options["postgres"] %> | ||
environment: | ||
- POSTGRES_DB=docker | ||
|
||
<%- end -%> | ||
volumes: | ||
bundler_data: |