diff --git a/packages/serverless-logic-web-tools-swf-dev-mode-image/Containerfile b/packages/serverless-logic-web-tools-swf-dev-mode-image/Containerfile index e4d742a7937..4d801e06da2 100644 --- a/packages/serverless-logic-web-tools-swf-dev-mode-image/Containerfile +++ b/packages/serverless-logic-web-tools-swf-dev-mode-image/Containerfile @@ -26,7 +26,8 @@ RUN chown kogito /home/kogito/.m2 USER kogito COPY --chown=kogito:root dist-dev/quarkus-app/ /home/kogito/serverless-logic-web-tools-swf-deployment-quarkus-app/ -COPY --chown=kogito:root dist-dev/quarkus-app-m2/ /home/kogito/.m2/repository +COPY --chown=kogito:root dist-dev/settings.xml /home/kogito/.m2/settings.xml +COPY --chown=kogito:root entrypoint.sh /home/kogito/entrypoint.sh WORKDIR /home/kogito/serverless-logic-web-tools-swf-deployment-quarkus-app/ @@ -35,16 +36,15 @@ RUN rm -rf src/test/ && \ quarkus:go-offline \ -B \ -ntp \ + -s /home/kogito/.m2/settings.xml \ -Dmaven.test.skip \ + -Dmaven.repo.local=/home/kogito/.m2/repository \ -Dquarkus-profiles=build,dev USER root -RUN chmod -R 775 /home/kogito +RUN chmod -R 775 /home/kogito && mkdir -p -m 777 /tmp/app USER kogito -ENTRYPOINT mvn quarkus:dev \ - quarkus:go-offline \ - -nsu \ - -Ddebug=false \ - -Dmaven.repo.local=/home/kogito/.m2/repository \ - -Dquarkus.http.port=8080 +EXPOSE 8080 + +ENTRYPOINT [ "/home/kogito/entrypoint.sh" ] diff --git a/packages/serverless-logic-web-tools-swf-dev-mode-image/entrypoint.sh b/packages/serverless-logic-web-tools-swf-dev-mode-image/entrypoint.sh new file mode 100644 index 00000000000..97c40b91eca --- /dev/null +++ b/packages/serverless-logic-web-tools-swf-dev-mode-image/entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Copying the assets here is essential for when the container is running with the readOnlyRootFilesystem flag. +# But, just like any other directory modified during runtime, the /tmp/app must be a mounted volume in the container in this case. +cp -R /home/kogito/* /tmp/app + +cd /tmp/app/serverless-logic-web-tools-swf-deployment-quarkus-app + +mvn quarkus:dev \ + -nsu \ + -o \ + -s /home/kogito/.m2/settings.xml \ + -Ddebug=false \ + -Dmaven.repo.local=/home/kogito/.m2/repository \ + -Dquarkus.http.port=8080 \ No newline at end of file diff --git a/packages/serverless-logic-web-tools-swf-dev-mode-image/env/index.js b/packages/serverless-logic-web-tools-swf-dev-mode-image/env/index.js index 88feb87c393..79c8786bf6e 100644 --- a/packages/serverless-logic-web-tools-swf-dev-mode-image/env/index.js +++ b/packages/serverless-logic-web-tools-swf-dev-mode-image/env/index.js @@ -21,6 +21,10 @@ const { varsWithName, getOrDefault, composeEnv } = require("@kie-tools-scripts/b const rootEnv = require("@kie-tools/root-env/env"); +const { + env: { mavenM2RepoViaHttpImage: mavenM2RepoViaHttpImageEnv }, +} = require("@kie-tools/maven-m2-repo-via-http-image/env"); + module.exports = composeEnv([rootEnv, require("@kie-tools/serverless-logic-web-tools-swf-dev-mode-image-env/env")], { vars: varsWithName({ /* (begin) This part of the file is referenced in `scripts/update-kogito-version` */ @@ -29,12 +33,21 @@ module.exports = composeEnv([rootEnv, require("@kie-tools/serverless-logic-web-t description: "", }, /* end */ + SERVERLESS_LOGIC_WEB_TOOLS_DEVMODE_IMAGE__mavenM2RepoViaHttpImage: { + default: `${mavenM2RepoViaHttpImageEnv.registry}/${mavenM2RepoViaHttpImageEnv.account}/${mavenM2RepoViaHttpImageEnv.name}:${mavenM2RepoViaHttpImageEnv.tag}`, + description: "The image tag for the Maven M2 Repo via HTTP. Used during the build only.", + }, }), get env() { return { swfDevModeImage: { version: require("../package.json").version, kogitoImageTag: getOrDefault(this.vars.SERVERLESS_LOGIC_WEB_TOOLS_DEVMODE_IMAGE__kogitoBaseBuilderImageTag), + dev: { + mavenM2RepoViaHttpImage: getOrDefault( + this.vars.SERVERLESS_LOGIC_WEB_TOOLS_DEVMODE_IMAGE__mavenM2RepoViaHttpImage + ), + }, }, }; }, diff --git a/packages/serverless-logic-web-tools-swf-dev-mode-image/package.json b/packages/serverless-logic-web-tools-swf-dev-mode-image/package.json index bf3cd627c5a..c94a5c47300 100644 --- a/packages/serverless-logic-web-tools-swf-dev-mode-image/package.json +++ b/packages/serverless-logic-web-tools-swf-dev-mode-image/package.json @@ -13,20 +13,29 @@ "url": "https://github.com/apache/incubator-kie-tools/issues" }, "scripts": { - "build:dev": "echo Nothing to do", - "build:prod": "pnpm cleanup && run-script-os", - "build:prod:darwin:linux": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm copy:assets\" \"pnpm image:docker:build\"", - "build:prod:win32": "echo \"Build not supported on Windows\"", - "cleanup": "rimraf dist-dev && mkdir dist-dev", - "copy:assets": "pnpm copy:quarkus-app && pnpm copy:sonataflow-deployment-webapp && pnpm copy:m2-for-sonataflow-quarkus-devui", - "copy:m2-for-sonataflow-quarkus-devui": "mvn dependency:copy-dependencies -Dmdep.useRepositoryLayout=true -Dmdep.copyPom=true -DexcludeTransitive=true -DoutputDirectory=./dist-dev/quarkus-app-m2", - "copy:quarkus-app": "cp -R ./node_modules/@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app/ ./dist-dev/quarkus-app && mkdir -p ./dist-dev/quarkus-app/src/main/resources/META-INF/resources/ && rm -rf ./dist-dev/quarkus-app/node_modules ./dist-dev/quarkus-app/install.js ./dist-dev/quarkus-app/env ./dist-dev/quarkus-app/package.json", - "copy:sonataflow-deployment-webapp": "cp -R ./node_modules/sonataflow-deployment-webapp/dist/* ./dist-dev/quarkus-app/src/main/resources/META-INF/resources", - "image:docker:build": "run-script-if --bool $([ $(command -v docker) ] && echo true || echo false) --then \"docker build --ulimit nofile=5000:5000 $(echo $(build-env swfDevModeImageEnv.buildTag) | xargs printf -- \"-t $(build-env swfDevModeImageEnv.registry)/$(build-env swfDevModeImageEnv.account)/$(build-env swfDevModeImageEnv.name):%s\n\" | xargs echo) --build-arg KOGITO_IMAGE_TAG=$(build-env swfDevModeImage.kogitoImageTag) .\" --else \"echo Docker not found, skipping image build.\"", - "install": "node install.js" + "build": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm m2-repo-via-http:container:run\" \"pnpm copy:assets\" \"pnpm image:docker:build\" --finally \"pnpm m2-repo-via-http:container:kill\"", + "build:dev": "pnpm build", + "build:prod": "pnpm build", + "copy:assets": "rimraf dist-dev && mkdir -p ./dist-dev && pnpm copy:quarkus-app && pnpm copy:sonataflow-deployment-webapp && pnpm copy:maven-m2-repo-via-http-image--settings-xml", + "copy:maven-m2-repo-via-http-image--settings-xml": "run-script-os", + "copy:maven-m2-repo-via-http-image--settings-xml:linux:darwin": "M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' m2-repo-via-http) envsubst < ./node_modules/@kie-tools/maven-m2-repo-via-http-image/settings.xml.envsubst > dist-dev/settings.xml", + "copy:maven-m2-repo-via-http-image--settings-xml:win32": "pnpm powershell \"(Get-Content ./node_modules/@kie-tools/maven-m2-repo-via-http-image/settings.xml.envsubst) -replace '$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL', $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' m2-repo-via-http) | Set-Content ./dist-dev/settings.xml\"", + "copy:quarkus-app": "run-script-os", + "copy:quarkus-app:linux:darwin": "cp -R ./node_modules/@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app/ ./dist-dev/quarkus-app && mkdir -p ./dist-dev/quarkus-app/src/main/resources/META-INF/resources/ && rm -rf ./dist-dev/quarkus-app/node_modules ./dist-dev/quarkus-app/install.js ./dist-dev/quarkus-app/env ./dist-dev/quarkus-app/package.json", + "copy:quarkus-app:win32": "pnpm powershell \"New-Item -ItemType Directory -Force -Path ./dist-dev/quarkus-app; Copy-Item -R ./node_modules/@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app/* ./dist-dev/quarkus-app -Exclude @('node_modules', 'install.js', 'package.json'); New-Item -ItemType Directory -Force -Path ./dist-dev/quarkus-app/src/main/resources/META-INF/resources \"", + "copy:sonataflow-deployment-webapp": "run-script-os", + "copy:sonataflow-deployment-webapp:linux:darwin": "cp -R ./node_modules/sonataflow-deployment-webapp/dist/* ./dist-dev/quarkus-app/src/main/resources/META-INF/resources", + "copy:sonataflow-deployment-webapp:win32": "pnpm powershell \"Copy-Item -R ./node_modules/sonataflow-deployment-webapp/dist/* ./dist-dev/quarkus-app/src/main/resources/META-INF/resources\"", + "image:docker:build": "kie-tools--image-builder build --allowHostNetworkAccess -r \"$(build-env swfDevModeImageEnv.registry)\" -a \"$(build-env swfDevModeImageEnv.account)\" -n \"$(build-env swfDevModeImageEnv.name)\" -t \"$(build-env swfDevModeImageEnv.buildTag)\" --build-arg KOGITO_IMAGE_TAG=\"$(build-env swfDevModeImage.kogitoImageTag)\"", + "install": "node install.js", + "m2-repo-via-http:container:kill": "(docker container kill m2-repo-via-http || true) && (docker container rm m2-repo-via-http || true)", + "m2-repo-via-http:container:run": "(pnpm m2-repo-via-http:container:kill || true) && docker run --name m2-repo-via-http -v \"$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout):/var/www/html\" -dit $(build-env swfDevModeImage.dev.mavenM2RepoViaHttpImage)", + "powershell": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command" }, "devDependencies": { + "@kie-tools/image-builder": "workspace:*", "@kie-tools/maven-config-setup-helper": "workspace:*", + "@kie-tools/maven-m2-repo-via-http-image": "workspace:*", "@kie-tools/root-env": "workspace:*", "@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app": "workspace:*", "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image-env": "workspace:*", diff --git a/packages/serverless-logic-web-tools-swf-dev-mode-image/pom.xml b/packages/serverless-logic-web-tools-swf-dev-mode-image/pom.xml deleted file mode 100644 index ae9a454ff68..00000000000 --- a/packages/serverless-logic-web-tools-swf-dev-mode-image/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - 4.0.0 - org.kie.kogito - serverless-logic-web-tools-swf-deployment-quarkus-app-image - ${revision} - - - - org.apache.kie.sonataflow - sonataflow-quarkus-devui-deployment - ${project.version} - - - org.apache.kie.sonataflow - sonataflow-quarkus-devui - ${project.version} - - - org.apache.kie.sonataflow - sonataflow-quarkus-devui-parent - ${project.version} - pom - - - org.kie - kie-tools-maven-base - ${project.version} - pom - - - diff --git a/packages/serverless-logic-web-tools/src/openshift/pipelines/SpinUpDevModePipeline.ts b/packages/serverless-logic-web-tools/src/openshift/pipelines/SpinUpDevModePipeline.ts index 995c6305697..c6af69a9842 100644 --- a/packages/serverless-logic-web-tools/src/openshift/pipelines/SpinUpDevModePipeline.ts +++ b/packages/serverless-logic-web-tools/src/openshift/pipelines/SpinUpDevModePipeline.ts @@ -197,6 +197,12 @@ export class SpinUpDevModePipeline extends OpenShiftPipeline "sonataflow-deployment-webapp" [ style = "dashed", color = "black" ]; "@kie-tools/serverless-logic-web-tools-swf-builder-image-env" -> "@kie-tools/root-env" [ style = "dashed", color = "black" ]; "@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app" -> "@kie-tools/sonataflow-quarkus-devui" [ style = "solid", color = "black" ]; + "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image" -> "@kie-tools/maven-m2-repo-via-http-image" [ style = "dashed", color = "black" ]; "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image" -> "@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app" [ style = "dashed", color = "black" ]; "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image" -> "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image-env" [ style = "dashed", color = "black" ]; "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image" -> "sonataflow-deployment-webapp" [ style = "dashed", color = "black" ]; diff --git a/repo/graph.json b/repo/graph.json index 60aff7139af..f706f858ade 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -2179,6 +2179,11 @@ "target": "@kie-tools/sonataflow-quarkus-devui", "weight": 1 }, + { + "source": "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image", + "target": "@kie-tools/maven-m2-repo-via-http-image", + "weight": 1 + }, { "source": "@kie-tools/serverless-logic-web-tools-swf-dev-mode-image", "target": "@kie-tools/serverless-logic-web-tools-swf-deployment-quarkus-app",