Skip to content

Commit f4ff8e5

Browse files
author
Sean Sundberg
committed
Reduces image footprint from ~950 MB to ~330 MB
- Changes base image to docker.io/hashicorp/terraform:0.12.24 - Removes unnecessary software like Calico, helm 2, and npm
1 parent cc35e6d commit f4ff8e5

4 files changed

Lines changed: 65 additions & 122 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/
22
*.iml
3+
node_modules/

Dockerfile

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM registry.access.redhat.com/ubi8/ubi:8.1-397
1+
FROM docker.io/hashicorp/terraform:0.12.24
22

3-
ENV TERRAFORM_VERSION 0.12.20
4-
ENV TERRAFORM_IBMCLOUD_VERSION 1.2.1
3+
ENV TERRAFORM_VERSION 0.12.23
4+
ENV TERRAFORM_IBMCLOUD_VERSION 1.2.6
55
ENV TERRAFORM_KUBERNETES_VERSION 1.10.0
66
ENV TERRAFORM_HELM_VERSION 1.0.0
77
ENV SUPPORTED_CALICO 3.12.0
@@ -10,20 +10,20 @@ ENV NODE_VERSION 12
1010
ENV SOLSA_VERSION 0.3.5
1111
ENV KUBECTL_VERSION 1.15.5
1212

13-
RUN dnf install -y dnf-plugins-core --disableplugin=subscription-manager && \
14-
dnf install -y golang --disableplugin=subscription-manager && \
15-
dnf install -y sudo --disableplugin=subscription-manager && \
16-
dnf install -y unzip --disableplugin=subscription-manager && \
17-
dnf install -y openssl --disableplugin=subscription-manager
13+
RUN apk add --update-cache \
14+
curl \
15+
unzip \
16+
sudo \
17+
shadow \
18+
bash \
19+
openssl \
20+
ca-certificates \
21+
&& rm -rf /var/cache/apk/*
1822

1923
##################################
2024
# Calico CLI
2125
##################################
2226

23-
RUN curl -O -L https://github.com/projectcalico/calicoctl/releases/download/v${SUPPORTED_CALICO}/calicoctl && \
24-
mv ./calicoctl /usr/local/bin/calicoctl && \
25-
chmod +x /usr/local/bin/calicoctl
26-
2727
# Kustomize
2828
RUN opsys=linux && \
2929
curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases |\
@@ -43,12 +43,6 @@ RUN opsys=linux && \
4343

4444
WORKDIR $GOPATH/bin
4545

46-
# Install Terraform
47-
RUN curl -O -L https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
48-
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
49-
chmod +x terraform && \
50-
rm -rf terraform_${TERRAFORM_VERSION}_linux_amd64.zip
51-
5246
COPY src/bin/* /usr/local/bin/
5347

5448
##################################
@@ -76,28 +70,23 @@ COPY --chown=devops:devops src/etc/* ${HOME}/etc/
7670
##################################
7771

7872
# Install the ibmcloud cli
79-
RUN curl -sL https://ibm.biz/idt-installer | bash && \
80-
ibmcloud config --check-version=false && \
81-
ibmcloud plugin install cloud-databases
82-
83-
# Install nvm
84-
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash
85-
86-
RUN echo 'echo "Initializing environment..."' > ${HOME}/.bashrc-ni && \
87-
echo 'export NVM_DIR="${HOME}/.nvm"' >> ${HOME}/.bashrc-ni && \
88-
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ${HOME}/.bashrc-ni
89-
90-
# Set the BASH_ENV to /home/devops/.bashrc-ni so that it is executed in a
91-
# non-interactive shell
92-
#ENV BASH_ENV ${HOME}/.bashrc-ni
93-
94-
# Pre-install node v11.12.0
95-
RUN echo ${PWD} && . ./.bashrc-ni && nvm install "v${NODE_VERSION}" && nvm use "v${NODE_VERSION}"
73+
RUN curl -fsSL https://clis.cloud.ibm.com/install/linux | sh && \
74+
ibmcloud plugin install container-service && \
75+
ibmcloud plugin install container-registry && \
76+
ibmcloud config --check-version=false
9677

9778
RUN mkdir -p ${HOME}/.terraform.d/plugins
9879
WORKDIR ${HOME}/.terraform.d/plugins
9980

10081
# Install IBM Cloud Terraform Provider
82+
RUN curl -O -L https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v1.2.1/linux_amd64.zip &&\
83+
unzip linux_amd64.zip && \
84+
chmod +x terraform-provider-ibm_* &&\
85+
rm -rf linux_amd64.zip
86+
RUN curl -O -L https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v1.2.2/linux_amd64.zip &&\
87+
unzip linux_amd64.zip && \
88+
chmod +x terraform-provider-ibm_* &&\
89+
rm -rf linux_amd64.zip
10190
RUN curl -O -L https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v${TERRAFORM_IBMCLOUD_VERSION}/linux_amd64.zip &&\
10291
unzip linux_amd64.zip && \
10392
chmod +x terraform-provider-ibm_* &&\
@@ -117,42 +106,29 @@ RUN curl -L https://releases.hashicorp.com/terraform-provider-helm/${TERRAFORM_H
117106

118107
WORKDIR ${HOME}
119108

120-
# Install yo
121-
RUN . ./.bashrc-ni && npm i -g yo
122-
RUN . ./.bashrc-ni && npm i -g @garage-catalyst/ibm-garage-cloud-cli
123-
124-
# Install solsa
125-
RUN . ./.bashrc-ni && npm i -g solsa@${SOLSA_VERSION}
126-
127109
COPY src/image-message ./image-message
128110
RUN cat ./image-message >> ./.bashrc-ni
129111

130-
#RUN sudo dnf install python3 python3-pip -yv
131-
#RUN sudo ln -s /usr/bin/python3 /usr/bin/python
132-
#RUN sudo ln -s /usr/bin/pip3 /usr/bin/pip
133-
#RUN /usr/bin/python3 -m pip install --user ansible && \
134-
# echo "export PATH=\"${PATH}:${HOME}/.local/bin\"" >> ./.bashrc-ni
135-
136-
RUN sudo dnf clean all
137-
138112
RUN curl -L https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz --output oc-client.tar.gz && \
139113
tar xzf oc-client.tar.gz && \
140114
sudo cp openshift-origin-client-tools*/oc /usr/local/bin && \
141115
sudo chmod +x /usr/local/bin/oc && \
142116
rm -rf openshift-origin-client-tools* && \
143-
rm oc-client.tar.gz
144-
# sudo cp openshift-origin-client-tools*/kubectl /usr/local/bin && \
145-
# sudo chmod +x /usr/local/bin/kubectl && \
117+
rm oc-client.tar.gz && \
118+
echo "alias oc='/lib/ld-musl-x86_64.so.1 --library-path /lib /usr/local/bin/oc'" >> ./.bashrc-ni
119+
146120

