WASdev / ci.docker.websphere-traditional

Dockerfiles for WebSphere Application Server traditional
Apache License 2.0
171 stars 192 forks source link

Decouple installation download and image build #128

Closed DSTOLF closed 5 years ago

DSTOLF commented 5 years ago

Hi,

I really liked when tWAS download through IM was decoupled from the image build.

Right now, in my company's private repo, we have a separate Installation Manager image to download and compress tWAS to a local folder, which we can later move to an artifact folder during our CI.

The Dockerfile looks like this:

# build image to extract the tar ball.
FROM ubuntu:16.04 as builder
 ARG WAS_VERSION=9.0.0.9
 ARG WAS_TAR_BALL=was-${WAS_VERSION}.tar.gz
COPY was/${WAS_TAR_BALL} /
RUN tar -xzf "$WAS_TAR_BALL"
# patch wsadmin.sh to avoid error when deploying apps
RUN sed -i 's/-Xms256m/-Xms1024m/g' /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh \
    && sed -i 's/-Xmx256m/-Xmx1024m/g' /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh

# final image that will copy extracted tar ball from builder
FROM ubuntu:16.04
ARG USER=was
ARG GROUP=was

RUN apt-get update && apt-get install -y openssl wget unzip

COPY scripts/ /work/

RUN groupadd $GROUP --gid 510 \
  && useradd $USER -g $GROUP -m --uid 500 \
  && mkdir /opt/IBM \
  && chmod -R +x /work/* \
  && mkdir /etc/websphere \
  && mkdir /work/config \
  && chown -R $USER:$GROUP /work /opt/IBM /etc/websphere

COPY --chown=500:510 --from=builder /opt/IBM /opt/IBM

....

I can submit a PR, if it's ok.

arthurdm commented 5 years ago

thanks for sharing @DSTOLF. I think that's a very valid scenario. +1 to the use of multi-stage-build to avoid the layer size increase.

Perhaps we can have this as an alternative way to build, by calling it Dockerfile.offline, so that users can choose which flavour they want to use?

@patricktiu - any comments on the approach above?

arthurdm commented 5 years ago

@arturdzm - can you please look into this one?

DSTOLF commented 5 years ago

@arthurdm I've sent a PR with the proposed changes #143 for your review. If there's any thing I should change, please let mw know.