Skip to content

Commit

Permalink
concat registry with image
Browse files Browse the repository at this point in the history
  • Loading branch information
openhoat committed Mar 9, 2020
1 parent 736bb3f commit 55c0c85
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ $ portainer image-list | jq "[.[] | {id: .Id, image: .Image}]" | prettyoutput
Example of a web application using a redis database :

```sh
$ portainer container-deploy my.private-registry.io/my-image:0.0.1 my-container \    master 
$ portainer container-deploy my-image:0.0.1 my-container \    master 
--registry 'my.private-registry.io' \
--hostConfig '{ "Links": ["redis-server:redis"], "RestartPolicy": { "Name": "unless-stopped" } }' \
--env '["APP_ENV=staging", "REDIS_HOST=redis"]' \
Expand All @@ -142,7 +142,7 @@ Some environment variables are supported by the command to override settings, or
- PORTAINER_JWT : portainer JWT token (obtained in authentication result, and usually available for 8 hours)
- PORTAINER_USERNAME : username of the portainer account to use when an authentication is needed (to generate a new JWT)
- PORTAINER_PASSWORD : password of the portainer account to use when an authentication is needed (to generate a new JWT)
- PORTAINER_REGISTRY_SERVER : docker private registry server hostname
- PORTAINER_DOCKER_REGISTRY : docker registry server hostname
- ENCRYPTION_KEY : encryption key to use to encrypt / decrypt passwords saved in settings file
- LOG_LEVEL : log level
- LANG : preferred lang to use (aliases : LC_ALL, LC_MESSAGES, LANGUAGE)
Expand Down Expand Up @@ -241,7 +241,7 @@ Set portainer host options.
- params :

- from : string
- registryAuth? : string
- registry? : string
- data? : any
- query? : any
- headers? : any
Expand Down
6 changes: 5 additions & 1 deletion src/main/api/docker-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Options } from 'got'
import { compact } from 'lodash'
import {
ApiClientParams,
DockerApiClientable,
Expand Down Expand Up @@ -80,7 +81,10 @@ class DockerApiClient implements DockerApiClientable {
const qs = { ...params.query }
const headers = { ...params.headers }
if (params.from) {
Object.assign(qs, { fromImage: params.from })
const fromImage = compact(
(params.registry ? params.registry.split('/') : []).concat(params.from.split('/')),
).join('/')
Object.assign(qs, { fromImage })
}
if (params.registry) {
Object.assign(headers, {
Expand Down
2 changes: 1 addition & 1 deletion src/main/cli/commands/container/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const dockerStartContainer: CommandSpecFactory = (portainer: PortainerApiClienta
alias: 'r',
type: 'string',
description: __('Docker registry server'),
default: process.env.PORTAINER_REGISTRY_SERVER,
default: process.env.PORTAINER_DOCKER_REGISTRY,
},
})
return args
Expand Down
2 changes: 1 addition & 1 deletion src/main/cli/commands/image/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const dockerCreateImage: CommandSpecFactory = (portainer: PortainerApiClientable
alias: 'r',
type: 'string',
description: __('Docker registry server'),
default: process.env.PORTAINER_REGISTRY_SERVER,
default: process.env.PORTAINER_DOCKER_REGISTRY,
},
})
return args
Expand Down
2 changes: 1 addition & 1 deletion src/main/types/docker-api-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DockerApiClientable {
env?: any
} & ApiClientParams,
): Promise<Response>
createImage(params: { from: string; registryAuth?: string } & ApiClientParams): Promise<Response>
createImage(params: { from: string; registry?: string } & ApiClientParams): Promise<Response>
deployContainer(
params: {
image: string
Expand Down

0 comments on commit 55c0c85

Please sign in to comment.