147121
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
148122
chmod +x ./kubectl && \
149123
sudo mv ./kubectl /usr/local/bin
150124

151-
RUN sudo mv /usr/local/bin/helm /usr/local/bin/helm2 && \
152-
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash && \
153-
sudo mv /usr/local/bin/helm /usr/local/bin/helm3 && \
154-
sudo ln -s /usr/local/bin/helm2 /usr/local/bin/helm
125+
RUN curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash && \
126+
sudo cp /usr/local/bin/helm /usr/local/bin/helm3
155127

156128
RUN sudo chown -R devops ${HOME} && sudo chgrp -R 0 ${HOME} && sudo chmod -R g=u ${HOME}
157129

130+
RUN curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
131+
chmod a+x jq-linux64 && \
132+
sudo mv jq-linux64 /usr/local/bin/jq
133+
158134
ENTRYPOINT ["/bin/bash", "--init-file", "/home/devops/.bashrc-ni"]

config.yaml

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ commandTests:
1414
args: ["--help"]
1515
expectedOutput: ["Usage: terraform.*"]
1616

17-
- name: "Calico CLI installation"
18-
command: "calicoctl"
19-
args: ["--help"]
20-
expectedOutput: ["Usage:\n.*calicoctl.*"]
21-
2217
- name: "IBM Cloud CLI installation"
2318
command: "ibmcloud"
2419
args: ["--help"]
@@ -34,21 +29,11 @@ commandTests:
3429
args: ["plugin", "list"]
3530
expectedOutput: [".*container-registry.*"]
3631

37-
- name: "IBM Cloud cloud-databases plugin"
38-
command: "ibmcloud"
39-
args: ["plugin", "list"]
40-
expectedOutput: [".*cloud-databases.*"]
41-
4232
- name: "Kubectl CLI installation"
4333
command: "kubectl"
4434
args: ["version", "--client"]
4535
expectedOutput: [".*v1.15.5.*"]
4636

