First
This commit is contained in:
28
lib/mrsk/commands/app.rb
Normal file
28
lib/mrsk/commands/app.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class Mrsk::Commands::App
|
||||
attr_accessor :config
|
||||
|
||||
def initialize(config)
|
||||
@config = config
|
||||
end
|
||||
|
||||
def push
|
||||
# TODO: Run 'docker buildx create --use' when needed
|
||||
"docker buildx build --push --platform=linux/amd64,linux/arm64 -t #{config.image_with_version} ."
|
||||
end
|
||||
|
||||
def pull
|
||||
"docker pull #{config.image_with_version}"
|
||||
end
|
||||
|
||||
def start
|
||||
"docker run -d --rm --name #{config.service_with_version} #{config.envs} #{config.labels} #{config.image_with_version}"
|
||||
end
|
||||
|
||||
def stop
|
||||
"docker ps -q --filter label=service=#{config.service} | xargs docker stop"
|
||||
end
|
||||
|
||||
def info
|
||||
"docker ps --filter label=service=#{config.service}"
|
||||
end
|
||||
end
|
||||
10
lib/mrsk/commands/registry.rb
Normal file
10
lib/mrsk/commands/registry.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Mrsk::Commands::Registry
|
||||
def login
|
||||
if (user = ENV["DOCKER_USER"]).present? && (password = ENV["DOCKER_PASSWORD"]).present?
|
||||
# FIXME: Find a way to hide PW so it's not shown on terminal
|
||||
"docker login -u #{user} -p #{password}"
|
||||
else
|
||||
raise ArgumentError, "Missing DOCKER_USER or DOCKER_PASSWORD in ENV"
|
||||
end
|
||||
end
|
||||
end
|
||||
17
lib/mrsk/commands/traefik.rb
Normal file
17
lib/mrsk/commands/traefik.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Mrsk::Commands::Traefik
|
||||
def start
|
||||
"docker run --name traefik " +
|
||||
"--rm -d " +
|
||||
"-p 80:80 " +
|
||||
"-v /var/run/docker.sock:/var/run/docker.sock " +
|
||||
"traefik --providers.docker"
|
||||
end
|
||||
|
||||
def stop
|
||||
"docker container stop traefik"
|
||||
end
|
||||
|
||||
def info
|
||||
"docker ps --filter name=traefik"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user