Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Commit 0749681

Browse files
ryanpriorapotterri
authored andcommitted
Adds standalone container image for v4 CLI (#211)
* Adds standalone container image for v4 CLI * Updates standalone Dockerfile to set the appropriate Conjur version * Adds "push-image" script and adds build, push stages to Jenkinsfile * Push on 'v4' instead of 'master' * When creating a new Dockerfile, exclude it from Git * Consolidates instructions in Dockerfile.standalone * Adds Docker usage notes to README.md * Adds `VERSION` and updates CHANGELOG.md * Fixes jank Dockerfile exclude logic in test.sh * Tags standalone images `cyberark/conjur-cli:4-*` instead of `-cli4` * Updates `build-standalone` script (cli4 -> cli) * Only push to dockerhub on 'v4' branch * Installs gem in standalone container instead of using release * Removes Emacs mode specification * Adds explanation and whitespace to Dockerfile.standalone * Updates instructions to recommend ephemeral container * Bumps version to 5.6.6 * Completes security warning * Fixes references to "cli4" or "cli:latest"
1 parent 89cbef4 commit 0749681

10 files changed

Lines changed: 159 additions & 1 deletion

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Dockerfile.*
21
.DS_Store
32
*.swp
43
*.deb

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 5.6.6
2+
3+
* Adds standalone Docker image (`cyberark/conjur-cli:4`)
4+
15
# 5.6.5
26

37
* Fix init cert check when Conjur behind a SNI

Dockerfile.standalone

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM ruby:2.2.9
2+
3+
#---install useful tools and dependencies---#
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
jq curl vim nano sudo openssh-client
7+
# as per https://hub.docker.com/r/conjurinc/cli5/~/dockerfile/
8+
9+
#---install summon and summon-conjur---#
10+
ENV CONJUR_MAJOR_VERSION=4
11+
ENV CONJUR_VERSION=4
12+
RUN curl -sSL https://raw.githubusercontent.com/cyberark/summon/master/install.sh \
13+
| env TMPDIR=$(mktemp -d) bash && \
14+
curl -sSL https://raw.githubusercontent.com/cyberark/summon-conjur/master/install.sh \
15+
| env TMPDIR=$(mktemp -d) bash
16+
# as per https://github.com/cyberark/summon#linux
17+
# and https://github.com/cyberark/summon-conjur#install
18+
19+
# Note: these install scripts^^ conflict with one another if they are not given
20+
# different TMPDIRs.
21+
22+
#---install Conjur 4 CLI---#
23+
WORKDIR /src
24+
COPY . .
25+
RUN gem build conjur-cli.gemspec && \
26+
gem install conjur-cli && \
27+
cd /root && \
28+
rm -rf /src
29+
30+
#---set defaults---#
31+
WORKDIR /root
32+
COPY standalone.entrypoint /bin/entry
33+
ENTRYPOINT ["/bin/entry"]

Jenkinsfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ pipeline {
5555
}
5656
}
5757

