Handle empty database password properly, don't try to run docker-compose inside the container

This commit is contained in:
Jyri-Petteri Paloposki 2020-07-19 21:30:24 +03:00
parent 53c7c94306
commit 85e104006c
7 changed files with 15 additions and 8 deletions

View file

@ -5,6 +5,8 @@ RUN bundle config --global frozen 1
WORKDIR /app WORKDIR /app
RUN touch /etc/app-env
COPY Gemfile* /app/ COPY Gemfile* /app/
RUN gem install bundler RUN gem install bundler
RUN bundle install --jobs 4 RUN bundle install --jobs 4
@ -17,8 +19,7 @@ COPY config/site.docker.yml /app/config/site.yml
RUN RAILS_ENV=production bundle exec rake assets:precompile RUN RAILS_ENV=production bundle exec rake assets:precompile
COPY docker-entrypoint.sh / ENTRYPOINT ["/app/docker-entrypoint.sh"]
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 3000 EXPOSE 3000

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
if File.exist?("#{__dir__}/../.use-docker") if File.exist?("#{__dir__}/../.use-docker")
exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) unless File.exist?("/etc/app-env")
end end
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle') load Gem.bin_path('bundler', 'bundle')

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
if File.exist?("#{__dir__}/../.use-docker") if File.exist?("#{__dir__}/../.use-docker")
exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) unless File.exist?("/etc/app-env")
end end
APP_PATH = File.expand_path('../config/application', __dir__) APP_PATH = File.expand_path('../config/application', __dir__)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
if File.exist?("#{__dir__}/../.use-docker") if File.exist?("#{__dir__}/../.use-docker")
exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) unless File.exist?("/etc/app-env")
end end
require_relative '../config/boot' require_relative '../config/boot'
require 'rake' require 'rake'

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
if File.exist?("#{__dir__}/../.use-docker") if File.exist?("#{__dir__}/../.use-docker")
exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) exec("#{__dir__}/../script/docker-environment", $PROGRAM_NAME, *ARGV) unless File.exist?("/etc/app-env")
end end
# This file loads spring without using Bundler, in order to be fast # This file loads spring without using Bundler, in order to be fast

View file

@ -11,8 +11,9 @@ services:
build: . build: .
environment: environment:
DATABASE_USERNAME: root DATABASE_USERNAME: root
DATABASE_PASSWORD_EMPTY: 1
volumes: volumes:
- ${VOLUME:-.:/app} - ${VOLUME:-.:/app}:Z
ports: ports:
- 3000:3000 - 3000:3000
depends_on: depends_on:

View file

@ -5,7 +5,12 @@ export DATABASE_NAME=${DATABASE_NAME:-tracks}
export DATABASE_HOST=${DATABASE_HOST:-db} export DATABASE_HOST=${DATABASE_HOST:-db}
export DATABASE_PORT=${DATABASE_PORT:-3306} export DATABASE_PORT=${DATABASE_PORT:-3306}
export DATABASE_USERNAME=${DATABASE_USERNAME:-tracks} export DATABASE_USERNAME=${DATABASE_USERNAME:-tracks}
if [ "$DATABASE_PASSWORD_EMPTY" != 1 ];
then
export DATABASE_PASSWORD=${DATABASE_PASSWORD:-password} export DATABASE_PASSWORD=${DATABASE_PASSWORD:-password}
else
export DATABASE_PASSWORD=""
fi
export DATABASE_TYPE=${DATABASE_TYPE:-mysql2} export DATABASE_TYPE=${DATABASE_TYPE:-mysql2}
export DATABASE_ENCODING=${DATABASE_ENCODING:-utf8} export DATABASE_ENCODING=${DATABASE_ENCODING:-utf8}