Skip to content

Commit dcfd156

Browse files
committed
Initial commit
0 parents  commit dcfd156

17 files changed

+330
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/.DS_Store
2+
.git

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.sh text eol=lf
2+
*.cls text eol=lf
3+
*.mac text eol=lf
4+
*.int text eol=lf
5+
Dockerfil* text eol=lf
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: objectscriptquality
2+
on: push
3+
4+
jobs:
5+
linux:
6+
name: Linux build
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Execute ObjectScript Quality Analysis
11+
run: wget https://raw.githubusercontent.com/litesolutions/objectscriptquality-jenkins-integration/master/iris-community-hook.sh && sh ./iris-community-hook.sh
12+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
3+

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "objectscript",
6+
"request": "launch",
7+
"name": "ObjectScript Debug Class",
8+
"program": "##class(PackageSample.ObjectScript).Test()",
9+
},
10+
{
11+
"type": "objectscript",
12+
"request": "attach",
13+
"name": "ObjectScript Attach",
14+
"processId": "${command:PickProcess}",
15+
"system": true
16+
}
17+
]
18+
}

.vscode/settings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"files.associations": {
3+
4+
"Dockerfile*": "dockerfile",
5+
"iris.script": "objectscript"
6+
},
7+
"objectscript.conn" :{
8+
"ns": "IRISAPP",
9+
"active": true,
10+
"username":"_SYSTEM",
11+
"password": "SYS",
12+
"docker-compose": {
13+
"service": "iris",
14+
"internalPort": 52773
15+
}
16+
}
17+
18+
}

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARG IMAGE=store/intersystems/iris-community:2020.1.0.204.0
2+
ARG IMAGE=intersystemsdc/iris-community:2020.1.0.209.0-zpm
3+
ARG IMAGE=intersystemsdc/iris-community:2020.2.0.204.0-zpm
4+
ARG IMAGE=intersystemsdc/iris-community:2020.3.0.200.0-zpm
5+
ARG IMAGE=intersystemsdc/irishealth-community:2020.3.0.200.0-zpm
6+
FROM $IMAGE
7+
8+
USER root
9+
10+
WORKDIR /opt/irisapp
11+
RUN chown ${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /opt/irisapp
12+
USER ${ISC_PACKAGE_MGRUSER}
13+
14+
COPY Installer.cls .
15+
COPY src src
16+
COPY iris.script /tmp/iris.script
17+
18+
# run iris and initial
19+
RUN iris start IRIS \
20+
&& iris session IRIS < /tmp/iris.script

Dockerfile-web

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ARG IMAGE=intersystems/iris:2019.1.0S.111.0
2+
ARG IMAGE=store/intersystems/irishealth:2019.3.0.308.0-community
3+
ARG IMAGE=store/intersystems/iris-community:2019.3.0.309.0
4+
ARG IMAGE=store/intersystems/iris-community:2019.4.0.379.0
5+
FROM $IMAGE
6+
7+
USER root
8+
9+
WORKDIR /opt/irisapp
10+
RUN chown ${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /opt/irisapp
11+
12+
USER irisowner
13+
14+
COPY Installer.cls .
15+
COPY src src
16+
COPY irissession.sh /
17+
SHELL ["/irissession.sh"]
18+
19+
RUN \
20+
do $SYSTEM.OBJ.Load("Installer.cls", "ck") \
21+
set sc = ##class(App.Installer).setup() \
22+
zn "%SYS" \
23+
write "Create web application ...",! \
24+
set webName = "/csp/irisweb" \
25+
set webProperties("NameSpace") = "IRISAPP" \
26+
set webProperties("Enabled") = 1 \
27+
set webProperties("CSPZENEnabled") = 1 \
28+
set webProperties("AutheEnabled") = 32 \
29+
set webProperties("iKnowEnabled") = 1 \
30+
set webProperties("DeepSeeEnabled") = 1 \
31+
set sc = ##class(Security.Applications).Create(webName, .webProperties) \
32+
write "Web application "_webName_" has been created!",!
33+
34+
35+
# bringing the standard shell back
36+
SHELL ["/bin/bash", "-c"]
37+
CMD [ "-l", "/usr/irissys/mgr/messages.log" ]

Installer.cls

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Class App.Installer
2+
{
3+
4+
XData setup
5+
{
6+
<Manifest>
7+
<Default Name="SourceDir" Value="#{$system.Process.CurrentDirectory()}src"/>
8+
<Default Name="Namespace" Value="IRISAPP"/>
9+
<Default Name="app" Value="irisapp" />
10+
11+
<Namespace Name="${Namespace}" Code="${Namespace}" Data="${Namespace}" Create="yes" Ensemble="0">
12+
13+
<Configuration>
14+
<Database Name="${Namespace}" Dir="/opt/${app}/data" Create="yes" Resource="%DB_${Namespace}"/>
15+
</Configuration>
16+
<Import File="${SourceDir}" Flags="ck" Recurse="1"/>
17+
<CSPApplication Url="/csp/${app}" Directory="${cspdir}${app}" ServeFiles="1" Recurse="1" MatchRoles=":%DB_${Namespace}" AuthenticationMethods="32"
18+
19+
/>
20+
</Namespace>
21+
22+
</Manifest>
23+
}
24+
25+
ClassMethod setup(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal ]
26+
{
27+
#; Let XGL document generate code for this method.
28+
Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "setup")
29+
}
30+
31+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 InterSystems Developer Community
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## intersystems-objectscript-template
2+
This is a template for InterSystems ObjectScript Github repository.
3+
The template goes also with a few files which let you immedietly compile your ObjecScript files in InterSystems IRIS Community Edition in a docker container
4+
5+
## Prerequisites
6+
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.
7+
8+
## Installation
9+
10+
Clone/git pull the repo into any local directory
11+
12+
```
13+
$ git clone https://github.com/intersystems-community/objectscript-docker-template.git
14+
```
15+
16+
Open the terminal in this directory and run:
17+
18+
```
19+
$ docker-compose build
20+
```
21+
22+
3. Run the IRIS container with your project:
23+
24+
```
25+
$ docker-compose up -d
26+
```
27+
28+
## How to Test it
29+
30+
Open IRIS terminal:
31+
32+
```
33+
$ docker-compose exec iris iris session iris
34+
USER>zn "IRISAPP"
35+
IRISAPP>write ##class(PackageSample.ObjectScript).Test()
36+
```
37+
## How to start coding
38+
This repository is ready to code in VSCode with ObjectScript plugin.
39+
Install [VSCode](https://code.visualstudio.com/), [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) and [ObjectScript](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript) plugin and open the folder in VSCode.
40+
Open /src/cls/PackageSample/ObjectScript.cls class and try to make changes - it will be compiled in running IRIS docker container.
41+
![docker_compose](https://user-images.githubusercontent.com/2781759/76656929-0f2e5700-6547-11ea-9cc9-486a5641c51d.gif)
42+
43+
Feel free to delete PackageSample folder and place your ObjectScript classes in a form
44+
/src/Package/Classname.cls
45+
[Read more about folder setup for InterSystems ObjectScript](https://community.intersystems.com/post/simplified-objectscript-source-folder-structure-package-manager)
46+
47+
The script in Installer.cls will import everything you place under /src into IRIS.
48+
49+
50+
## What's inside the repository
51+
52+
### Dockerfile
53+
54+
The simplest dockerfile which starts IRIS and imports Installer.cls and then runs the Installer.setup method, which creates IRISAPP Namespace and imports ObjectScript code from /src folder into it.
55+
Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders.
56+
Use .env/ file to adjust the dockerfile being used in docker-compose.
57+
58+
### Dockerfile-zpm
59+
60+
Dockerfile-zpm builds for you a container which contains ZPM package manager client so you are able to install packages from ZPM in this container.
61+
As an example of usage in installs webterminal
62+
63+
### Dockerfile-web
64+
65+
Dockerfile-web starts IRIS does the same what Dockerfile does and also sets up the web app programmatically
66+
67+
68+
### .vscode/settings.json
69+
70+
Settings file to let you immedietly code in VSCode with [VSCode ObjectScript plugin](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript))
71+
72+
### .vscode/launch.json
73+
Config file if you want to debug with VSCode ObjectScript
74+
75+
[Read about all the files in this artilce](https://community.intersystems.com/post/dockerfile-and-friends-or-how-run-and-collaborate-objectscript-projects-intersystems-iris)

dev.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# useful commands
2+
## build container with no cache
3+
```
4+
docker-compose build --no-cache
5+
```
6+
## open terminal to docker
7+
```
8+
docker-compose exec iris iris session iris -U IRISAPP
9+
```
10+
11+
12+

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.6'
2+
services:
3+
iris:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
restart: always
8+
ports:
9+
- 51773
10+
- 52773
11+
- 53773
12+
volumes:
13+
- ~/iris.key:/usr/irissys/mgr/iris.key
14+
- ./:/irisdev/app

iris.script

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; run installer to create namespace
2+
do $SYSTEM.OBJ.Load("/opt/irisapp/Installer.cls", "ck")
3+
set sc = ##class(App.Installer).setup()
4+
5+
zn "%SYS"
6+
Do ##class(Security.Users).UnExpireUserPasswords("*")
7+
8+
; call your initial methods here
9+
halt

module.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Export generator="Cache" version="25">
3+
<Document name="objectscript-sample.ZPM">
4+
<Module>
5+
<Name>objectscript-sample</Name>
6+
<Version>0.0.1</Version>
7+
<Packaging>module</Packaging>
8+
<SourcesRoot>src</SourcesRoot>
9+
<Resource Name="PackageSample.PKG"/>
10+
</Module>
11+
</Document>
12+
</Export>

src/PackageSample/ObjectScript.cls

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Class PackageSample.ObjectScript
2+
{
3+
4+
ClassMethod Test() As %Status
5+
{
6+
set a=42
7+
return "It works!"
8+
}
9+
10+
}

src/PackageSample/PersistentClass.cls

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Class PackageSample.PersistentClass Extends %Persistent
2+
{
3+
4+
Property Test As %VarString;
5+
6+
ClassMethod CreateRecord() As %Status
7+
{
8+
s objPC=..%New()
9+
s objPC.Test="Test string"
10+
return objPC.%Save()
11+
}
12+
13+
Storage Default
14+
{
15+
<Data name="PersistentClassDefaultData">
16+
<Value name="1">
17+
<Value>%%CLASSNAME</Value>
18+
</Value>
19+
<Value name="2">
20+
<Value>Test</Value>
21+
</Value>
22+
</Data>
23+
<DataLocation>^PackageSample.PersistentClassD</DataLocation>
24+
<DefaultData>PersistentClassDefaultData</DefaultData>
25+
<IdLocation>^PackageSample.PersistentClassD</IdLocation>
26+
<IndexLocation>^PackageSample.PersistentClassI</IndexLocation>
27+
<StreamLocation>^PackageSample.PersistentClassS</StreamLocation>
28+
<Type>%Storage.Persistent</Type>
29+
}
30+
31+
}

0 commit comments

Comments
 (0)