58+
stage('Build standalone Docker image') {
59+
steps {
60+
sh './build-standalone'
61+
}
62+
}
63+
64+
stage('Publish standalone Docker image to DockerHub') {
65+
steps {
66+
sh './push-image'
67+
}
68+
}
69+
5870
// Only publish to RubyGems if the HEAD is
5971
// tagged with the same version as in version.rb
6072
stage('Publish to RubyGems') {

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,60 @@ Or install it yourself as:
2020

2121
$ gem install conjur-cli
2222

23+
### Using Docker
24+
25+
This software is included in the standalone `cyberark/conjur-cli:4` Docker
26+
image. Docker containers are designed to be ephemeral, which means they don't
27+
store state after the container exits.
28+
29+
You can start an ephemeral session with the Conjur CLI software like so:
30+
31+
```sh-session
32+
$ docker run --rm -it cyberark/conjur-cli:4
33+
root@b27a95721e7d:~#
34+
```
35+
36+
Any initialization you do or files you create in that session will be discarded
37+
(permanently lost) when you exit the shell. Changes that you make to the Conjur
38+
server will remain.
39+
40+
You can also use a folder on your filesystem to persist the data that the Conjur
41+
CLI uses to connect. For example:
42+
43+
```sh-session
44+
$ mkdir mydata
45+
$ chmod 700 mydata
46+
$ docker run --rm -it -v $(PWD)/mydata:/root cyberark/conjur-cli:4 init -h https://conjur.myorg.com
47+
SHA1 Fingerprint=16:C8:F8:AC:7B:57:BD:5B:58:B4:13:27:22:8E:3F:A2:12:01:DB:68
48+
49+
Please verify this certificate on the appliance using command:
50+
openssl x509 -fingerprint -noout -in ~conjur/etc/ssl/conjur.pem
51+
52+
Trust this certificate (yes/no): yes
53+
Wrote certificate to /root/conjur-conjur.pem
54+
Wrote configuration to /root/.conjurrc
55+
$ ls -lA mydata
56+
total 8
57+
drwxr-xr-x 2 you staff 64 Mar 28 19:30 .cache
58+
-rw-r--r-- 1 you staff 128 Mar 28 19:30 .conjurrc
59+
-rw-r--r-- 1 you staff 2665 Mar 28 19:30 conjur-conjur.pem
60+
$ docker run --rm -it -v $(PWD)/mydata:/root cyberark/conjur-cli:4 authn login -u your-user-name
61+
Please enter your password (it will not be echoed):
62+
Logged in
63+
$ ls -lA mydata
64+
total 12
65+
drwxr-xr-x 2 you staff 64 Mar 28 19:26 .cache
66+
-rw-r--r-- 1 you staff 128 Mar 28 19:20 .conjurrc
67+
-rw------- 1 you staff 143 Mar 28 19:27 .netrc
68+
-rw-r--r-- 1 you staff 2665 Mar 28 19:20 conjur-conjur.pem
69+
$
70+
```
71+
72+
*Security notice:* the file `.netrc`, created or updated by `conjur authn
73+
login`, contains a user identity credential that can be used to access the
74+
Conjur API. You should remove it after use or otherwise secure it like you would
75+
another netrc file.
76+
2377
### Bash completion
2478

2579
To enable bash completions, run this command:

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.6.6

build-standalone

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -e
2+
3+
# build the cli standalone container image
4+
docker build . \
5+
-f Dockerfile.standalone \
6+
-t cyberark/conjur-cli

push-image

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash -e
2+
3+
# Push the 'cli:4' image to Dockerhub when on the 'v4' branch
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
7+
TAG="4-${1:-$(cat VERSION)-$(git rev-parse --short HEAD)}"
8+
IMAGE='cyberark/conjur-cli'
9+
10+
function tag_and_push() {
11+
local image="$1"
12+
local tag="$2"
13+
local description="$3"
14+
15+
echo "TAG = $tag, $description"
16+
17+
docker tag "$image" "$image:$tag"
18+
docker push "$image:$tag"
19+
}
20+
21+
if [[ "$BRANCH_NAME" == 'v4' ]]; then
22+
bare_tag='4'
23+
latest_tag='4-latest'
24+
stable_tag="4-$(cat VERSION)-stable"
25+
26+
tag_and_push $IMAGE $bare_tag 'latest image (bare)'
27+
tag_and_push $IMAGE $latest_tag 'latest image'
28+
tag_and_push $IMAGE $stable_tag 'stable image'
29+
fi

standalone.entrypoint

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh -e
2+
3+
# A tool container entrypoint that tries to do the right thing whether you want
4+
# an interactive shell environment or run a command directly.
5+
#
6+
# It starts bash if
7+
# - there is a tty (ie. docker was run with -t),
8+
# - there are no arguments.
9+
#
10+
# Otherwise it runs the tool.
11+
12+
TOOL=conjur
13+
14+
[ -t 1 -a $# -eq 0 ] && exec bash
15+
16+
# else
17+
exec $TOOL "$@"

test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ RUBY_VERSION=${1-${RUBY_VERSION_DEFAULT}}
1212
function dockerfile_path {
1313
echo "Setting Ruby version as ${RUBY_VERSION}" >&2
1414
cp "Dockerfile" "Dockerfile.${RUBY_VERSION}"
15+
if ! grep "Dockerfile.${RUBY_VERSION}" .git/info/exclude >/dev/null; then
16+
echo "Dockerfile.${RUBY_VERSION}*" >>.git/info/exclude
17+
fi
1518
sed -i -e "s/${RUBY_VERSION_DEFAULT}/${RUBY_VERSION}/g" Dockerfile.${RUBY_VERSION}
1619

1720
echo "Dockerfile.${RUBY_VERSION}"

0 commit comments

Comments
 (0)