Commit c7b82600 authored by Armand Grillet's avatar Armand Grillet
Browse files

Swarm is ready

parent 229a0413
......@@ -62,14 +62,14 @@ As we do not have an HTTPS certification yet, you need to allow insecure registr
```zsh
sudo nano /etc/default/docker
```
Then modify the line concerning DOCKER_OPTS to have: ```DOCKER_OPTS="--insecure-registry cargo.irisa.fr:5000"```.
Then modify the line concerning DOCKER_OPTS to have: ```DOCKER_OPTS="--insecure-registry <registry_ip>:5000"```.
####Debian >= v8
```zsh
sudo nano /lib/systemd/system/docker.service
```
Change one line to have ```ExecStart=/usr/bin/docker --insecure-registry myregistry:5000 -d -H fd://```
Change one line to have ```ExecStart=/usr/bin/docker --insecure-registry <registry_ip>:5000 -d -H fd://```
```zsh
sudo systemctl daemon-reload
......@@ -127,5 +127,5 @@ docker pull registry
When running the registry, you need to mount a datastore:
```zsh
docker run -d -p 5000:5000 -e SETTING_FLAVOR=dev -e STORAGE_PATH=/the_folder_of/your_choice_on_container/ -v /the_folder_of/your_choice/on_host:/the_folder_of/your_choice_on_container/ registry:latest
docker run -d -p 5000:5000 -e SETTING_FLAVOR=dev -e STORAGE_PATH=/osef/ -v /home/allgo/docker/:/osef/ registry:latest
```
# -*- encoding : utf-8 -*-
# -*- encoding : utf-8 -*-
require 'docker'
class JobWorker < ActiveJob::Base
queue_as :jobs_queue
......@@ -8,32 +9,27 @@ class JobWorker < ActiveJob::Base
job_inst.update!(status: 'in progress')
if job_inst.webapp.status == 2 && job_inst.webapp.ipadress.nil? #not in edit mode
puts "Running the job on the worker"
Docker.url = Rails.configuration.url_worker0
container = Docker::Container.create(
"Image" => "#{Rails.configuration.docker_registry}/allgo/#{job_inst.webapp.docker_name}:#{job_inst.webapp.version.to_f}",
"Binds" => "#{job_inst.path}:/tmp",
"WorkingDir" => "/tmp"
)
container.start
else
puts "Running the job on the sandbox"
cmd = "#{Rails.configuration.connect_sandbox} \""
#cmd = "#{Rails.configuration.connect_worker} run --rm -v #{job_inst.path}:/tmp -w /tmp "
cmd += "docker run --rm -v #{job_inst.path}:/tmp -w /tmp "
#cmd += "#{Rails.configuration.docker_registry}/#{job_inst.webapp.docker_name}:#{job_inst.webapp.version.to_f} "
cmd += "#{Rails.configuration.docker_registry}/allgo/#{job_inst.webapp.docker_name}:#{job_inst.webapp.version} "
cmd += "#{job_inst.webapp.entrypoint} #{job_inst.param} \""
# cmd += "/bin/#{j.webapp.docker_name} #{j.param}"
#launch the job
system cmd
puts "#{cmd}"
#log = `#{cmd}`
#puts log
#File.open("#{job_inst.path}/allgo.log", 'w') { |file| file.write(log) }
#IO.popen('cmd') { |io| while (line = io.gets) do log+= line end }
# XXX push log in db
cmd = "docker -H #{Rails.configuration.url_swarm} run "
else # We're editing thus using the sandbox
cmd = "#{Rails.configuration.connect_sandbox} \"docker run "
end
cmd += "--rm -v #{job_inst.path}:/tmp -w /tmp "
cmd += "#{Rails.configuration.docker_registry}/allgo/#{job_inst.webapp.docker_name}:#{job_inst.webapp.version} "
cmd += "#{job_inst.webapp.entrypoint} #{job_inst.param} "
unless job_inst.webapp.status == 2 && job_inst.webapp.ipadress.nil? #in edit mode
cmd += "\""
end
#launch the job
system cmd
puts "#{cmd}"
#log = `#{cmd}`
#puts log
#File.open("#{job_inst.path}/allgo.log", 'w') { |file| file.write(log) }
#IO.popen('cmd') { |io| while (line = io.gets) do log+= line end }
# XXX push log in db
job_inst.update!(status: 'finish')
# if job_inst.webapp.status == 2 && job_inst.webapp.ipadress.nil? #not in edit mode
......
......@@ -42,18 +42,15 @@ Allgo::Application.configure do
config.assets.css_compressor = :sass
config.connection_prefix = "ssh allgo"
config.worker0 = "192.168.56.104"
config.worker1 = "192.168.56.106"
config.workers = ["#{Rails.configuration.worker0}","#{Rails.configuration.worker1}"]
config.sandbox = "192.168.56.107"
config.docker_registry = "192.168.56.105:5000"
config.connect_sandbox = "#{Rails.configuration.connection_prefix}@#{Rails.configuration.sandbox}"
config.connect_worker = "#{Rails.configuration.connection_prefix}@#{Rails.configuration.worker0}"
config.connect_woody = "ssh agrillet@localhost"
# config.url_sandbox = "tcp://192.168.56.107:5000" # Not used yet as we still use SSH with the sandbox
config.url_worker0 = "tcp://192.168.56.104:5000"
config.url_swarm = "tcp://0.0.0.0:2375"
config.active_record.raise_in_transactional_callbacks = true
config.active_record.raise_in_transactional_callbacks = true
# + # Asset digests allow you to set far-future HTTP expiration dates on all assets,
# + # yet still be able to expire them through the digest params.
......
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150414144903) do
ActiveRecord::Schema.define(version: 20150513081058) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
......@@ -123,6 +123,7 @@ ActiveRecord::Schema.define(version: 20150414144903) do
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.text "sshkey", limit: 65535
t.string "auth_token", limit: 255
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment