/workshop

Primary LanguageDockerfile

Workshop

01-basic-components

  1. Start minishift
  2. Check if everything is working
  3. 01-basic-components/setup.sh # to setup a project

02-docker-multistage

To play around with and get a feel for multistage builds

cd 02-docker-multistage
IMAGE_NAME=spring-test

docker build -t $IMAGE_NAME . # builds default stage
docker build -t ${IMAGE_NAME}:runtime-alpine --target runtime-alpine . #builds runtime-alpine stage
docker build -t ${IMAGE_NAME}:debug --target debug . # builds debug stage


TAG_TO_RUN=runtime-alpine
docker run --rm -p 8080:8080 ${IMAGE_NAME}:${TAG_TO_RUN}

Docker basics

COPY VS ADD

"Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /."

--init # https://github.com/krallin/tini

ENTRYPOINT VS. CMD

https://docs.docker.com/engine/reference/builder/#entrypoint

Further resoruces

Source2image: 03-okd-s2i

Used base images: https://hub.docker.com/r/fabric8/s2i-java // https://github.com/fabric8io-images/s2i

cd 03-okd-s2i

Steps

  1. Import the base image: oc import-image -h # check which params you can set

oc apply -f imagestream.yml # create imagestream

  1. create s2i-build-config:
# process template via: oc process -f s2i.yml -p APPLICATION_NAME=XY -p REPOSITORY_URL=re...
oc process -f s2i.yml \
  -p APPLICATION_NAME=spring-boot \
  -p REPOSITORY_URL=https://github.com/spring-guides/gs-spring-boot.git \
  -p CONTEXT_DIR=complete \
  | oc apply -f -
  1. start a build: oc start-build spring-boot-dev -w # -w watches the output

  2. Create svc and dc: oc new-app --image-stream spring-boot

Resources

https://docs.openshift.com/online/dev_guide/builds/advanced_build_operations.html https://docs.openshift.com/online/dev_guide/builds/build_strategies.html

04-okd-chained-build

see README.md in 04-okd-chained-build

Platform pattern

pattern

  • Single node multi container: sidecar, ambassador, adapter
  • Multi node: leader election, work queue, scatter/gather

Ambassador / proxy - 05-ambassador

Run the files via oc apply -f <file/directory>

The main container communicates or gets called through an ambassador. (Proxy, name resolver, ...) https://github.com/openshift/oauth-proxy/blob/master/contrib/sidecar.yaml

Sidecar - 06-sidecar

Enhances basic pod functionality. Logging, circut breaker, ...

Adapter - 07-adapter

Like an adapter in software development. Changes the interface or converts the requests from or to the main container

Openshift guide

https://github.com/openshift-labs/devops-guides