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

Commit 4e42c45

Browse files
committed
Optimized build process
Moved the logic of building the images into docker. Removed using any absolute paths on the build system (i.e. $(pwd) which does not work correctly on Windows) Added .gitattributes to ensure line endings for files being used in the Docker build containers are correct.
1 parent 194ea09 commit 4e42c45

File tree

9 files changed

+94
-67
lines changed

9 files changed

+94
-67
lines changed

ilan/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.sh eol=lf
2+
*.csv eol=lf

ilan/Dockerfile

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
1-
############################################################################
2-
# (C) Copyright IBM Corporation 2015. #
3-
# #
4-
# Licensed under the Apache License, Version 2.0 (the "License"); #
5-
# you may not use this file except in compliance with the License. #
6-
# You may obtain a copy of the License at #
7-
# #
8-
# http://www.apache.org/licenses/LICENSE-2.0 #
9-
# #
10-
# Unless required by applicable law or agreed to in writing, software #
11-
# distributed under the License is distributed on an "AS IS" BASIS, #
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13-
# See the License for the specific language governing permissions and #
14-
# limitations under the License. #
15-
# #
16-
############################################################################
1+
#!/bin/bash
2+
#
3+
###########################################################################
4+
# (C) Copyright IBM Corporation 2015, 2016. #
5+
# #
6+
# Licensed under the Apache License, Version 2.0 (the "License"); #
7+
# you may not use this file except in compliance with the License. #
8+
# You may obtain a copy of the License at #
9+
# #
10+
# http://www.apache.org/licenses/LICENSE-2.0 #
11+
# #
12+
# Unless required by applicable law or agreed to in writing, software #
13+
# distributed under the License is distributed on an "AS IS" BASIS, #
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.#
15+
# See the License for the specific language governing permissions and #
16+
# limitations under the License. #
17+
###########################################################################
1718

18-
FROM ubuntu:16.04
19+
# This Dockerfile is meant to download the requisite software and tar them
20+
# up for the final DockerFile which will not have the IBM_ID and
21+
# IBM_PASSWORD saved
1922

20-
MAINTAINER Kavitha Suresh Kumar <[email protected]>
23+
FROM ubuntu:16.04
2124

