Sha256: a7c065f6236195c049511d4ec45dfb691fde884e20b2ad170dcad4a9114187c0
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Floe class Workflow class Runner class Docker < Floe::Workflow::Runner def initialize(options = {}) require "awesome_spawn" require "tempfile" super @network = options.fetch("network", "bridge") end def run!(resource, env = {}, secrets = {}) raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://") image = resource.sub("docker://", "") params = ["run", :rm] params += [[:net, "host"]] if network == "host" params += env.map { |k, v| [:e, "#{k}=#{v}"] } if env secrets_file = nil if secrets && !secrets.empty? secrets_file = Tempfile.new secrets_file.write(secrets.to_json) secrets_file.flush params << [:e, "_CREDENTIALS=/run/secrets"] params << [:v, "#{secrets_file.path}:/run/secrets:z"] end params << image logger.debug("Running docker: #{AwesomeSpawn.build_command_line("docker", params)}") result = AwesomeSpawn.run!("docker", :params => params) [result.exit_status, result.output] ensure secrets_file&.close! end private attr_reader :network end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
floe-0.3.1 | lib/floe/workflow/runner/docker.rb |