47-
- name: "Helm CLI installation"
48-
command: "helm"
49-
args: ["version", "--client"]
50-
expectedOutput: [".*SemVer:.v2.16.*"]
51-
5237
- name: "Helm 3 CLI installation"
5338
command: "helm3"
5439
args: ["version"]
@@ -64,51 +49,10 @@ commandTests:
6449
args: ["--help"]
6550
expectedOutput: ["usage: git.*"]
6651

67-
# - name: "Postgres installation"
68-
# command: "createdb"
69-
# args: ["--help"]
70-
# expectedOutput: ["createdb creates a PostgreSQL database.*"]
71-
72-
- name: "OpenShift client installation"
73-
command: "oc"
74-
args: ["--help"]
75-
expectedOutput: [".*OpenShift.*"]
76-
77-
# - name: "python"
78-
# command: "python"
79-
# args: ["--help"]
80-
# expectedOutput: [".*python.*"]
81-
#
82-
# - name: "pip"
83-
# command: "pip"
84-
# args: ["--help"]
85-
# expectedOutput: [".*pip.*"]
86-
#
87-
# - name: "ansible"
88-
# command: "/home/devops/.local/bin/ansible-playbook"
89-
# args: ["--help"]
90-
# expectedOutput: [".*ansible.*"]
91-
92-
# - name: "nvm installation"
93-
# setup: [["/bin/bash", "--init-file", "/home/devops/.bashrc-ni"]]
94-
# command: "nvm"
95-
# args: ["--help"]
96-
# expectedOutput: [".*Node Version Manager.*"]
97-
98-
# - name: "node installation"
99-
# command: "node"
100-
# args: ["--help"]
101-
# expectedOutput: ["v\\d\\d[.]\\d\\d[.]\\d\n"]
102-
103-
- name: "SolSA CLI installation"
104-
command: "bash"
105-
args: ["-c", "source /home/devops/.nvm/nvm.sh && solsa help"]
106-
expectedError: ["Usage:\n.*solsa <command> <solution> \\[flags\\].*"]
107-
108-
# - name: "yo installation"
109-
# command: "yo"
52+
# - name: "OpenShift client installation"
53+
# command: "/lib/ld-musl-x86_64.so.1 --library-path /lib /usr/local/bin/oc"
11054
# args: ["--help"]
111-
# expectedOutput: ["\\d[.]\\d[.]\\d\n"]
55+
# expectedOutput: [".*OpenShift.*"]
11256

11357
fileExistenceTests:
11458
- name: 'jenkins-config-template.xml'

package.json

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
{
2-
"name": "ibm-garage-cli-tools",
3-
"version": "0.0.26",
4-
"org": "garagecatalyst",
5-
"branch": "next",
2+
"name": "cli-tools",
3+
"version": "0.1.7",
4+
"org": "ibmgaragecloud",
5+
"branch": "lite",
66
"description": "This repository contains a docker image to help setup an IBM Cloud Public development environment.",
77
"main": "index.js",
8+
"release-it": {
9+
"git": {
10+
"tagName": "v${version}"
11+
},
12+
"npm": {
13+
"publish": false
14+
},
15+
"github": {
16+
"release": true
17+
},
18+
"hooks": {
19+
"before:init": [
20+
"npm test"
21+
],
22+
"after:bump": "npm run build",
23+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
24+
}
25+
},
826
"scripts": {
927
"build": "./scripts/build.sh $npm_package_name $npm_package_version $npm_package_branch",
1028
"pretest": "npm run build",
@@ -14,13 +32,17 @@
1432
"push": "npm run push:only",
1533
"push:only": "./scripts/publish.sh $npm_package_org $npm_package_name $npm_package_version $npm_package_branch",
1634
"pull": "./scripts/pull.sh $npm_package_org $npm_package_name $npm_package_version $npm_package_branch",
17-
"start": "docker run -it $npm_package_name:$npm_package_version$(echo $npm_package_branch | sed -E \"s/(.+)/-\\1/g\")"
35+
"start": "docker run -it $npm_package_name:$npm_package_version$(echo $npm_package_branch | sed -E \"s/(.+)/-\\1/g\")",
36+
"release": "release-it --verbose -VV"
1837
},
1938
"repository": {
2039
"type": "git",
2140
"url": "git@github.ibm.com:garage-catalyst/client-tools-image.git"
2241
},
2342
"keywords": [],
2443
"author": "",
25-
"license": "ISC"
44+
"license": "ISC",
45+
"devDependencies": {
46+
"release-it": "^13.0.0"
47+
}
2648
}

0 commit comments

Comments
 (0)