From 99972ce0917109b4575bf95989d5421994fbc6da Mon Sep 17 00:00:00 2001 From: r-cemper Date: Wed, 22 May 2024 19:59:55 +0200 Subject: [PATCH 1/2] add DOCKER --- .dockerignore | 3 + .gitattributes | 11 ++ .github/workflows/objectscript-quality.yml | 12 +++ .github/workflows_build-push-gcr.yaml | 19 ++++ .github/workflows_bump-module-version.yml | 28 +++++ .github/workflows_github-registry.yml | 25 +++++ .github/workflows_runtests.yml | 28 +++++ .gitignore | 5 + .vscode/extensions.json | 17 +++ .vscode/launch.json | 18 ++++ .vscode/settings.json | 22 ++++ Dockerfile | 1 + README.md | 62 +++++++++++ ascript.sh | 4 + dev.md | 117 +++++++++++++++++++++ docker-compose.yml | 12 +++ iris.script | 15 +++ module.xml | 18 ++++ 18 files changed, 417 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .github/workflows/objectscript-quality.yml create mode 100644 .github/workflows_build-push-gcr.yaml create mode 100644 .github/workflows_bump-module-version.yml create mode 100644 .github/workflows_github-registry.yml create mode 100644 .github/workflows_runtests.yml create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 Dockerfile create mode 100644 ascript.sh create mode 100644 dev.md create mode 100644 docker-compose.yml create mode 100644 iris.script create mode 100644 module.xml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..114a057 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/.DS_Store +iris-main.log +.git \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..43e39d5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +*.cls linguist-language=ObjectScript +*.mac linguist-language=ObjectScript +*.int linguist-language=ObjectScript +*.inc linguist-language=ObjectScript +*.csp linguist-language=Html + +*.sh text eol=lf +*.cls text eol=lf +*.mac text eol=lf +*.int text eol=lf +Dockerfil* text eol=lf diff --git a/.github/workflows/objectscript-quality.yml b/.github/workflows/objectscript-quality.yml new file mode 100644 index 0000000..df27ddf --- /dev/null +++ b/.github/workflows/objectscript-quality.yml @@ -0,0 +1,12 @@ +name: objectscriptquality +on: push + +jobs: + linux: + name: Linux build + runs-on: ubuntu-latest + + steps: + - name: Execute ObjectScript Quality Analysis + run: wget https://raw.githubusercontent.com/litesolutions/objectscriptquality-jenkins-integration/master/iris-community-hook.sh && sh ./iris-community-hook.sh + diff --git a/.github/workflows_build-push-gcr.yaml b/.github/workflows_build-push-gcr.yaml new file mode 100644 index 0000000..4272bce --- /dev/null +++ b/.github/workflows_build-push-gcr.yaml @@ -0,0 +1,19 @@ +name: Cloud Run Deploy + +on: + push: + branches: + - master + - main + workflow_dispatch: + +jobs: + deploy: + uses: intersystems-community/demo-deployment/.github/workflows/deployment.yml@master + with: + # Replace the name: parameter below to have your application deployed at + # https://project-name.demo.community.intersystems.com/ + name: project-name + secrets: + # Do not forget to add Secret in GitHub Repoository Settings with name SERVICE_ACCOUNT_KEY + SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }} diff --git a/.github/workflows_bump-module-version.yml b/.github/workflows_bump-module-version.yml new file mode 100644 index 0000000..7c54977 --- /dev/null +++ b/.github/workflows_bump-module-version.yml @@ -0,0 +1,28 @@ +name: versionbump + +on: + push: + branches: + - master + - main + release: + types: + - released +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Bump version + run: | + git config --global user.name 'ProjectBot' + git config --global user.email 'bot@users.noreply.github.com' + VERSION=$(sed -n '0,/.*\(.*\)<\/Version>.*/s//\1/p' module.xml) + VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` + sed -i "0,/\(.*\)<\/Version>/s//$VERSION<\/Version>/" module.xml + git add module.xml + git commit -m 'auto bump version' + git push diff --git a/.github/workflows_github-registry.yml b/.github/workflows_github-registry.yml new file mode 100644 index 0000000..05642f6 --- /dev/null +++ b/.github/workflows_github-registry.yml @@ -0,0 +1,25 @@ +name: Build and publish a Docker image to ghcr.io +on: + + # publish on pushes to the main branch (image tagged as "latest") + # image name: will be: ghcr.io/${{ github.repository }}:latest + # e.g.: ghcr.io/intersystems-community/intersystems-iris-dev-template:latest + push: + branches: + - master + +jobs: + docker_publish: + runs-on: "ubuntu-20.04" + + steps: + - uses: actions/checkout@v2 + + # https://github.com/marketplace/actions/push-to-ghcr + - name: Build and publish a Docker image for ${{ github.repository }} + uses: macbre/push-to-ghcr@master + with: + image_name: ${{ github.repository }} + github_token: ${{ secrets.GITHUB_TOKEN }} + # optionally push to the Docker Hub (docker.io) + # docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} # see https://hub.docker.com/settings/security diff --git a/.github/workflows_runtests.yml b/.github/workflows_runtests.yml new file mode 100644 index 0000000..b5e564f --- /dev/null +++ b/.github/workflows_runtests.yml @@ -0,0 +1,28 @@ +name: unittest + +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + release: + types: + - released + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build and Test + uses: docker/build-push-action@v2 + with: + context: . + push: false + load: true + tags: ${{ github.repository }}:${{ github.sha }} + build-args: TESTS=1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..258bec2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +iris-main.log +.env +.git + diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..a019fe9 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,17 @@ +{ + "recommendations": [ + "eamodio.gitlens", + "georgejames.gjlocate", + "github.copilot", + "intersystems-community.servermanager", + "intersystems-community.sqltools-intersystems-driver", + "intersystems-community.testingmanager", + "intersystems-community.vscode-objectscript", + "intersystems.language-server", + "mohsen1.prettify-json", + "ms-azuretools.vscode-docker", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-vscode-remote.remote-containers" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c17f3ea --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "objectscript", + "request": "launch", + "name": "ObjectScript Debug Class", + "program": "##class(dc.sample.ObjectScript).Test()", + }, + { + "type": "objectscript", + "request": "attach", + "name": "ObjectScript Attach", + "processId": "${command:PickProcess}", + "system": true + } + ] + } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..044a229 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "files.associations": { + + "Dockerfile*": "dockerfile", + "iris.script": "objectscript" + }, + "objectscript.conn" :{ + "active": true, + "ns": "USER", + "username": "_SYSTEM", + "password": "SYS", + "docker-compose": { + "service": "iris", + "internalPort": 52773 + }, + "links": { + "UnitTest Portal": "${serverUrl}/csp/sys/%25UnitTest.Portal.Home.cls?$NAMESPACE=IRISAPP" + } + }, + "intersystems.testingManager.client.relativeTestRoot": "tests" + +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..13acaa3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +# fake for OEX docker detection diff --git a/README.md b/README.md index 078d34b..075360e 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,65 @@ or FROM SpatialIndex.Test WHERE %ID %FIND search_index(x1F,'radius','x=55,y=55,radiusX=2,radiusY=2') and name %StartsWith 'Z' + +## Docker + +### Prerequisites +Make sure you have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker desktop](https://www.docker.com/products/docker-desktop) installed. +### Installation +Clone/git pull the repo into any local directory +``` +$ git clone https://github.com/rcemper/PR_System-Alerts.git +``` +to build and start the container run +``` +$ docker compose up -d && docker compose logs -f +``` +A deom Task is prepared. It's named **docker** +http://localhost:42773/csp/sys/op/%25CSP.UI.Portal.TaskInfo.zen?$ID1=1000 +It is ready for you to adjust it to your needs. + +To open IRIS Terminal do: +``` +$ docker-compose exec iris iris session iris +USER> +``` +or using **WebTerminal** +http://localhost:42773/terminal/ + +To access IRIS System Management Portal +http://localhost:42773/csp/sys/UtilHome.csp + +### Testing +The easiest way is to enter a terminal session +and start SQL Shell with its alias **:sql** +and execute the examples in multiline mode + + USER>:sql + SQL Command Line Shell + ---------------------------------------------------- + + The command prefix is currently set to: <>. + Enter , 'q' to quit, '?' for help. + [SQL]USER>> << entering multiline statement mode, 'GO' to execute >> + 1>>SELECT * + 2>>FROM SpatialIndex.Test + 3>>WHERE %ID %FIND search_index(x1F,'radius','x=55,y=55,radiusX=2,radiusY=2') + 4>>and name %StartsWith 'Z' + 5>> + 5>>go + +1. SELECT * + FROM SpatialIndex.Test + WHERE %ID %FIND search_index(x1F,'radius','x=55,y=55,radiusX=2,radiusY=2') + and name %StartsWith 'Z' + +| ID | Latitude | Longitude | Name | +| -- | -- | -- | -- | +| 1446 | 56.6 | 54.05 | Zyablovo | +| 1517 | 56.5461 | 56.1358 | Zverevo | +| 1551 | 55.88074 | 53.2886 | Zuyevy Klyuchi | +| 1571 | 55.88191 | 53.22122 | Zuyevo | +| 1572 | 55.26306 | 55.81972 | Zuyevo | + + ------- diff --git a/ascript.sh b/ascript.sh new file mode 100644 index 0000000..7f0f074 --- /dev/null +++ b/ascript.sh @@ -0,0 +1,4 @@ +cd /home/irisowner/dev +iris view +iris session iris < iris.script +exit 0 \ No newline at end of file diff --git a/dev.md b/dev.md new file mode 100644 index 0000000..080011f --- /dev/null +++ b/dev.md @@ -0,0 +1,117 @@ +# useful commands +## clean up docker +use it when docker says "There is no space left on device". It will remove built but not used images and other temporary files. +``` +docker system prune -f +``` + +``` +docker rm -f $(docker ps -qa) +``` + +## build container with no cache +``` +docker-compose build --no-cache --progress=plain +``` +## start iris container +``` +docker-compose up -d +``` + +## open iris terminal in docker +``` +docker exec iris iris session iris -U IRISAPP +``` + + +## import objectscirpt code + +do $System.OBJ.LoadDir("/home/irisowner/dev/src","ck",,1) +## map iris key from Mac home directory to IRIS in container +- ~/iris.key:/usr/irissys/mgr/iris.key + +## install git in the docker image +## add git in dockerfile +USER root +RUN apt update && apt-get -y install git + +USER ${ISC_PACKAGE_MGRUSER} + + +## install docker-compose +``` +sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + +sudo chmod +x /usr/local/bin/docker-compose + +``` + +## load and test module +``` + +zpm "load /home/irisowner/dev" + +zpm "test dc-sample" +``` + +## select zpm test registry +``` +repo -n registry -r -url https://test.pm.community.intersystems.com/registry/ -user test -pass PassWord42 +``` + +## get back to public zpm registry +``` +repo -r -n registry -url https://pm.community.intersystems.com/ -user "" -pass "" +``` + +## export a global in runtime into the repo +``` +d $System.OBJ.Export("GlobalD.GBL","/irisrun/repo/src/gbl/GlobalD.xml") +``` + +## create a web app in dockerfile +``` +zn "%SYS" \ + write "Create web application ...",! \ + set webName = "/csp/irisweb" \ + set webProperties("NameSpace") = "IRISAPP" \ + set webProperties("Enabled") = 1 \ + set webProperties("CSPZENEnabled") = 1 \ + set webProperties("AutheEnabled") = 32 \ + set webProperties("iKnowEnabled") = 1 \ + set webProperties("DeepSeeEnabled") = 1 \ + set sc = ##class(Security.Applications).Create(webName, .webProperties) \ + write "Web application "_webName_" has been created!",! +``` + + + +``` +do $SYSTEM.OBJ.ImportDir("/opt/irisbuild/src",, "ck") +``` + + +### run tests described in the module + +IRISAPP>zpm +IRISAPP:zpm>load /irisrun/repo +IRISAPP:zpm>test package-name + +### install ZPM with one line + // Install ZPM + set $namespace="%SYS", name="DefaultSSL" do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name) set url="https://pm.community.intersystems.com/packages/zpm/latest/installer" Do ##class(%Net.URLParser).Parse(url,.comp) set ht = ##class(%Net.HttpRequest).%New(), ht.Server = comp("host"), ht.Port = 443, ht.Https=1, ht.SSLConfiguration=name, st=ht.Get(comp("path")) quit:'st $System.Status.GetErrorText(st) set xml=##class(%File).TempFilename("xml"), tFile = ##class(%Stream.FileBinary).%New(), tFile.Filename = xml do tFile.CopyFromAndSave(ht.HttpResponse.Data) do ht.%Close(), $system.OBJ.Load(xml,"ck") do ##class(%File).Delete(xml) + + + + +docker run --rm --name iris-sql -d -p 9091:1972 -p 9092:52773  -e IRIS_PASSWORD=demo -e IRIS_USERNAME=demo intersystemsdc/iris-community + + +docker run --rm --name iris-ce -d -p 9091:1972 -p 9092:52773 -e IRIS_PASSWORD=demo -e IRIS_USERNAME=demo intersystemsdc/iris-community -a "echo 'zpm \"install webterminal\"' | iriscli" + + + +docker run --rm --name iris-sql -d -p 9092:52773 containers.intersystems.com/intersystems/iris-community:2023.1.0.229.0 + + +docker run --rm --name iris-ce -d -p 9092:52773 containers.intersystems.com/intersystems/iris-community:2023.1.0.229.0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..eea062d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.6' +services: + iris: + image: intersystemsdc/iris-community + restart: always + command: -a /home/irisowner/dev/ascript.sh + + ports: + - 41773:1972 + - 42773:52773 + volumes: + - ./:/home/irisowner/dev diff --git a/iris.script b/iris.script new file mode 100644 index 0000000..40fc0d2 --- /dev/null +++ b/iris.script @@ -0,0 +1,15 @@ +zn "%SYS" +// Unexpire passwords and set up passwordless mode to simplify dev use. +do ##class(Security.Users).UnExpireUserPasswords("*") +zpm "install passwordless" +zn "USER" +// Create /_vscode web app to support intersystems-community.testingmanager VS Code extension +zpm "install vscode-per-namespace-settings" +zpm "install webterminal" +// this should be the place for individual application code. +zpm "load /home/irisowner/dev -v":1 +zpm "list" +do ##class(SpatialIndex.Test).load("/home/irisowner/dev/Rucut.txt") +write !?5,"Test data loaded",! +halt + diff --git a/module.xml b/module.xml new file mode 100644 index 0000000..52a4adc --- /dev/null +++ b/module.xml @@ -0,0 +1,18 @@ + + + + + spatialindex + 2.0.0 + Spatialindex Demo + module + src + + + + + \ No newline at end of file From ce8ef7eb7f79473c70dd9f500c2f970d185a5928 Mon Sep 17 00:00:00 2001 From: r-cemper <146277387+r-cemper@users.noreply.github.com> Date: Sat, 16 Aug 2025 19:59:13 +0200 Subject: [PATCH 2/2] Delete .github directory --- .github/workflows/objectscript-quality.yml | 12 ---------- .github/workflows_build-push-gcr.yaml | 19 --------------- .github/workflows_bump-module-version.yml | 28 ---------------------- .github/workflows_github-registry.yml | 25 ------------------- .github/workflows_runtests.yml | 28 ---------------------- 5 files changed, 112 deletions(-) delete mode 100644 .github/workflows/objectscript-quality.yml delete mode 100644 .github/workflows_build-push-gcr.yaml delete mode 100644 .github/workflows_bump-module-version.yml delete mode 100644 .github/workflows_github-registry.yml delete mode 100644 .github/workflows_runtests.yml diff --git a/.github/workflows/objectscript-quality.yml b/.github/workflows/objectscript-quality.yml deleted file mode 100644 index df27ddf..0000000 --- a/.github/workflows/objectscript-quality.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: objectscriptquality -on: push - -jobs: - linux: - name: Linux build - runs-on: ubuntu-latest - - steps: - - name: Execute ObjectScript Quality Analysis - run: wget https://raw.githubusercontent.com/litesolutions/objectscriptquality-jenkins-integration/master/iris-community-hook.sh && sh ./iris-community-hook.sh - diff --git a/.github/workflows_build-push-gcr.yaml b/.github/workflows_build-push-gcr.yaml deleted file mode 100644 index 4272bce..0000000 --- a/.github/workflows_build-push-gcr.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Cloud Run Deploy - -on: - push: - branches: - - master - - main - workflow_dispatch: - -jobs: - deploy: - uses: intersystems-community/demo-deployment/.github/workflows/deployment.yml@master - with: - # Replace the name: parameter below to have your application deployed at - # https://project-name.demo.community.intersystems.com/ - name: project-name - secrets: - # Do not forget to add Secret in GitHub Repoository Settings with name SERVICE_ACCOUNT_KEY - SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }} diff --git a/.github/workflows_bump-module-version.yml b/.github/workflows_bump-module-version.yml deleted file mode 100644 index 7c54977..0000000 --- a/.github/workflows_bump-module-version.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: versionbump - -on: - push: - branches: - - master - - main - release: - types: - - released -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Bump version - run: | - git config --global user.name 'ProjectBot' - git config --global user.email 'bot@users.noreply.github.com' - VERSION=$(sed -n '0,/.*\(.*\)<\/Version>.*/s//\1/p' module.xml) - VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` - sed -i "0,/\(.*\)<\/Version>/s//$VERSION<\/Version>/" module.xml - git add module.xml - git commit -m 'auto bump version' - git push diff --git a/.github/workflows_github-registry.yml b/.github/workflows_github-registry.yml deleted file mode 100644 index 05642f6..0000000 --- a/.github/workflows_github-registry.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build and publish a Docker image to ghcr.io -on: - - # publish on pushes to the main branch (image tagged as "latest") - # image name: will be: ghcr.io/${{ github.repository }}:latest - # e.g.: ghcr.io/intersystems-community/intersystems-iris-dev-template:latest - push: - branches: - - master - -jobs: - docker_publish: - runs-on: "ubuntu-20.04" - - steps: - - uses: actions/checkout@v2 - - # https://github.com/marketplace/actions/push-to-ghcr - - name: Build and publish a Docker image for ${{ github.repository }} - uses: macbre/push-to-ghcr@master - with: - image_name: ${{ github.repository }} - github_token: ${{ secrets.GITHUB_TOKEN }} - # optionally push to the Docker Hub (docker.io) - # docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} # see https://hub.docker.com/settings/security diff --git a/.github/workflows_runtests.yml b/.github/workflows_runtests.yml deleted file mode 100644 index b5e564f..0000000 --- a/.github/workflows_runtests.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: unittest - -on: - push: - branches: - - master - - main - pull_request: - branches: - - master - - main - release: - types: - - released - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build and Test - uses: docker/build-push-action@v2 - with: - context: . - push: false - load: true - tags: ${{ github.repository }}:${{ github.sha }} - build-args: TESTS=1