Fully customizable Dockerfile

IBM Industry Solutions Workbench is using pre-defined Dockerfiles for the build of service projects. Those Dockerfiles can be overridden for specific service projects depending on your needs and requirements.

Warning:

If you are using a customized Dockerfile in your service project, the Dockerfile will not be updated automatically with new releases. Please make sure, that you take care of updating the Dockerfile by yourself.

Prerequisites

Add a customized Dockerfile to a service project

To use a custom Dockerfile in your pipelines, please provide a file named Dockerfile at the root level of your service project. The content of the file is highly dependent on the stack that your service project is based on.

Dockerfile examples

Node image

ARG IMAGE_BASE
FROM ${IMAGE_BASE}

ARG ACRONYM
ARG COMMITSHA
ARG TIMESTAMP
ARG VERSION

LABEL k5.build.acronym=${ACRONYM} \
  k5.build.vcs-ref=${COMMITSHA} \
  k5.build.timestamp=${TIMESTAMP} \
  k5.build.version=${VERSION}

ENV k5.build.acronym=${ACRONYM}
ENV k5.build.vcs-ref=${COMMITSHA}
ENV k5.build.timestamp=${TIMESTAMP}
ENV k5.build.version=${VERSION}

USER 0

COPY ./ /opt/knowis/solution

RUN chmod -R a+rx /opt/knowis/solution

USER 1000

EXPOSE 8443

Java 11

ARG IMAGE_BASE
FROM ${IMAGE_BASE}

ARG ACRONYM
ARG COMMITSHA
ARG TIMESTAMP
ARG VERSION

LABEL k5.build.acronym=${ACRONYM} \
  k5.build.vcs-ref=${COMMITSHA} \
  k5.build.timestamp=${TIMESTAMP} \
  k5.build.version=${VERSION}

ENV k5.build.acronym=${ACRONYM}
ENV k5.build.vcs-ref=${COMMITSHA}
ENV k5.build.timestamp=${TIMESTAMP}
ENV k5.build.version=${VERSION}
ENV JAVA_APP_DIR=/opt/knowis/solution

VOLUME /tmp

USER 0

COPY ./${ACRONYM}-application/target/app.jar /opt/knowis/solution/app.jar
COPY ./cli /opt/knowis/solution/cli
COPY ./artifacts /opt/knowis/solution/artifacts

RUN chmod -R a+rx,a-w /opt/knowis/solution

USER 1000

EXPOSE 8443

Java 17

ARG IMAGE_BASE
FROM ${IMAGE_BASE}

ARG ACRONYM
ARG COMMITSHA
ARG TIMESTAMP
ARG VERSION

LABEL k5.build.acronym=${ACRONYM} \
  k5.build.vcs-ref=${COMMITSHA} \
  k5.build.timestamp=${TIMESTAMP} \
  k5.build.version=${VERSION}

ENV k5.build.acronym=${ACRONYM}
ENV k5.build.vcs-ref=${COMMITSHA}
ENV k5.build.timestamp=${TIMESTAMP}
ENV k5.build.version=${VERSION}
ENV JAVA_APP_DIR=/opt/k5/solution

VOLUME /tmp

USER 0

COPY ./target/app.jar /opt/k5/solution/app.jar
COPY ./cli /opt/k5/solution/cli
COPY ./artifacts /opt/k5/solution/artifacts

RUN chmod -R a+rx,a-w /opt/k5/solution

USER 1000

EXPOSE 8443

Available variables

There are some variables, which are automatically provided by the pipeline. You can make use of them in your custom Dockerfile:

  • ACRONYM: The service project acronym (e.g. myservice)
  • IMAGE_BASE: The configured base image (e.g. openjdk:17-jdk-slim-buster)
  • COMMITSHA: Contains the git commit Sha for the last changes.
  • VERSION: The service project Version (e.g. 1.0.0)
  • TIMESTAMP: build date (e.g. 2023-11-01T21:05:26Z)