remkohdev
  • Learn to Code
  • About Me
  • CI/CD
    • DevOps101
      • Welcome
  • OpenShift
    • Setup OpenShift
      • Setup Minishift
    • Builds
      • Source-to-Image (S2I)
        • Setup S2I
        • Build, Run, Deploy from Source
      • Jenkins Pipeline
    • Jenkins as a Service
      • Setup Jenkins on Openshift
      • Create a Pipeline for Java Spring Boot
  • Istio
    • Setup Istio on IKS
      • Login to IKS
    • Setup Istio on Openshift 3.11
    • Traffic Shifts with a VirtualService
    • Telemetry of Metrics using Prometheus
    • Telemetry of Distributed Tracing using Jaeger
    • Security with Mutual TLS (mTLS)
  • Apache Kafka
    • Setup Apache Kafka on IBM Cloud
    • Setup Apache Kafka on OpenShift
    • Produce and Consume Streams with Kafka Console Tools
    • Produce and Consume Streams with Spring Boot
    • Using the Event Streams CLI
    • Kafka Admin API
  • API Connect
    • APIC CLI
      • Manage API Lifecycle with apic
    • Securing your API
      • Setup AppID
      • Setup API Connect
      • Optional: Add Node-RED Test Server
      • Add 3rd Party OAuth OIDC
        • Create a Custom AppID API
        • Add a Security Definition to your API
Powered by GitBook
On this page

Was this helpful?

  1. OpenShift
  2. Builds
  3. Source-to-Image (S2I)

Build, Run, Deploy from Source

  • Get the source code for the spring-client app, and remove the Jenkinsfile from root,

$ git clone https://github.com/remkohdev/spring-client.git
$ cd spring-client
$ mkdir Jenkins
$ mv Jenkinsfile Jenkins
  • Download the builder image for Java,

  • You can use the private registry,

$ cd ~/dev/src/projects/spring-client
$ echo 'passw0rd' | docker login https://registry.redhat.io -u remkohdev --password-stdin
$ docker pull registry.redhat.com/redhat-openjdk-18/openjdk18-openshift
  • Or the public registry,

$ docker pull registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
  • Build the image from source,

$ s2i build . registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift s2i-spring-client
$ docker images
REPOSITORY    TAG    IMAGE ID    CREATED    SIZE
s2i-spring-client    latest    4809340c9b4b    57 seconds ago    583MB
registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift   latest    74c8511ec481    5 weeks ago    480MB
  • Docker run the spring-client,

$ docker run -d -p 8080:8080 s2i-spring-client
  • Test,

$ newman run postman/springclient-test.postman_collection.json
  • Deploy to OpenShift,

$ oc project s2i-spring-client-ns
$ oc new-app --name springclient registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift~. --strategy=source --allow-missing-images --build-env='JAVA_APP_JAR=hello.jar'
$ oc expose svc/springclient
$ oc status

PreviousSetup S2INextJenkins Pipeline

Last updated 5 years ago

Was this helpful?