Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit 468ca36

Browse files
committed
use multistage builds
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
1 parent c22cf42 commit 468ca36

File tree

4 files changed

+32
-43
lines changed

4 files changed

+32
-43
lines changed

.travis/integration.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,55 @@
33
set -e
44
set -x
55

6+
TAG=test
7+
8+
# before_install
9+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
10+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
11+
sudo apt-get update
12+
sudo apt-get -y install docker-ce
13+
614
# install
715
docker pull rastasheep/ubuntu-sshd:14.04
816
docker pull busybox
917

1018
#script
1119

1220
# make the plugin
13-
make
21+
PLUGIN_TAG=$TAG make
1422
# enable the plugin
15-
make enable
23+
docker plugin enable vieux/sshfs:$TAG
1624
# list plugins
1725
docker plugin ls
1826
# start sshd
1927
docker run -d -p 2222:22 rastasheep/ubuntu-sshd:14.04
2028

2129
# test1: simple
22-
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
30+
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
2331
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
2432
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
2533
sudo cat /var/lib/docker/plugins/sshfs-state.json
2634
docker volume rm sshvolume
2735

2836
# test2: allow_other
29-
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
37+
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
3038
docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
3139
docker run --rm -v sshvolume:/read -u nobody busybox grep -Fxq hello /read/world
3240
sudo cat /var/lib/docker/plugins/sshfs-state.json
3341
docker volume rm sshvolume
3442

3543
# test3: compression
36-
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
44+
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
3745
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
3846
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
3947
sudo cat /var/lib/docker/plugins/sshfs-state.json
4048
docker volume rm sshvolume
4149

4250
# test4: source
43-
docker plugin disable vieux/sshfs:next
44-
docker plugin set vieux/sshfs:next state.source=/tmp
45-
docker plugin enable vieux/sshfs:next
46-
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
51+
docker plugin disable vieux/sshfs:$TAG
52+
docker plugin set vieux/sshfs:$TAG state.source=/tmp
53+
docker plugin enable vieux/sshfs:$TAG
54+
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
4755
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
4856
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
4957
sudo cat /tmp/sshfs-state.json

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
FROM alpine
1+
FROM golang:1.9-alpine as builder
2+
COPY . /go/src/github.com/vieux/docker-volume-sshfs
3+
WORKDIR /go/src/github.com/vieux/docker-volume-sshfs
4+
RUN set -ex \
5+
&& apk add --no-cache --virtual .build-deps \
6+
gcc libc-dev \
7+
&& go install --ldflags '-extldflags "-static"' \
8+
&& apk del .build-deps
9+
CMD ["/go/bin/docker-volume-sshfs"]
210

11+
FROM alpine
312
RUN apk update && apk add sshfs
4-
513
RUN mkdir -p /run/docker/plugins /mnt/state /mnt/volumes
6-
7-
COPY docker-volume-sshfs docker-volume-sshfs
8-
14+
COPY --from=builder /go/bin/docker-volume-sshfs .
915
CMD ["docker-volume-sshfs"]

Dockerfile.dev

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

Makefile

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
PLUGIN_NAME=vieux/sshfs
2-
PLUGIN_TAG=next
1+
PLUGIN_NAME = vieux/sshfs
2+
PLUGIN_TAG ?= next
33

4-
all: clean docker rootfs create
4+
all: clean rootfs create
55

66
clean:
77
@echo "### rm ./plugin"
88
@rm -rf ./plugin
99

10-
docker:
11-
@echo "### docker build: builder image"
12-
@docker build -q -t builder -f Dockerfile.dev .
13-
@echo "### extract docker-volume-sshfs"
14-
@docker create --name tmp builder
15-
@docker cp tmp:/go/bin/docker-volume-sshfs .
16-
@docker rm -vf tmp
17-
@docker rmi builder
10+
rootfs:
1811
@echo "### docker build: rootfs image with docker-volume-sshfs"
1912
@docker build -q -t ${PLUGIN_NAME}:rootfs .
20-
21-
rootfs:
2213
@echo "### create rootfs directory in ./plugin/rootfs"
2314
@mkdir -p ./plugin/rootfs
2415
@docker create --name tmp ${PLUGIN_NAME}:rootfs
@@ -33,10 +24,6 @@ create:
3324
@echo "### create new plugin ${PLUGIN_NAME}:${PLUGIN_TAG} from ./plugin"
3425
@docker plugin create ${PLUGIN_NAME}:${PLUGIN_TAG} ./plugin
3526

36-
enable:
37-
@echo "### enable plugin ${PLUGIN_NAME}:${PLUGIN_TAG}"
38-
@docker plugin enable ${PLUGIN_NAME}:${PLUGIN_TAG}
39-
4027
push: clean docker rootfs create enable
4128
@echo "### push plugin ${PLUGIN_NAME}:${PLUGIN_TAG}"
4229
@docker plugin push ${PLUGIN_NAME}:${PLUGIN_TAG}

0 commit comments

Comments
 (0)