Skip to content

Commit

Permalink
Merge pull request #44 from ibuildthecloud/image
Browse files Browse the repository at this point in the history
Build rancher/cli image
  • Loading branch information
ibuildthecloud authored Mar 3, 2017
2 parents 5fd267a + 0ea05c3 commit a783b9c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 21 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Run `make`.

Run `CROSS=1 make build`

### Docker image

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.

To build `rancher/cli` just run `make`. To use a custom Docker repository do `REPO=custom make` and it will producte `custom/cli` image.

## Contact

For bugs, questions, comments, corrections, suggestions, etc., open an issue in
Expand Down
12 changes: 0 additions & 12 deletions cli-docker/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions cli-docker/rancher

This file was deleted.

10 changes: 10 additions & 0 deletions contrib/rancher
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

[[ -d ~/.rancher ]] || mkdir -p ~/.rancher
[[ -d ~/.ssh ]] || mkdir -p ~/.ssh
[[ -e ~/.ssh/known_hosts ]] || touch ~/.ssh/known_hosts
[[ -e ~/.rancher/cli.json ]] || echo "{"accessKey":"","secretKey":"","url":"","environment":""}" > ~/.rancher/cli.json

IMAGE=${IMAGE:-rancher/cli}

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} "$@"
7 changes: 5 additions & 2 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
FROM alpine
COPY bin/rancher /usr/bin/
FROM alpine:3.5
RUN apk add --no-cache ca-certificates openssh-client
COPY rancher /usr/bin/
WORKDIR /mnt
ENTRYPOINT ["rancher"]
CMD ["--help"]
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OS_ARCH_ARG[windows]="386 amd64"
OS_ARCH_ARG[darwin]="amd64"

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

if [ -n "$CROSS" ]; then
rm -rf build/bin
Expand Down
20 changes: 20 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,23 @@ for i in build/bin/*; do
fi
)
done


ARCH=${ARCH:-"amd64"}
SUFFIX=""
[ "${ARCH}" != "amd64" ] && SUFFIX="_${ARCH}"

cd package

TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}

if echo $TAG | grep -q dirty; then
TAG=dev
fi

cp ../bin/rancher .
docker build -t ${REPO}/cli:${TAG} .

echo ${REPO}/cli:${TAG} > ../dist/images
echo Built ${REPO}/cli:${TAG}

0 comments on commit a783b9c

Please sign in to comment.