Skip to content

Commit a783b9c

Browse files
Merge pull request #44 from ibuildthecloud/image
Build rancher/cli image
2 parents 5fd267a + 0ea05c3 commit a783b9c

File tree

7 files changed

+42
-21
lines changed

7 files changed

+42
-21
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ Run `make`.
4040

4141
Run `CROSS=1 make build`
4242

43+
### Docker image
44+
45+
Run `docker run --rm -it rancher/cli [ARGS]` You can pass in credentials by bind mounting in a config file or setting env vars. You can also use the wrapper script in `./contrib/rancher` that will make the process a bit easier.
46+
47+
To build `rancher/cli` just run `make`. To use a custom Docker repository do `REPO=custom make` and it will producte `custom/cli` image.
48+
4349
## Contact
4450

4551
For bugs, questions, comments, corrections, suggestions, etc., open an issue in

cli-docker/Dockerfile

-12
This file was deleted.

cli-docker/rancher

-6
This file was deleted.

contrib/rancher

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
[[ -d ~/.rancher ]] || mkdir -p ~/.rancher
4+
[[ -d ~/.ssh ]] || mkdir -p ~/.ssh
5+
[[ -e ~/.ssh/known_hosts ]] || touch ~/.ssh/known_hosts
6+
[[ -e ~/.rancher/cli.json ]] || echo "{"accessKey":"","secretKey":"","url":"","environment":""}" > ~/.rancher/cli.json
7+
8+
IMAGE=${IMAGE:-rancher/cli}
9+
10+
exec docker run --rm -it --net host -v ~/.rancher/cli.json:/root/.rancher/cli.json -v ~/.ssh/known_hosts:/root/.ssh/known_hosts -v $(pwd):/mnt ${IMAGE} "$@"

package/Dockerfile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
FROM alpine
2-
COPY bin/rancher /usr/bin/
1+
FROM alpine:3.5
2+
RUN apk add --no-cache ca-certificates openssh-client
3+
COPY rancher /usr/bin/
4+
WORKDIR /mnt
35
ENTRYPOINT ["rancher"]
6+
CMD ["--help"]

scripts/build

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OS_ARCH_ARG[windows]="386 amd64"
1212
OS_ARCH_ARG[darwin]="amd64"
1313

1414
go generate
15-
go build -ldflags="-w -s -X main.VERSION=$VERSION" -o bin/rancher
15+
CGO_ENABLED=0 go build -ldflags="-w -s -X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/rancher
1616

1717
if [ -n "$CROSS" ]; then
1818
rm -rf build/bin

scripts/package

+20
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,23 @@ for i in build/bin/*; do
5656
fi
5757
)
5858
done
59+
60+
61+
ARCH=${ARCH:-"amd64"}
62+
SUFFIX=""
63+
[ "${ARCH}" != "amd64" ] && SUFFIX="_${ARCH}"
64+
65+
cd package
66+
67+
TAG=${TAG:-${VERSION}${SUFFIX}}
68+
REPO=${REPO:-rancher}
69+
70+
if echo $TAG | grep -q dirty; then
71+
TAG=dev
72+
fi
73+
74+
cp ../bin/rancher .
75+
docker build -t ${REPO}/cli:${TAG} .
76+
77+
echo ${REPO}/cli:${TAG} > ../dist/images
78+
echo Built ${REPO}/cli:${TAG}

0 commit comments

Comments
 (0)