Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ホスティングサービスのインフラ環境を再構築!

 ホスティングサービスのインフラ環境を再構築!

Takayuki Yoshioka

June 24, 2020
Tweet

More Decks by Takayuki Yoshioka

Other Decks in Technology

Transcript

  1. ΞδΣϯμ  ߏங  ߏ੒ਤͷ঺հʢ#FGPSF "GUFSʣ  ϙΠϯτ  3FENJOF

    3BJMT ͷίϯςφԽ  Ϛϧνςφϯτʹ͍ͭͯ  ӡ༻  $PEF1JQFMJOF  4UFQ'VODUJPOT  .JHSBUJPOͷ࣮ࢪํ๏ ϗεςΟϯάαʔϏεͷΠϯϑϥ؀ڥΛ࠶ߏஙʂ
  2. AWS Cloud Internet Amazon RDS Proxy Server (EC2) App Server

    (EC2) ϗεςΟϯάαʔϏε αʔϏεఏڙதͷγεςϜͳͷͰৄࡉ΅΍͔͠ؾຯʜ Mail Server (EC2)
  3. db: name: [db_name] user: [user_name] password: [password] s3: bucket: [user_bucket]

    folder: [user_folder] property: sub_domain: [sub_domain] limit_ips: - ‘192.168.xx.xx' - '192.168.xx.xx' ઃఆ৘ใ͸4ʹอଘ ˞αϯϓϧΠϝʔδ
  4. $POGϑΝΠϧΛੜ੒ ˞αϯϓϧΠϝʔδ <VirtualHost *:80> ServerName siteA.example.jp DocumentRoot /var/lib/siteA/public RailsEnv production

    PassengerEnabled on SetEnv RAILS_DB db001 SetEnv RAILS_DB_USERNAME dbuser001 SetEnv RAILS_DB_PASSWORD xxxxxxxx SetEnv S3_FOLDER_NAME user001 ... </VirtualHost>
  5. 3FENJOFͷઃఆϑΝΠϧͷมߋ # database.yml production: adapter: postgresql database: <%= ENV['RAILS_DB'] %>

    username: <%= ENV['RAILS_DB_USERNAME'] %> password: <%= ENV['RAILS_DB_PASSWORD'] %> host: <%= ENV['RAILS_DB_HOST'] %> # s3.yml production: bucket: <%= ENV['S3_BUCKET_NAME'] %> folder: <%= ENV['S3_FOLDER_NAME'] %> ˞αϯϓϧΠϝʔδ
  6. %PDLFSͷߏ੒ͷ࿩ … if [ $DB_CREATE = 'true' ]; then bundle

    exec rake db:create fi if [ $DB_MIGRATE = 'true' ]; then bundle exec rake db:migrate bundle exec rake redmine:plugins fi … b&/503:10*/5`ʹ%#ઃఆܥͷίϚϯυΛ͋Β͔͡Ί࢓ࠐΜͰ͓͘ FOUSZQPJOUTI
  7. %PDLFSͷߏ੒ͷ࿩ "NB[PO-BNCEB task_prop = { cluster: cluster_name, task_definition: task_def_name, launch_type:

    "Fargate", overrides: { container_overrides: [ { name: [redmine_container_name], command: [ "rake", "redmine:load_default_data"], environment: [ { name: "RAILS_DB", value: db }, { name: "RAILS_DB_USERNAME", value: user }, { name: "RAILS_DB_PASSWORD", value: password }, { name: "DB_CREATE", value: 'true'}, { name: "DB_MIGRATE", value: 'true'}, ] }, ], }, network_configuration: network_config, } client = Aws::ECS::Client.new() client.run_task(task_prop) ࡞੒ࡁΈͷ5BTL%FpOJUJPOΛར༻ͯ͠ ৽نొ࿥ɺ.JHSBUJPOͷ࣮ߦͳͲ͕Ͱ͖Δɻ