22-
RUN apt-get update && apt-get install -y openssl wget
25+
RUN apt-get update && apt-get install --no-install-recommends -y unzip bsdtar && rm -rf /var/lib/apt/lists/*
26+
# BSD tar is need to prevent errors on Docker builds
27+
# see https://github.com/docker/hub-feedback/issues/727
28+
RUN export tar='bsdtar'
2329

24-
ARG TAR_URL
30+
# Install IBM Installation Manager
31+
COPY im/agent.installer.linux.gtk.x86_64_*.zip /tmp/
32+
RUN unzip -qd /tmp/im /tmp/agent.installer.linux.gtk.x86_64_*.zip \
33+
&& /tmp/im/installc -acceptLicense -accessRights nonAdmin \
34+
-installationDirectory "/opt/IBM/InstallationManager" \
35+
-dataLocation "/var/ibm/InstallationManager" -showProgress \
36+
&& rm -rf /tmp/agent.installer.linux.gtk.x86_65_*.zip /tmp/im
2537

26-
COPY ihsstart.sh /work/
38+
ENV PATH /opt/IBM/InstallationManager/eclipse/tools:$PATH
39+
RUN mkdir /host
40+
RUN mkdir /target
41+
COPY install_ihs.sh /host
42+
COPY versions.csv /host
43+
COPY Dockerfile.template /host
44+
RUN chmod 700 /host/install_ihs.sh
2745

28-
RUN wget -q -O - $TAR_URL | tar xz
29-
ENV PATH /opt/IBM/HTTPServer/bin:$PATH
30-
CMD ["/work/ihsstart.sh"]
46+
# requires envvars
47+
ARG VERSION
48+
ARG IBM_ID
49+
ARG IBM_PASSWORD
50+
RUN /host/install_ihs.sh
51+
RUN tar zcf /target/ihs${VERSION}.tar.gz /opt/IBM/HTTPServer /opt/IBM/WebSphere/Plugins /opt/IBM/WebSphere/Toolbox
52+
RUN sed s/@VERSION@/${VERSION}/ /host/Dockerfile.template > /target/Dockerfile.${VERSION}

ilan/Dockerfile.template

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
############################################################################
2+
# (C) Copyright IBM Corporation 2015. #
3+
# #
4+
# Licensed under the Apache License, Version 2.0 (the "License"); #
5+
# you may not use this file except in compliance with the License. #
6+
# You may obtain a copy of the License at #
7+
# #
8+
# http://www.apache.org/licenses/LICENSE-2.0 #
9+
# #
10+
# Unless required by applicable law or agreed to in writing, software #
11+
# distributed under the License is distributed on an "AS IS" BASIS, #
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13+
# See the License for the specific language governing permissions and #
14+
# limitations under the License. #
15+
# #
16+
############################################################################
17+
18+
# This is a template Dockerfile which will have version of the tar expected
19+
# in the COPY command set during the previous docker build.
20+
21+
FROM ubuntu:16.04
22+
23+
MAINTAINER Kavitha Suresh Kumar <[email protected]>
24+
25+
RUN apt-get update && apt-get install --no-install-recommends -y unzip bsdtar && rm -rf /var/lib/apt/lists/*
26+
# BSD tar is need to prevent errors on Docker builds
27+
# see https://github.com/docker/hub-feedback/issues/727
28+
RUN export tar='bsdtar'
29+
30+
COPY ihsstart.sh /work/
31+
COPY im/ihs@[email protected] /ihs.tar.gz
32+
RUN tar xzf /ihs.tar.gz && rm /ihs.tar.gz
33+
ENV PATH /opt/IBM/HTTPServer/bin:$PATH
34+
CMD ["/work/ihsstart.sh"]

ilan/build

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ if [ $# != 3 ]; then
2121
exit 1
2222
fi
2323

24-
docker build -t installation-manager im || exit $?
25-
docker run --rm -v $(pwd):/host installation-manager /host/install_ihs $1 $2 $3 || exit $?
24+
docker build -t installation-manager . --build-arg VERSION=$1 --build-arg IBM_ID=$2 --build-arg IBM_PASSWORD=$3|| exit $?
2625

27-
docker run -d --name tar_server -v $(pwd)/ihs$1.tar.gz:/host/ihs$1.tar.gz -w /host python:2-slim python -m SimpleHTTPServer
28-
tar_server_ip=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' tar_server)
29-
tar_url="http://${tar_server_ip}:8000/ihs${1}.tar.gz"
26+
# copy the intermediate artifacts from /target
3027

28+
docker run installation-manager cat /target/ihs$1.tar.gz > im/ihs$1.tar.gz
29+
docker run installation-manager cat /target/Dockerfile.$1 > im/Dockerfile.$1
3130

3231
# Build image from hosted tar file
3332
echo "Building image"
34-
docker build -t ibm-http-server:$1 --build-arg TAR_URL=$tar_url . || exit $?
35-
docker rm -f tar_server
33+
docker build -t ibm-http-server:$1 -f im/DockerFile.$1 . || exit $?

ilan/build_all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ while read line; do
2525
if [[ $line == \#* ]]; then continue; fi
2626
version=$(cut -d, -f1 <<< $line)
2727
./build $version $1 $2
28-
done < versions.csv
28+
done < im/versions.csv

ilan/im/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.zip
2+
*.tar.gz
3+
DockerFile.*

ilan/im/Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

ilan/im/NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This folder is where `agent.installer.linux.gtk.x85_64_*.zip` is expected to be stored. The file is ignored for source control.
2+
3+
In addition intermediate artifacts are stored here and will also be ignored by source control.

ilan/install_ihs renamed to ilan/install_ihs.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
# limitations under the License. #
1717
###########################################################################
1818

19-
VERSION=$1
20-
IBM_ID=$2
21-
IBM_PASSWORD=$3
2219
echo "Running build for versions: "$VERSION
2320
SECURE_STORAGE_FILE=/tmp/credentials
2421

@@ -79,4 +76,3 @@ function install_version() {
7976

8077

8178
install_version
82-
tar -zcf /host/ihs${VERSION}.tar.gz /opt/IBM/HTTPServer /opt/IBM/WebSphere/Plugins /opt/IBM/WebSphere/Toolbox

0 commit comments

Comments
 (0)