Skip to content

Commit

Permalink
add instance number to container env. fixes #1039
Browse files Browse the repository at this point in the history
  • Loading branch information
jnummelin committed Sep 27, 2016
1 parent 03a1cf6 commit 3468724
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/app/services/docker/service_creator.rb
Expand Up @@ -54,7 +54,7 @@ def service_spec(instance_number, deploy_rev, creds = nil)
log_opts: grid_service.log_opts,
pid: grid_service.pid
}
spec[:env] = build_env
spec[:env] = build_env(instance_number)
spec[:secrets] = build_secrets
overlay_cidr = nil
if grid_service.overlay_network?
Expand Down Expand Up @@ -95,12 +95,13 @@ def client

##
# @return [Array<String>]
def build_env
def build_env(instance_number)
env = grid_service.env.dup || []
env << "KONTENA_SERVICE_ID=#{grid_service.id.to_s}"
env << "KONTENA_SERVICE_NAME=#{grid_service.name}"
env << "KONTENA_GRID_NAME=#{grid_service.grid.try(:name)}"
env << "KONTENA_NODE_NAME=#{host_node.name}"
env << "KONTENA_SERVICE_INSTANCE=#{instance_number}"
env
end

Expand Down
1 change: 1 addition & 0 deletions server/spec/services/docker/service_creator_spec.rb
Expand Up @@ -131,6 +131,7 @@
expect(env).to include("KONTENA_SERVICE_NAME=#{service.name.to_s}")
expect(env).to include("KONTENA_GRID_NAME=#{service.grid.name.to_s}")
expect(env).to include("KONTENA_NODE_NAME=#{node.name.to_s}")
expect(env).to include("KONTENA_SERVICE_INSTANCE=2")
end
end

Expand Down

0 comments on commit 3468724

Please sign in to comment.