Skip to content

Commit

Permalink
Updating the devfile to make it easier to use with odo and have more
Browse files Browse the repository at this point in the history
configuration options using variables

Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Sep 8, 2023
1 parent e6fd9ca commit 17a0b95
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 0 deletions.
20 changes: 20 additions & 0 deletions stacks/java-wildfly/2.0.1/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG IMAGE_VERSION=latest-jdk17

FROM quay.io/wildfly/wildfly-s2i:$IMAGE_VERSION AS builder

ENV MVN_ARGS_APPEND="-s /home/jboss/.m2/settings.xml -Dmaven.repo.local=/home/jboss/.m2/repository -Dcom.redhat.xpaas.repo.jbossorg"
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/urandom"
ENV S2I_DESTINATION_DIR=/build

WORKDIR /build
RUN mkdir src
COPY --chown=jboss:root pom.xml .
COPY --chown=jboss:root src src
RUN mvn $MVN_ARGS_APPEND -Popenshift -Dmaven.test.skip=true clean package

FROM quay.io/wildfly/wildfly-runtime:$IMAGE_VERSION AS runtime

ENV SERVER_ARGS=-Djboss.http.port=8081
COPY --chown=jboss:root --from=builder /build/target/server $JBOSS_HOME
RUN chmod -R ug+rwX $JBOSS_HOME
EXPOSE 8080
52 changes: 52 additions & 0 deletions stacks/java-wildfly/2.0.1/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: '{{applicationName}}'
spec:
replicas: 1
selector:
matchLabels:
app: '{{applicationName}}'
template:
metadata:
labels:
app: '{{applicationName}}'
spec:
containers:
- name: '{{applicationName}}'
image: '{{imageName}}:{{imageVersion}}'
ports:
- name: http
containerPort: 8081
protocol: TCP
resources:
limits:
memory: "1024Mi"
cpu: "500m"
---
kind: Service
apiVersion: v1
metadata:
name: '{{applicationName}}-svc'
spec:
ports:
- name: http-8081
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: '{{applicationName}}'
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: '{{applicationName}}-route'
spec:
to:
kind: Service
name: '{{applicationName}}-svc'
weight: 100
port:
targetPort: http-8081
wildcardPolicy: None

164 changes: 164 additions & 0 deletions stacks/java-wildfly/2.0.1/devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
schemaVersion: 2.2.0
metadata:
name: wildfly-start
version: 2.0.1
website: https://wildfly.org
displayName: WildFly Getting Started
description: Upstream WildFly Getting Started
icon: https://design.jboss.org/wildfly/logo/final/wildfly_logomark.svg
tags: ['Java', 'WildFly']
projectType: 'wildfly'
language: 'java'
variables:
imageRegistry: 'quay.io'
imageName: 'getting-started'
imageVersion: 'latest'
applicationName: 'start'
nodeName: 'getting-started'
starterProjects:
- name: getting-started
description: WildFly Getting Started
git:
checkoutFrom:
remote: wildfly-devfile-examples
revision: getting-started
remotes:
wildfly-devfile-examples: https://github.com/wildfly-extras/wildfly-devfile-examples.git
components:
- name: tools
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest
memoryLimit: 1512Mi
mountSources: true
volumeMounts:
- name: m2
path: /home/user/.m2
env:
- name: JAVA_OPTS
value: '-Djava.security.egd=file:/dev/urandom -Djboss.host.name=localhost'
- name: DEBUG_PORT
value: '5005'
- name: NODE_NAME
value: '{{nodeName}}'
- name: IMAGE_REGISTRY
value: '{{imageRegistry}}'
- name: IMAGE
value: '{{imageName}}'
endpoints:
- name: debug
exposure: internal
protocol: tcp
targetPort: 5005
- name: 'http'
protocol: http
targetPort: 8080
exposure: public
- name: 'management'
targetPort: 9990
protocol: http
exposure: internal
- name: image-build
image:
dockerfile:
buildContext: .
rootRequired: false
uri: Containerfile
imageName: '{{imageName}}:{{imageVersion}}'
- name: kubernetes-deploy
kubernetes:
endpoints:
- name: http-8081
path: /
targetPort: 8081
uri: deploy.yaml
attributes:
deployment/container-port: 8081
deployment/cpuLimit: 100m
deployment/cpuRequest: 10m
deployment/memoryLimit: 300Mi
deployment/memoryRequest: 180Mi
deployment/replicas: 1
- name: m2
volume:
size: 3Gi
commands:
- id: package
exec:
label: "InnerLoop 01 - Build the application."
component: tools
commandLine: mvn clean verify
workingDir: ${PROJECT_SOURCE}
hotReloadCapable: true
group:
kind: build
isDefault: true
- id: run
exec:
label: "InnerLoop 02 - Run the application in dev mode."
component: tools
commandLine: mvn -Dwildfly.javaOpts="-Djboss.host.name=${NODE_NAME}" -Dmaven.test.skip=true clean package org.wildfly.plugins:wildfly-maven-plugin:dev
workingDir: ${PROJECT_SOURCE}
hotReloadCapable: true
group:
kind: run
isDefault: true
- id: debug
exec:
label: "InnerLoop 03 - Debug the application in dev mode."
component: tools
commandLine: mvn -Dwildfly.javaOpts="-Djboss.host.name=${NODE_NAME} -agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" -Dmaven.test.skip=true clean package org.wildfly.plugins:wildfly-maven-plugin:dev
workingDir: ${PROJECT_SOURCE}
hotReloadCapable: true
group:
kind: debug
isDefault: true
- id: build-runtime-image
exec:
label: "OuterLoop 01 - Build Runtime Image."
component: tools
commandLine: "podman build -f Containerfile -t ${IMAGE_REGISTRY}/${IMAGE_REGISTRY_NAMESPACE}/${IMAGE} ."
workingDir: ${PROJECT_SOURCE}
group:
kind: build
isDefault: false
- id: push-image
exec:
label: "OuterLoop 02 - Push Image into image registry."
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "podman tag ${IMAGE_REGISTRY}/${IMAGE_REGISTRY_NAMESPACE}/${IMAGE} ${IMAGE_REGISTRY}/${IMAGE_REGISTRY_NAMESPACE}/${IMAGE}:latest && podman login ${IMAGE_REGISTRY} -u ${IMAGE_REGISTRY_LOGIN} -p ${IMAGE_REGISTRY_PASSWORD} && podman push --tls-verify=false ${IMAGE_REGISTRY}/${IMAGE_REGISTRY_NAMESPACE}/${IMAGE}:latest"
group:
kind: build
isDefault: false
- id: deploy-image
exec:
label: "OuterLoop 03 - Deploy Image into the cloud."
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "helm repo add wildfly https://docs.wildfly.org/wildfly-charts/ && helm install ${IMAGE} -f .charts/helm.yaml --set build.enabled=false --set image.name=${IMAGE_REGISTRY}/${IMAGE_REGISTRY_NAMESPACE}/${IMAGE} wildfly/wildfly"
group:
kind: run
isDefault: false
- id: undeploy-image
exec:
label: "OuterLoop 04 - Undeploy Image from the cloud."
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "helm uninstall ${IMAGE}"
group:
kind: run
isDefault: false
- id: build-image
apply:
component: image-build
- id: deployk8s
apply:
component: kubernetes-deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
1 change: 1 addition & 0 deletions stacks/java-wildfly/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ icon: https://design.jboss.org/wildfly/logo/final/wildfly_logomark.svg
versions:
- version: 1.1.0
- version: 2.0.0
- vresion: 2.0.1
default: true

0 comments on commit 17a0b95

Please sign in to comment.