Module: RubyYacht::Plugins::MySQL

Defined in:
lib/ruby_yacht/plugins/mysql.rb

Overview

This module provides the plugin for managing MySQL databases.

Class Method Summary collapse

Class Method Details

.loadObject

This method loads the configuration for the MySQL plugin.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby_yacht/plugins/mysql.rb', line 5

def self.load
  RubyYacht.configure do
    server_type :mysql do
      container_type :database
      baseline_image 'mysql'
      server_default port: 3306
    end
  end

  RubyYacht.configure do
    add_hooks(database_server_type: :mysql, container_type: :database, script_folder: File.join(File.dirname(__FILE__), 'mysql', 'scripts')) do
      during(:install_libraries) do
        set_environment_variable 'DEBIAN_FRONTEND', 'noninteractive'
        command 'apt-get install -y mysql-server'
      end
      during(:create_databases) { run_script :bash, 'setup.bash' }

      before(:startup) do
        set_environment_variable('MYSQL_PORT') { @database.port }
      end
      
      during(:startup) { command 'mysqld_safe --bind-address=0.0.0.0 --port=$MYSQL_PORT' }

      during :install_libraries do
        container_type :app
        command 'apt-get install -y mysql-client'
      end
    end
  end
end