Skip to content

Commit

Permalink
Merge pull request #43 from markbirbeck/42-host-option
Browse files Browse the repository at this point in the history
42 host option
  • Loading branch information
markbirbeck authored Jul 12, 2018
2 parents 14d39c2 + 4cb62d3 commit b4685c4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v0.7.0] - 2018-07-12
### Added
- Add option to specify host/swarm (#42).

## [v0.6.0] - 2018-07-12
### Added
- Add option to remove service when complete (#5).
Expand Down Expand Up @@ -40,10 +44,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add CLI parameters (#1).

[Unreleased]: https://github.com/markbirbeck/docker-job/compare/v0.6.0...HEAD
[v0.2.0]: https://github.com/markbirbeck/docker-job/compare/v0.1.0...v0.2.0
[v0.2.1]: https://github.com/markbirbeck/docker-job/compare/v0.2.0...v0.2.1
[v0.3.1]: https://github.com/markbirbeck/docker-job/compare/v0.2.1...v0.3.1
[v0.4.1]: https://github.com/markbirbeck/docker-job/compare/v0.3.1...v0.4.1
[v0.5.0]: https://github.com/markbirbeck/docker-job/compare/v0.4.1...v0.5.0
[v0.6.0]: https://github.com/markbirbeck/docker-job/compare/v0.5.0...v0.6.0
[v0.7.0]: https://github.com/markbirbeck/docker-job/compare/v0.6.0...v0.7.0
[Unreleased]: https://github.com/markbirbeck/docker-job/compare/v0.7.0...HEAD
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ dj \
docker-compose up
```

To use a different host, set `-H` or --`host`:

```shell
dj -H http://swarm:2375 --rm hello-world
```

Note that for the moment the value must include the protocol and port.

## Swarm on AWS

To use a swarm that is running on AWS, create an SSH tunnel with the `---ssh-*` options. For example:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docker-job",
"version": "0.6.0",
"version": "0.7.0",
"description": "Run a single job as a Docker Service on Docker Swarm",
"bin": {
"dj": "./src/bin/cli.js"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const ServiceClient = require('./service-client')

const main = async (options, config) => {
if (options.host) {
process.env.DOCKER_HOST = options.host
}

const serviceClient = await new ServiceClient.Builder(config).build()
let id;

Expand Down
1 change: 1 addition & 0 deletions src/lib/option-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const commandLineArgs = require('command-line-args')
const optionDefinitions = [
{ name: 'detach', alias: 'd', type: Boolean },
{ name: 'env', alias: 'e', type: String, lazyMultiple: true },
{ name: 'host', alias: 'H', type: String },
{ name: 'name', type: String },
{ name: 'replicas', type: Number, defaultValue: 1 },
{ name: 'repeat-until', type: String },
Expand Down
11 changes: 11 additions & 0 deletions test/unit/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ tap.test('cli', t => {
t.end()
})

t.test('host', t => {
const config = options('-H swarm hello-world'.split(' '))
t.same(config, {
args: [],
replicas: 1,
host: 'swarm',
image: 'hello-world'
})
t.end()
})

t.test('logs', t => {
const config = options('--showlogs hello-world'.split(' '))
t.same(config, {
Expand Down

0 comments on commit b4685c4

Please sign in to comment.