oc create -f - -n openshift <<EOF
---
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: r-shiny-s2i
---
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
build: r-shiny-s2i
name: r-shiny-s2i
spec:
failedBuildsHistoryLimit: 5
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: r-shiny-s2i:latest
postCommit: {}
resources: {}
runPolicy: Serial
source:
contextDir: build/s2i-R-shiny/builder
git:
uri: 'https://github.com/rbo/openshift-examples.git'
type: Git
strategy:
dockerStrategy:
from:
kind: DockerImage
name: 'rhscl/s2i-base-rhel7:latest'
type: Docker
successfulBuildsHistoryLimit: 5
EOF
oc start-build r-shiny-s2i [--follow] -n openshift
oc create -f - -n openshif <<EOF
apiVersion: template.openshift.io/v1
kind: Template
labels:
template: s2i-r-shiny-example
message: |-
The following service(s) have been created in your project: ${NAME}.
For more information about using this template, including OpenShift considerations, see https://github.com/rbo/openshift-examples/tree/master/build/s2i-R-shiny.
metadata:
annotations:
description: An example R shiny https://github.com/rbo/openshift-examples/tree/master/build/s2i-R-shiny.
iconClass: icon-play
openshift.io/display-name: R Shiny exmaple
openshift.io/documentation-url: https://github.com/rbo/openshift-examples/tree/master/build/s2i-R-shiny
openshift.io/long-description: R Shiny exmaple
openshift.io/provider-display-name: Robert Bohne
openshift.io/support-url: https://github.com/rbo/openshift-examples/tree/master/build/s2i-R-shiny
tags: quickstart,r,shiny,r-shiny,s2i
creationTimestamp: null
name: s2i-r-shiny-example
objects:
- apiVersion: v1
kind: Service
metadata:
annotations:
description: Exposes and load balances the application pods
name: ${NAME}
spec:
ports:
- name: web
port: 8080
targetPort: 8080
selector:
name: ${NAME}
- apiVersion: v1
kind: Route
metadata:
annotations:
template.openshift.io/expose-uri: http://{.spec.host}{.spec.path}
name: ${NAME}
spec:
host: ${APPLICATION_DOMAIN}
to:
kind: Service
name: ${NAME}
- apiVersion: v1
kind: ImageStream
metadata:
annotations:
description: Keeps track of changes in the application image
name: ${NAME}
- apiVersion: v1
kind: BuildConfig
metadata:
annotations:
description: Defines how to build the application
template.alpha.openshift.io/wait-for-ready: "true"
name: ${NAME}
spec:
output:
to:
kind: ImageStreamTag
name: ${NAME}:latest
source:
contextDir: ${CONTEXT_DIR}
git:
ref: ${SOURCE_REPOSITORY_REF}
uri: ${SOURCE_REPOSITORY_URL}
type: Git
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: r-shiny-s2i:latest
namespace: ${NAMESPACE}
type: Source
triggers:
- type: ImageChange
- type: ConfigChange
- github:
secret: ${GITHUB_WEBHOOK_SECRET}
type: GitHub
- generic:
secret: ${GENERIC_WEBHOOK_SECRET}
type: Generic
- apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
description: Defines how to deploy the application server
template.alpha.openshift.io/wait-for-ready: "true"
name: ${NAME}
spec:
replicas: 1
selector:
name: ${NAME}
strategy:
type: Rolling
template:
metadata:
labels:
name: ${NAME}
name: ${NAME}
spec:
containers:
- env: []
image: ' '
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 30
timeoutSeconds: 3
name: s2i-r-shiny
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 3
timeoutSeconds: 3
resources:
limits:
memory: ${MEMORY_LIMIT}
triggers:
- imageChangeParams:
automatic: true
containerNames:
- s2i-r-shiny
from:
kind: ImageStreamTag
name: ${NAME}:latest
type: ImageChange
- type: ConfigChange
parameters:
- description: The name assigned to all of the frontend objects defined in this template.
displayName: Name
name: NAME
required: true
value: word-cloud
- description: The OpenShift Namespace where the ImageStream resides.
displayName: Namespace
name: NAMESPACE
required: true
value: openshift
- description: Maximum amount of memory the container can use.
displayName: Memory Limit
name: MEMORY_LIMIT
required: true
value: 512Mi
- description: The URL of the repository with your application source code.
displayName: Git Repository URL
name: SOURCE_REPOSITORY_URL
required: true
value: https://github.com/rstudio/shiny-examples.git
- description: Set this to a branch name, tag or other ref of your repository if you
are not using the default branch.
displayName: Git Reference
name: SOURCE_REPOSITORY_REF
value: master
- description: Set this to the relative path to your project if it is not in the root
of your repository.
displayName: Context Directory
name: CONTEXT_DIR
value: 082-word-cloud
- description: The exposed hostname that will route to the r shiny service, if left
blank a value will be defaulted.
displayName: Application Hostname
name: APPLICATION_DOMAIN
- description: Github trigger secret. A difficult to guess string encoded as part
of the webhook URL. Not encrypted.
displayName: GitHub Webhook Secret
from: '[a-zA-Z0-9]{40}'
generate: expression
name: GITHUB_WEBHOOK_SECRET
- description: A secret string used to configure the Generic webhook.
displayName: Generic Webhook Secret
from: '[a-zA-Z0-9]{40}'
generate: expression
name: GENERIC_WEBHOOK_SECRET
EOF
FROM docker-registry-default.ocp3.bohne.io/openshift/r-shiny-s2i:latest
COPY ./s2i/bin/ /usr/libexec/s2i
USER 1001
# Set the default port for applications built using this image
EXPOSE 8080
CMD ["/usr/libexec/s2i/usage"]
docker pull docker-registry-default.ocp3.bohne.io/openshift/r-shiny-s2i:latest
docker build -t b -f Dockerfile.playground .
s2i build https://github.com/rstudio/shiny-examples b b-app --context-dir=027-absolutely-positioned-panels --loglevel=99
# Or by hand: docker run -ti --entrypoint bash -v $(pwd):/tmp/src b
docker run word-cloud