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

Commit

Permalink
Improve the CLI standalone docker image
Browse files Browse the repository at this point in the history
Changes made:
- Base image changed from ruby -> ubuntu
- Comments standardized
- Git checkout done using `--depth=1`

This change slims the image down to less tham 50% of the original one
(952MB -> 432MB == 45% of original)
  • Loading branch information
sgnn7 committed Jan 24, 2020
1 parent 2f42170 commit 71aac16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
35 changes: 22 additions & 13 deletions Dockerfile.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@
# then installs the CLI system-wide.
#
# Entrypoint is bash, with `conjur` command available.
FROM ubuntu:latest

FROM ruby:2.4.6
ENV CONJUR_MAJOR_VERSION=5 \
CONJUR_VERSION=5 \
DEBIAN_FRONTEND=noninteractive

#---some useful tools for interactive usage---#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
jq curl vim nano sudo openssh-client
# as per https://hub.docker.com/r/conjurinc/cli5/~/dockerfile/

#---install summon and summon-conjur---#
ENV CONJUR_MAJOR_VERSION=5
ENV CONJUR_VERSION=5
build-essential \
curl \
git \
nano \
openssh-client \
ruby2.5 ruby2.5-dev \
sudo \
vim \
tzdata && \
apt-get clean

# Install `summon` and `summon-conjur`
RUN curl -sSL https://raw.githubusercontent.com/cyberark/summon/master/install.sh \
| env TMPDIR=$(mktemp -d) bash && \
curl -sSL https://raw.githubusercontent.com/cyberark/summon-conjur/master/install.sh \
Expand All @@ -25,20 +33,21 @@ RUN curl -sSL https://raw.githubusercontent.com/cyberark/summon/master/install.s
# and https://github.com/cyberark/summon-conjur#install
ENV PATH="/usr/local/lib/summon:${PATH}"

#---install Conjur 5 CLI---#
# cache a reasonable version of api-ruby & deps
# Install Conjur 5 CLI
# Cache a reasonable version of api-ruby & deps
RUN mkdir -p /usr/src && \
cd /usr/src && \
git clone https://github.com/cyberark/api-ruby.git && \
git clone --depth 1 https://github.com/cyberark/api-ruby.git && \
cd api-ruby && \
gem install bundler && \
rake install

COPY standalone.entrypoint /bin/entry

# update API and install everything
# Update API and install everything
COPY . /usr/src/cli-ruby

# only reinstall API if changed
# Only reinstall API if changed
RUN cd /usr/src/api-ruby && git fetch && \
if [ $(git rev-parse HEAD origin/master | uniq | wc -l) -gt 1 ]; then \
git reset --hard origin/master && rake install ; \
Expand Down
10 changes: 1 addition & 9 deletions build-standalone
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
TAG="cyberark/conjur-cli:latest"

ENV_VARS=(
"BUNDLE_APP_CONFIG=/usr/local/bundle"
"BUNDLE_PATH=/usr/local/bundle"
"BUNDLE_SILENCE_ROOT_WARNING=1"
"CONJUR_MAJOR_VERSION=5"
"CONJUR_VERSION=5"
"GEM_HOME=/usr/local/bundle"
"PATH=/usr/local/lib/summon:/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
"RUBY_DOWNLOAD_SHA256=25da31b9815bfa9bba9f9b793c055a40a35c43c6adfb1fdbd81a09099f9b529c"
"RUBY_MAJOR=2.4"
"RUBY_VERSION=2.4.6"
"RUBYGEMS_VERSION=3.0.3"
"PATH=/usr/local/lib/summon:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
)

# Flatten resulting image.
Expand Down

0 comments on commit 71aac16

Please sign in to comment.