smartmachine 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +661 -0
- data/README.md +147 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/smartmachine +3 -0
- data/lib/smart_machine/apps/app.rb +165 -181
- data/lib/smart_machine/apps/container.rb +120 -0
- data/lib/smart_machine/apps/manager.rb +182 -0
- data/lib/smart_machine/base.rb +24 -6
- data/lib/smart_machine/buildpackers/buildpacker.rb +95 -0
- data/lib/smart_machine/{engine/buildpacks → buildpackers}/rails/Dockerfile +3 -3
- data/lib/smart_machine/buildpackers/rails.rb +221 -0
- data/lib/smart_machine/commands/app.rb +112 -0
- data/lib/smart_machine/commands/buildpacker.rb +53 -0
- data/lib/smart_machine/commands/credentials.rb +17 -0
- data/lib/smart_machine/commands/docker.rb +23 -0
- data/lib/smart_machine/commands/engine.rb +27 -0
- data/lib/smart_machine/commands/grid.rb +33 -0
- data/lib/smart_machine/commands/grid_commands/elasticsearch.rb +68 -0
- data/lib/smart_machine/commands/grid_commands/minio.rb +65 -0
- data/lib/smart_machine/commands/grid_commands/mysql.rb +71 -0
- data/lib/smart_machine/commands/grid_commands/nginx.rb +53 -0
- data/lib/smart_machine/commands/grid_commands/prereceiver.rb +96 -0
- data/lib/smart_machine/commands/grid_commands/redis.rb +65 -0
- data/lib/smart_machine/commands/grid_commands/scheduler.rb +15 -0
- data/lib/smart_machine/commands/grid_commands/sub_thor.rb +15 -0
- data/lib/smart_machine/commands/machine.rb +24 -0
- data/lib/smart_machine/commands/syncer.rb +23 -0
- data/lib/smart_machine/commands/utilities.rb +37 -0
- data/lib/smart_machine/commands.rb +66 -0
- data/lib/smart_machine/configuration.rb +79 -0
- data/lib/smart_machine/credentials.rb +93 -95
- data/lib/smart_machine/docker.rb +144 -143
- data/lib/smart_machine/engine/Dockerfile +7 -5
- data/lib/smart_machine/engine.rb +104 -79
- data/lib/smart_machine/grids/elasticsearch.rb +70 -89
- data/lib/smart_machine/grids/minio.rb +79 -68
- data/lib/smart_machine/grids/mysql.rb +207 -202
- data/lib/smart_machine/grids/nginx.rb +176 -135
- data/lib/smart_machine/grids/prereceiver/Dockerfile +2 -2
- data/lib/smart_machine/grids/prereceiver/pre-receive +17 -0
- data/lib/smart_machine/grids/prereceiver.rb +169 -169
- data/lib/smart_machine/grids/redis.rb +73 -57
- data/lib/smart_machine/logger.rb +26 -26
- data/lib/smart_machine/machine.rb +128 -194
- data/lib/smart_machine/scp.rb +15 -0
- data/lib/smart_machine/ssh.rb +69 -40
- data/lib/smart_machine/syncer.rb +133 -0
- data/lib/smart_machine/templates/dotsmartmachine/Gemfile +7 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/elasticsearch.yml +5 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +0 -9
- data/lib/smart_machine/templates/dotsmartmachine/config/minio.yml +13 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/mysql/schedule.rb +3 -3
- data/lib/smart_machine/templates/dotsmartmachine/config/mysql.yml +13 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/prereceiver.yml +7 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/redis.yml +13 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +1 -1
- data/lib/smart_machine/templates/dotsmartmachine/gitignore-template +47 -0
- data/lib/smart_machine/templates/dotsmartmachine/{grids/elasticsearch/data → vendor}/.keep +0 -0
- data/lib/smart_machine/version.rb +30 -6
- data/lib/smart_machine.rb +42 -16
- metadata +97 -47
- data/CHANGELOG.rdoc +0 -0
- data/MIT-LICENSE +0 -21
- data/README.rdoc +0 -87
- data/bin/buildpacker +0 -8
- data/bin/prereceiver +0 -8
- data/bin/scheduler +0 -18
- data/bin/smartmachine +0 -81
- data/bin/smartrunner +0 -33
- data/lib/smart_machine/apps/rails.rb +0 -250
- data/lib/smart_machine/apps.rb +0 -14
- data/lib/smart_machine/boot.rb +0 -32
- data/lib/smart_machine/buildpacker.rb +0 -106
- data/lib/smart_machine/gem_version.rb +0 -17
- data/lib/smart_machine/grids.rb +0 -18
- data/lib/smart_machine/sync.rb +0 -120
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/backups/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +0 -17
- data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
- data/lib/smart_machine/user.rb +0 -38
data/lib/smart_machine/docker.rb
CHANGED
@@ -1,144 +1,145 @@
|
|
1
|
-
# The main SmartMachine Docker driver
|
2
1
|
module SmartMachine
|
3
|
-
|
4
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
end
|
2
|
+
class Docker < SmartMachine::Base
|
3
|
+
def initialize
|
4
|
+
@machine = SmartMachine::Machine.new
|
5
|
+
end
|
6
|
+
|
7
|
+
# Installing Docker!
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
# => Installation Complete
|
11
|
+
#
|
12
|
+
# Arguments:
|
13
|
+
# none
|
14
|
+
def install
|
15
|
+
puts "-----> Installing Docker"
|
16
|
+
if platform_on_machine?(os: "linux", distro_name: "debian")
|
17
|
+
install_on_linuxos(distro_name: "debian", arch: "amd64")
|
18
|
+
# elsif platform_on_machine?(os: "mac")
|
19
|
+
# install_on_macos
|
20
|
+
else
|
21
|
+
raise "Installation of docker is currently supported on Debian GNU/Linux."
|
22
|
+
end
|
23
|
+
puts "-----> Docker Installation Complete"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Uninstalling Docker!
|
27
|
+
#
|
28
|
+
# Example:
|
29
|
+
# => Uninstallation Complete
|
30
|
+
#
|
31
|
+
# Arguments:
|
32
|
+
# none
|
33
|
+
def uninstall
|
34
|
+
puts "-----> Uninstalling Docker"
|
35
|
+
if platform_on_machine?(os: "linux", distro_name: "debian")
|
36
|
+
uninstall_on_linuxos(distro_name: "debian", arch: "amd64")
|
37
|
+
# elsif platform_on_machine?(os: "mac")
|
38
|
+
# uninstall_on_macos
|
39
|
+
else
|
40
|
+
raise "Uninstallation of docker is currently supported on Debian GNU/Linux."
|
41
|
+
end
|
42
|
+
puts "-----> Docker Uninstallation Complete"
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def install_on_linuxos(distro_name:, arch:)
|
48
|
+
|
49
|
+
commands = [
|
50
|
+
"sudo apt-get -y update",
|
51
|
+
"sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common",
|
52
|
+
"curl -fsSL https://download.docker.com/linux/#{distro_name}/gpg | sudo apt-key add -",
|
53
|
+
"sudo apt-key fingerprint 0EBFCD88",
|
54
|
+
"sudo add-apt-repository \"deb [arch=#{arch}] https://download.docker.com/linux/#{distro_name} $(lsb_release -cs) stable\"",
|
55
|
+
"sudo apt-get -y update",
|
56
|
+
"sudo apt-get -y install docker-ce docker-ce-cli containerd.io",
|
57
|
+
"sudo usermod -aG docker $USER",
|
58
|
+
"docker run --rm hello-world",
|
59
|
+
"docker rmi hello-world"
|
60
|
+
]
|
61
|
+
@machine.run_on_machine(commands: commands)
|
62
|
+
|
63
|
+
puts '-----> Add the following rules to the end of the file /etc/ufw/after.rules and reload ufw using - sudo ufw reload'
|
64
|
+
puts '# BEGIN UFW AND DOCKER
|
65
|
+
*filter
|
66
|
+
:ufw-user-forward - [0:0]
|
67
|
+
:DOCKER-USER - [0:0]
|
68
|
+
-A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
69
|
+
-A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
|
70
|
+
-A DOCKER-USER -i eth0 -j ufw-user-forward
|
71
|
+
-A DOCKER-USER -i eth0 -j DROP
|
72
|
+
COMMIT
|
73
|
+
# END UFW AND DOCKER'
|
74
|
+
|
75
|
+
# puts "-----> Adding UFW rules for Docker"
|
76
|
+
# interface_name = system("ip route show | sed -e 's/^default via [0-9.]* dev \(\w\+\).*/\1/'")
|
77
|
+
# puts interface_name
|
78
|
+
|
79
|
+
# system("sed '/^# BEGIN UFW AND DOCKER/,/^# END UFW AND DOCKER/d' '/etc/ufw/after.rules'")
|
80
|
+
# system("sudo tee -a '/etc/ufw/after.rules' > /dev/null <<EOT
|
81
|
+
# # BEGIN UFW AND DOCKER
|
82
|
+
# *filter
|
83
|
+
# :ufw-user-forward - [0:0]
|
84
|
+
# :DOCKER-USER - [0:0]
|
85
|
+
# -A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
86
|
+
# -A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
|
87
|
+
# -A DOCKER-USER -i eth0 -j ufw-user-forward
|
88
|
+
# -A DOCKER-USER -i eth0 -j DROP
|
89
|
+
# COMMIT
|
90
|
+
# # END UFW AND DOCKER
|
91
|
+
# EOT")
|
92
|
+
# system("sudo ufw reload")
|
93
|
+
end
|
94
|
+
|
95
|
+
def uninstall_on_linuxos(distro_name:, arch:)
|
96
|
+
|
97
|
+
commands = [
|
98
|
+
"sudo apt-get purge docker-ce docker-ce-cli containerd.io",
|
99
|
+
"sudo apt-get autoremove",
|
100
|
+
"sudo rm -rf /var/lib/docker",
|
101
|
+
"sudo rm -rf /var/lib/containerd"
|
102
|
+
]
|
103
|
+
@machine.run_on_machine(commands: commands)
|
104
|
+
|
105
|
+
puts '-----> Remove the following rules at the end of the file /etc/ufw/after.rules and reload ufw using - sudo ufw reload'
|
106
|
+
puts '# BEGIN UFW AND DOCKER
|
107
|
+
*filter
|
108
|
+
:ufw-user-forward - [0:0]
|
109
|
+
:DOCKER-USER - [0:0]
|
110
|
+
-A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
111
|
+
-A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
|
112
|
+
-A DOCKER-USER -i eth0 -j ufw-user-forward
|
113
|
+
-A DOCKER-USER -i eth0 -j DROP
|
114
|
+
COMMIT
|
115
|
+
# END UFW AND DOCKER'
|
116
|
+
|
117
|
+
# puts "-----> Removing UFW rules for Docker"
|
118
|
+
# system("sed '/^# BEGIN UFW AND DOCKER/,/^# END UFW AND DOCKER/d' '/etc/ufw/after.rules'")
|
119
|
+
# system("sudo ufw reload")
|
120
|
+
end
|
121
|
+
|
122
|
+
# def install_on_macos
|
123
|
+
# commands = [
|
124
|
+
# "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"",
|
125
|
+
# "brew install homebrew/cask/docker",
|
126
|
+
# "brew install bash-completion",
|
127
|
+
# "brew install docker-completion",
|
128
|
+
# "open /Applications/Docker.app",
|
129
|
+
# # The docker app asks for permission after opening gui. if that can be automated then the next two statements can be uncommented and automated. Until then can't execute automatically.
|
130
|
+
# # "docker run --rm hello-world",
|
131
|
+
# # "docker rmi hello-world"
|
132
|
+
# ]
|
133
|
+
# @machine.run_on_machine(commands: commands)
|
134
|
+
# end
|
135
|
+
|
136
|
+
# def uninstall_on_macos
|
137
|
+
# commands = [
|
138
|
+
# "brew uninstall docker-completion",
|
139
|
+
# "brew uninstall bash-completion",
|
140
|
+
# "brew uninstall --zap homebrew/cask/docker"
|
141
|
+
# ]
|
142
|
+
# @machine.run_on_machine(commands: commands)
|
143
|
+
# end
|
144
|
+
end
|
145
|
+
end
|
@@ -1,26 +1,28 @@
|
|
1
1
|
FROM ruby:2.7.0-alpine3.11
|
2
|
-
LABEL maintainer="
|
2
|
+
LABEL maintainer="Gaurav Goel <gaurav@timeboard.me>"
|
3
3
|
|
4
4
|
# User
|
5
|
-
# --- Fix to change gid
|
5
|
+
# --- Fix to change docker gid to 998 (if it is in use) so that addgroup is free to create a group with docker gid.
|
6
6
|
ARG USER_NAME
|
7
7
|
ARG USER_UID
|
8
8
|
ARG DOCKER_GID
|
9
|
-
|
9
|
+
ARG DOCKER_GNAME
|
10
|
+
RUN sed -i "s/$DOCKER_GID/998/" /etc/group && \
|
10
11
|
adduser --disabled-password --gecos "" --uid "$USER_UID" "$USER_NAME" && \
|
11
|
-
addgroup --gid "$DOCKER_GID" "
|
12
|
+
addgroup --gid "$DOCKER_GID" "$DOCKER_GNAME" && adduser "$USER_NAME" "$DOCKER_GNAME"
|
12
13
|
|
13
14
|
# Essentials
|
14
15
|
RUN apk add --update build-base && \
|
15
16
|
apk add --update xz && \
|
16
17
|
apk add --update docker && \
|
17
18
|
apk add --update git && \
|
19
|
+
apk add --update rsync && \
|
18
20
|
rm -rf /var/cache/apk/*
|
19
21
|
|
20
22
|
# smartmachine gem
|
21
23
|
ARG SMARTMACHINE_VERSION
|
22
24
|
COPY ./smartmachine-$SMARTMACHINE_VERSION.gem ./smartmachine-$SMARTMACHINE_VERSION.gem
|
23
|
-
RUN gem install --no-document smartmachine-$SMARTMACHINE_VERSION.gem && \
|
25
|
+
RUN gem install --no-document ./smartmachine-$SMARTMACHINE_VERSION.gem && \
|
24
26
|
rm ./smartmachine-$SMARTMACHINE_VERSION.gem
|
25
27
|
|
26
28
|
# smartmachine master key
|
data/lib/smart_machine/engine.rb
CHANGED
@@ -1,82 +1,107 @@
|
|
1
1
|
# The main SmartMachine Engine driver
|
2
2
|
module SmartMachine
|
3
|
-
|
4
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
3
|
+
class Engine < SmartMachine::Base
|
4
|
+
def initialize
|
5
|
+
@scp = SmartMachine::SCP.new
|
6
|
+
@grids_nginx = SmartMachine::Grids::Nginx.new
|
7
|
+
@syncer = SmartMachine::Syncer.new
|
8
|
+
@machine = SmartMachine::Machine.new
|
9
|
+
|
10
|
+
@gem_cache_dir = Gem::Specification.find_by_name("smartmachine").cache_dir
|
11
|
+
@gem_cache_dir = "../smartmachine/pkg"
|
12
|
+
|
13
|
+
if platform_on_machine?(os: "linux", distro_name: "debian")
|
14
|
+
@docker_gid = "getent group docker | cut -d: -f3"
|
15
|
+
@docker_gname = "docker"
|
16
|
+
@docker_socket_path = "/var/run/docker.sock"
|
17
|
+
@remote_smartmachine_dir = "/home/`whoami`/smartmachine"
|
18
|
+
# elsif platform_on_machine?(os: "mac")
|
19
|
+
# @docker_gid = "id -g"
|
20
|
+
# @docker_gname = "staff"
|
21
|
+
# @docker_socket_path = "/Users/`whoami`/Library/Containers/com.docker.docker/Data/docker.sock"
|
22
|
+
# @remote_smartmachine_dir = "/Users/`whoami`/Desktop/smartmachine"
|
23
|
+
else
|
24
|
+
raise("OS not supported to set docker_gid, docker_gname and docker_socket_path")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def install
|
29
|
+
puts "-----> Installing SmartMachine Engine"
|
30
|
+
|
31
|
+
if @machine.run_on_machine commands: "mkdir -p #{@remote_smartmachine_dir}/tmp/engine"
|
32
|
+
@scp.upload!(local_path: "#{SmartMachine.config.gem_dir}/lib/smart_machine/engine/Dockerfile", remote_path: "~/smartmachine/tmp/engine")
|
33
|
+
@scp.upload!(local_path: "#{@gem_cache_dir}/smartmachine-#{SmartMachine.version}.gem", remote_path: "~/smartmachine/tmp/engine")
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "-----> Creating image for Engine ... "
|
37
|
+
command = [
|
38
|
+
"docker image build --quiet --tag #{engine_image_name_with_version}",
|
39
|
+
"--build-arg SMARTMACHINE_MASTER_KEY=#{SmartMachine::Credentials.new.read_key}",
|
40
|
+
"--build-arg SMARTMACHINE_VERSION=#{SmartMachine.version}",
|
41
|
+
"--build-arg USER_NAME=`id -un`",
|
42
|
+
"--build-arg USER_UID=`id -u`",
|
43
|
+
"--build-arg DOCKER_GID=`#{@docker_gid}`",
|
44
|
+
"--build-arg DOCKER_GNAME=#{@docker_gname}",
|
45
|
+
"#{@remote_smartmachine_dir}/tmp/engine"
|
46
|
+
]
|
47
|
+
@machine.run_on_machine commands: command.join(" ")
|
48
|
+
puts "done"
|
49
|
+
|
50
|
+
puts "-----> Adding Engine to PATH ... "
|
51
|
+
commands = [
|
52
|
+
"mkdir -p #{@remote_smartmachine_dir}/bin && touch #{@remote_smartmachine_dir}/bin/smartengine",
|
53
|
+
"echo '#{smartengine_binary_template}' > #{@remote_smartmachine_dir}/bin/smartengine",
|
54
|
+
"chmod +x #{@remote_smartmachine_dir}/bin/smartengine",
|
55
|
+
"sudo ln -sf #{@remote_smartmachine_dir}/bin/smartengine /usr/local/bin/smartengine",
|
56
|
+
"rm -r #{@remote_smartmachine_dir}/tmp/engine",
|
57
|
+
"smartengine --version"
|
58
|
+
]
|
59
|
+
@machine.run_on_machine(commands: commands)
|
60
|
+
puts "done"
|
61
|
+
|
62
|
+
@grids_nginx.create_htpasswd_files
|
63
|
+
|
64
|
+
@syncer.sync(initial: true)
|
65
|
+
|
66
|
+
puts "-----> SmartMachine Engine Installation Complete"
|
67
|
+
end
|
68
|
+
|
69
|
+
def uninstall
|
70
|
+
puts "-----> Uninstalling SmartMachine Engine"
|
71
|
+
|
72
|
+
commands = [
|
73
|
+
"sudo rm /usr/local/bin/smartengine",
|
74
|
+
"sudo rm #{@remote_smartmachine_dir}/bin/smartengine",
|
75
|
+
"docker rmi $(docker images -q #{engine_image_name})"
|
76
|
+
]
|
77
|
+
@machine.run_on_machine(commands: commands)
|
78
|
+
|
79
|
+
puts "-----> SmartMachine Engine Uninstallation Complete"
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def smartengine_binary_template
|
85
|
+
<<~BASH
|
86
|
+
#!/bin/bash
|
87
|
+
|
88
|
+
docker run -i --rm \
|
89
|
+
-e INSIDE_ENGINE="yes" \
|
90
|
+
-v "#{@remote_smartmachine_dir}:/home/`whoami`/machine" \
|
91
|
+
-v "#{@docker_socket_path}:/var/run/docker.sock" \
|
92
|
+
-w "/home/`whoami`/machine" \
|
93
|
+
-u `id -u` \
|
94
|
+
--entrypoint "smartmachine" \
|
95
|
+
#{engine_image_name_with_version} "$@"
|
96
|
+
BASH
|
97
|
+
end
|
98
|
+
|
99
|
+
def engine_image_name_with_version
|
100
|
+
"#{engine_image_name}:#{SmartMachine.version}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def engine_image_name
|
104
|
+
"smartmachine/smartengine"
|
105
|
+
end
|
106
|
+
end
|
82
107
|
end
|