Skip to content

Commit

Permalink
Move Config to Compose File (#28)
Browse files Browse the repository at this point in the history
* Move most config to compose file from .env

* Remove append_to_env method

* clean up new line

* Update Changelog
  • Loading branch information
Nate Vick authored Aug 8, 2020
1 parent 40d55b3 commit b61efa9
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
### Changed
- default to exposing only necessary ports [PR26](https://github.com/hintmedia/railsdock/pull/26)
- move most config to compose file [PR28](https://github.com/hintmedia/railsdock/pull/28)
### Deprecated
### Removed
### Fixed
Expand Down
7 changes: 0 additions & 7 deletions lib/railsdock/commands/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def execute(input: $stdin, output: $stdout)
inject_driver_config(service)
append_erb_to_compose_file(service)
file.inject_into_file('./docker-compose.yml', "\n #{service}:", after: "\nvolumes:")
append_service_config_to_env(service)
if type == :database
copy_db_yml("#{BASE_TEMPLATE_DIR}/#{service}/database.yml.erb")
inject_db_script_into_entrypoint(service)
Expand Down Expand Up @@ -129,12 +128,6 @@ def append_erb_to_compose_file(service)
file.inject_into_file('./docker-compose.yml', " - #{service}\n", after: "depends_on:\n")
end

def append_service_config_to_env(service)
file.safe_append_to_file('./.env') do
::File.binread("#{BASE_TEMPLATE_DIR}/#{service}/#{service}.env")
end
end

def prompt_for_dockerfile_directory
prompt.ask('Where would you like your docker container configuration files to live?') do |q|
q.default './docker/'
Expand Down
14 changes: 1 addition & 13 deletions lib/railsdock/templates/install/default/default.env.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@ COMPOSE_PATH_SEPARATOR=<%= is_windows? ? ';' : ':' %>
# Define the prefix of container names. This is useful when there are multiple projects using railsdock
COMPOSE_PROJECT_NAME=<%= app_name %>

###############################################################################
######################### Containers Customization ############################
###############################################################################


### RUBY ######################################################################
# Select a Ruby Version of the Ruby container. Accepted values: 2.2.x-2.7.x
### User Configuration ######################################################

RAILSDOCK_RUBY_VERSION=<%= ruby_version %>
BUNDLE_JOBS=10
BUNDLE_RETRY=3
RAILS_SERVER_HOST_PORT=3000
RUBY_UID=<%= uid %>
RUBY_GID=<%= uid %>
# Select a Node Version for the Ruby container. Accepted values: 8-13
RAILSDOCK_NODE_VERSION=12
10 changes: 5 additions & 5 deletions lib/railsdock/templates/install/default/docker-compose.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ x-ruby: &ruby-base
build:
context: <%= dockerfile_dir %>ruby
args:
- RAILSDOCK_RUBY_VERSION=${RAILSDOCK_RUBY_VERSION}
- RAILSDOCK_NODE_VERSION=${RAILSDOCK_NODE_VERSION}
- RAILSDOCK_BUNDLE_JOBS=${BUNDLE_JOBS}
- RAILSDOCK_BUNDLE_RETRY=${BUNDLE_RETRY}
- RAILSDOCK_RUBY_VERSION=<%= ruby_version %>
- RAILSDOCK_NODE_VERSION=12
- RAILSDOCK_BUNDLE_JOBS=10
- RAILSDOCK_BUNDLE_RETRY=3
- RUBY_UID=${RUBY_UID}
- RUBY_GID=${RUBY_GID}
volumes:
Expand Down Expand Up @@ -36,4 +36,4 @@ services:
command: bundle exec rails server -p 3000 -b '0.0.0.0'
entrypoint: ./docker/ruby/entrypoint.sh
ports:
- "${RAILS_SERVER_HOST_PORT}:3000"
- "3000:3000"
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
build:
context: <%= dockerfile_dir %>memcached
args:
- MEMCACHED_VERSION=${MEMCACHED_VERSION}
- MEMCACHED_VERSION=1.5
volumes:
- memcached:/var/lib/memcached
5 changes: 0 additions & 5 deletions lib/railsdock/templates/install/memcached/memcached.env

This file was deleted.

4 changes: 2 additions & 2 deletions lib/railsdock/templates/install/mysql/docker-compose.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
build:
context: <%= dockerfile_dir %>mysql
args:
- MYSQL_VERSION=${MYSQL_VERSION}
- MYSQL_VERSION=5.7
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_ROOT_PASSWORD=Password1
volumes:
- mysql:/var/lib/mysql
6 changes: 0 additions & 6 deletions lib/railsdock/templates/install/mysql/mysql.env

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
build:
context: <%= dockerfile_dir %>postgres
args:
- POSTGRES_VERSION=${POSTGRES_VERSION}
- POSTGRES_VERSION=12
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
Expand Down
5 changes: 0 additions & 5 deletions lib/railsdock/templates/install/postgres/postgres.env

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
build:
context: <%= dockerfile_dir %>redis
args:
- REDIS_VERSION=${REDIS_VERSION}
- REDIS_VERSION=5
volumes:
- redis:/data
5 changes: 0 additions & 5 deletions lib/railsdock/templates/install/redis/redis.env

This file was deleted.

0 comments on commit b61efa9

Please sign in to comment.