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

Commit 51e4bdc

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. Please compare with whitespace checks turned off. In order to support builds within the container bsdtar needs to be used rather than the regular tar due to docker/hub-feedback#727 The tar server was also removed in favor of copying from the container to the "im" folder and imported back using Dockerfile for the final image. The step where the files are tarred in install_ihs was removed and put into docker. This makes it easier to debug issues with tar
1 parent 194ea09 commit 51e4bdc

File tree

8 files changed

+91
-66
lines changed

8 files changed

+91
-66
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: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
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+
###########################################################################
2+
# (C) Copyright IBM Corporation 2015, 2016. #
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+
###########################################################################
1716

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

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

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

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

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

28-
RUN wget -q -O - $TAR_URL | tar xz
29-
ENV PATH /opt/IBM/HTTPServer/bin:$PATH
30-
CMD ["/work/ihsstart.sh"]
44+
# requires envvars
45+
ARG VERSION
46+
ARG IBM_ID
47+
ARG IBM_PASSWORD
48+
RUN /host/install_ihs.sh
49+
RUN tar zcf /target/ihs${VERSION}.tar.gz /opt/IBM/HTTPServer /opt/IBM/WebSphere/Plugins /opt/IBM/WebSphere/Toolbox
50+
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/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)