Skip to content

Commit

Permalink
Support: Deploying sindan/visualization on kubernetes
Browse files Browse the repository at this point in the history
Signed-off-by: mi2428 <[email protected]>
  • Loading branch information
mi2428 committed Aug 15, 2019
1 parent 97e0442 commit 88f5829
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ build:
docker-compose pull mysql
$(BUILDKIT_DOCKER_BUILD) fluentd --no-cache -t $(SINDAN_FLUENTD_TAG)
$(BUILDKIT_DOCKER_BUILD) visualization --no-cache -t $(SINDAN_VISUALIZATION_TAG) \
--build-arg BUILDTIME_RAILS_SECRETKEY_FILE=/run/secrets/rails_secret_key_base \
--build-arg BUILDTIME_DB_PASSWORD_FILE=/run/secrets/db_password \
--secret id=rails_secret,src=.secrets/rails_secret_key_base.txt \
--secret id=db_pass,src=.secrets/db_password.txt

Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ services:
- accounts
env_file:
- .env
environment:
DB_PASSWORD_FILE: "/run/secrets/db_password"
RAILS_SECRETKEY_FILE: "/run/secrets/rails_secret_key_base"
ACCOUNTS_FILE: "/run/secrets/accounts"
command: bundle exec rails s -p 3000 -b '0.0.0.0'
healthcheck:
<<: *default-healthcheck
Expand Down
6 changes: 6 additions & 0 deletions visualization/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
FROM ruby:2.6.3-alpine as builder
LABEL maintainer "mi2428 <[email protected]>"

ARG BUILDTIME_RAILS_SECRETKEY_FILE
ENV RAILS_SECRETKEY_FILE=$BUILDTIME_RAILS_SECRETKEY_FILE

ARG BUILDTIME_DB_PASSWORD_FILE
ENV DB_PASSWORD_FILE=$BUILDTIME_DB_PASSWORD_FILE

ENV BUNDLE_JOBS=4
ENV RAILS_ENV=production

Expand Down
2 changes: 1 addition & 1 deletion visualization/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ production:
<<: *default
database: <%= ENV['DB_NAME'] %>
username: <%= ENV['DB_GRANTED_USER'] %>
password: <%= File.open('/run/secrets/db_password').read.chomp %>
password: <%= File.open(ENV['DB_PASSWORD_FILE']).read.chomp %>
2 changes: 1 addition & 1 deletion visualization/secrets.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
production:
secret_key_base: <%= File.open('/run/secrets/rails_secret_key_base').read.chomp %>
secret_key_base: <%= File.open(ENV['RAILS_SECRETKEY_FILE']).read.chomp %>
2 changes: 1 addition & 1 deletion visualization/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'yaml'
if User.count.zero?
puts '-- Registering default users'
YAML.load_file('/run/secrets/accounts')['accounts'].each do |account|
YAML.load_file(ENV['ACCOUNTS_FILE'])['accounts'].each do |account|
User.create(login: account['username'], email: account['email'], password: account['password'])
end
end

0 comments on commit 88f5829

Please sign in to comment.