Skip to content

Commit d8e00f5

Browse files
authored
Merge pull request #5 from libgolang/issue-3
Makes plugin installable via `docker plugin install` command
2 parents 703962f + 8551038 commit d8e00f5

File tree

8 files changed

+198
-93
lines changed

8 files changed

+198
-93
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ jobs:
1313
script: ./scripts/test.sh
1414
- stage: deploy
1515
script: ./scripts/deploy.sh
16+
if: tag =~ ^v\d
17+
- stage: deploy-latest
18+
if: tag =~ ^v\d
19+
script: ./scripts/deploy.sh

README.md

Lines changed: 81 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,51 @@
55
[![Build Status](https://travis-ci.org/libgolang/docker-volume-linode.svg?branch=master)](https://travis-ci.org/libgolang/docker-volume-linode)
66

77
## Requirements
8-
- Linux (tested on Ubuntu 18.04, should work with other versions)
8+
- Linux (tested on Ubuntu 18.04, should work with other versions and distros)
99
- Docker (tested on version 17, should work with other versions)
1010

11-
## Usage
11+
## Installation
1212

13-
### Run the driver
14-
```
15-
export LINODE_TOKEN=<token from linode console>
16-
export LINODE_REGION=us-west
17-
export LINODE_LABEL=linode-machine-label-1234
18-
./docker-volume-linode
19-
```
20-
or
13+
- Install
2114

22-
```
23-
./docker-volume-linode -linode.token $TOKEN -linode.region $REGION -linode.host $LINODE_LABEL
24-
```
15+
```
16+
docker plugin install libgolang/docker-volume-linode
17+
```
18+
19+
- Configuration
2520

21+
```
22+
docker plugin set libgolang/docker-volume-linode LINODE_TOKEN=<linode token>
23+
docker plugin set libgolang/docker-volume-linode LINODE_REGION=<linode region>
24+
docker plugin set libgolang/docker-volume-linode LINODE_LABEL=<host label>
25+
```
26+
27+
- Enable
28+
29+
```
30+
docker plugin enable libgolang/docker-volume-linode
31+
```
32+
33+
34+
- Debugging Configuration
35+
36+
```
37+
docker plugin set libgolang/docker-volume-linode LOG_LEVEL=debug
38+
```
39+
40+
41+
## Usage
2642

2743
### Create Volume
44+
2845
```
2946
$ docker volume create -d linode-driver my-test-volume
30-
| my-test-volume
3147
```
48+
49+
```
50+
my-test-volume
51+
```
52+
3253
### Create 50G Volume
3354
```
3455
$ # docker volume create -o size=50 -d linode-driver my-test-volume-50
@@ -63,6 +84,52 @@ $ docker run --rm -it -v http-volume:/usr/local/apache2/htdocs/ httpd
6384
```
6485

6586

87+
88+
# Manual Installation
89+
90+
# Requirements
91+
- Install Golang: https://golang.org/
92+
- Get code and Compile: `go get -u github.com/libgolang/docker-volume-linode`
93+
94+
### Run the driver
95+
96+
```
97+
$ docker-volume-linode --linode-token=<token from linode console> --linode-region=<linode region> --linode-label=<host label>
98+
```
99+
or
100+
101+
```
102+
$ export LINODE_TOKEN=<token from linode console>
103+
$ export LINODE_REGION=<linode region>
104+
$ export LINODE_LABEL=<host label>
105+
$ docker-volume-linode
106+
```
107+
108+
109+
110+
## Debugging
111+
112+
# Enable Deug Level on plugin
113+
114+
```
115+
docker plugin set libgolang/docker-volume-linode LOG_LEVEL=debug
116+
```
117+
118+
# Enable Deug Level in manual installation
119+
```
120+
$ docker-volume-linode --linode-token=<...> --linode-region=<...> --linode-label=<...> --log-level=debug
121+
```
122+
or
123+
124+
```
125+
$ export DEBUG_LEVEL=debug
126+
$ export LINODE_REGION=<...>
127+
$ export LINODE_LABEL=<...>
128+
$ export LINODE_LABEL=<...>
129+
$ docker-volume-linode
130+
```
131+
132+
66133
## Tested On
67134
```
68135
Ubuntu 18.04 LTS

docker_push

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/build.sh

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,13 @@
11
#!/bin/bash
22

3-
set -e
3+
# set:
4+
# -e: Exit on error.
5+
# -x: Display commands.
6+
set -ex
47

58
scriptDir=`dirname $(readlink -f $0)`
69
source $scriptDir/common.sh
710

8-
##############################
9-
echo "go get -u github.com/golang/dep/cmd/dep"
10-
go get -u github.com/golang/dep/cmd/dep
11-
##############################
12-
echo "dep ensure"
13-
dep ensure
14-
##############################
15-
echo "docker build --no-cache -q -t ${PLUGIN_NAME_ROOTFS} ."
16-
docker build --no-cache -q -t ${PLUGIN_NAME_ROOTFS} .
17-
##############################
18-
echo "mkdir -p ./plugin/rootfs"
19-
mkdir -p ./plugin/rootfs
20-
##############################
21-
echo "docker create --name tmp ${PLUGIN_NAME_ROOTFS}"
22-
docker create --name tmp ${PLUGIN_NAME_ROOTFS}
23-
##############################
24-
echo "docker export tmp | tar -x -C ./plugin/rootfs"
25-
docker export tmp | tar -x -C ./plugin/rootfs
26-
##############################
27-
echo "cp config.json ./plugin/"
28-
cp config.json ./plugin/
29-
##############################
30-
echo "docker rm -vf tmp"
31-
docker rm -vf tmp
32-
##############################
33-
echo "docker plugin rm -f ${PLUGIN_NAME} || true"
34-
docker plugin rm -f ${PLUGIN_NAME} || true
35-
##############################
36-
echo "docker plugin create ${PLUGIN_NAME} ./plugin"
37-
docker plugin create ${PLUGIN_NAME} ./plugin
38-
##############################
11+
# Build Step
12+
build
13+

scripts/common.sh

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
11
#!/bin/bash
22

3-
##############################
4-
export PLUGIN_NAME_ROOTFS=docker-volume-linode:rootfs-${TRAVIS_BUILD_NUMBER}
3+
# e.g: docker-volume-linode:rootfs.30
4+
export PLUGIN_NAME_ROOTFS=docker-volume-linode:rootfs.${TRAVIS_BUILD_NUMBER}
5+
6+
# e.g: docker-volume-linode:master.30
7+
# e.g: docker-volume-linode:v1.1.30
58
export PLUGIN_NAME=libgolang/docker-volume-linode:${TRAVIS_BRANCH}.${TRAVIS_BUILD_NUMBER}
6-
export PLUGIN_NAME_TAR=docker-volume-linode_${TRAVIS_BRANCH}.${TRAVIS_BUILD_NUMBER}.tar
7-
##############################
9+
export PLUGIN_NAME_LATEST=libgolang/docker-volume-linode:latest
10+
11+
# Build Step
12+
build () {
13+
compile
14+
assemble-plugin-dir
15+
create-plugin-from-dir ${PLUGIN_NAME}
16+
}
17+
18+
# Build Latest Step
19+
build-latest () {
20+
compile
21+
assemble-plugin-dir
22+
create-plugin-from-dir ${PLUGIN_NAME_LATEST}
23+
}
24+
25+
# Deploy Step
26+
deploy () {
27+
# Login to docker
28+
echo "$DOCKER_PASSWORD" | docker login -u libgolang --password-stdin
29+
30+
# Push image
31+
docker plugin push ${PLUGIN_NAME}
32+
}
33+
34+
# Deploy Latest Tag Step
35+
deploy-latest () {
36+
# Login to docker
37+
echo "$DOCKER_PASSWORD" | docker login -u libgolang --password-stdin
38+
39+
# Push image
40+
docker plugin push ${PLUGIN_NAME_LATEST}
41+
}
42+
43+
compile () {
44+
go get -u github.com/golang/dep/cmd/dep
45+
dep ensure
46+
docker build --no-cache -q -t ${PLUGIN_NAME_ROOTFS} .
47+
}
48+
49+
assemble-plugin-dir () {
50+
# create plugin
51+
mkdir -p ./plugin/rootfs
52+
docker create --name tmp ${PLUGIN_NAME_ROOTFS}
53+
docker export tmp | tar -x -C ./plugin/rootfs
54+
cp config.json ./plugin/
55+
docker rm -vf tmp
56+
}
857

58+
create-plugin-from-dir () {
59+
docker plugin rm -f $1 || true
60+
docker plugin create $1 ./plugin
61+
}

scripts/deploy-latest.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# set:
4+
# -e: Exit on error.
5+
# -x: Display commands.
6+
set -ex
7+
8+
scriptDir=`dirname $(readlink -f $0)`
9+
source $scriptDir/common.sh
10+
11+
12+
# Deploy Step have to build again, it does not remember
13+
# the docker image built before.
14+
build
15+
16+
17+
# Deploy Step
18+
deploy-latest
19+

scripts/deploy.sh

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,19 @@
11
#!/bin/bash
22

3-
set -e
3+
# set:
4+
# -e: Exit on error.
5+
# -x: Display commands.
6+
set -ex
47

5-
##############################
68
scriptDir=`dirname $(readlink -f $0)`
79
source $scriptDir/common.sh
810

9-
##############################
10-
echo "go get -u github.com/golang/dep/cmd/dep"
11-
go get -u github.com/golang/dep/cmd/dep
12-
##############################
13-
echo "dep ensure"
14-
dep ensure
15-
##############################
16-
echo "docker build --no-cache -q -t ${PLUGIN_NAME_ROOTFS} ."
17-
docker build --no-cache -q -t ${PLUGIN_NAME_ROOTFS} .
18-
##############################
19-
echo "mkdir -p ./plugin/rootfs"
20-
mkdir -p ./plugin/rootfs
21-
##############################
22-
echo "docker create --name tmp ${PLUGIN_NAME_ROOTFS}"
23-
docker create --name tmp ${PLUGIN_NAME_ROOTFS}
24-
##############################
25-
echo "docker export tmp | tar -x -C ./plugin/rootfs"
26-
docker export tmp | tar -x -C ./plugin/rootfs
27-
##############################
28-
echo "cp config.json ./plugin/"
29-
cp config.json ./plugin/
30-
##############################
31-
echo "docker rm -vf tmp"
32-
docker rm -vf tmp
33-
##############################
34-
echo "docker plugin rm -f ${PLUGIN_NAME} || true"
35-
docker plugin rm -f ${PLUGIN_NAME} || true
36-
##############################
37-
echo "docker plugin create ${PLUGIN_NAME} ./plugin"
38-
docker plugin create ${PLUGIN_NAME} ./plugin
39-
##############################
4011

12+
# Deploy Step have to build again, it does not remember
13+
# the docker image built before.
14+
build
4115

42-
##############################
43-
echo "docker login -u libgolang --password-stdin"
44-
echo "$DOCKER_PASSWORD" | docker login -u libgolang --password-stdin
45-
echo "docker plugin push ${PLUGIN_NAME}"
46-
docker plugin push ${PLUGIN_NAME}
16+
17+
# Deploy Step
18+
deploy
4719

scripts/test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
#!/bin/bash
22

3+
# set:
4+
# -e: Exit on error.
5+
# -x: Display commands.
6+
set -ex
7+
8+
# Tools
9+
go get -u github.com/tsenart/deadcode
10+
go get -u github.com/kisielk/errcheck
11+
go get -u golang.org/x/lint/golint
12+
13+
# Run Code Tests
14+
go vet
15+
errcheck
16+
golint
17+
deadcode
18+
go test
19+
20+
# Test Plugin Functionality
21+
# ...
22+
# ...

0 commit comments

Comments
 (0)