Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iscChris authored Dec 1, 2024
0 parents commit 3409ca9
Show file tree
Hide file tree
Showing 16 changed files with 428 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.DS_Store
.git
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.sh text eol=lf
*.cls text eol=lf
*.mac text eol=lf
*.int text eol=lf
Dockerfil* text eol=lf
12 changes: 12 additions & 0 deletions .github/workflows/objectscript-quality.yml
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store


18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "objectscript",
"request": "launch",
"name": "ObjectScript Debug Class",
"program": "##class(PackageSample.ObjectScript).Test()",
},
{
"type": "objectscript",
"request": "attach",
"name": "ObjectScript Attach",
"processId": "${command:PickProcess}",
"system": true
}
]
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"files.associations": {

"Dockerfile*": "dockerfile",
"iris.script": "objectscript"
},
"objectscript.conn" :{
"ns": "USER",
"username": "_SYSTEM",
"password": "SYS",
"docker-compose": {
"service": "iris",
"internalPort": 52773
},
"active": true
},
"sqltools.connections": [
{
"namespace": "USER",
"connectionMethod": "Server and Port",
"showSystem": false,
"previewLimit": 50,
"server": "localhost",
"port": 32770,
"askForPassword": false,
"driver": "InterSystems IRIS",
"name": "objectscript-docker",
"username": "_SYSTEM",
"password": "SYS"
}
]

}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG IMAGE=intersystemsdc/irishealth-community:2020.3.0.200.0-zpm
ARG IMAGE=intersystemsdc/iris-community:2020.3.0.221.0-zpm
ARG IMAGE=intersystemsdc/iris-community:2020.4.0.524.0-zpm
ARG IMAGE=intersystemsdc/iris-community
FROM $IMAGE


WORKDIR /opt/irisapp
ARG TESTS=0
ARG MODULE="dc-sample-template"
ARG NAMESPACE="IRISAPP"

#COPY Installer.cls .
RUN --mount=type=bind,src=.,dst=. \
iris start IRIS && \
iris session IRIS < iris.script && \
([ $TESTS -eq 0 ] || iris session iris -U $NAMESPACE "##class(%ZPM.PackageManager).Shell(\"test $MODULE -v -only\",1,1)") && \
iris stop IRIS quietly
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 InterSystems Developer Community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## aoc2020-template
This is a template for [Advent of Code](https://adventofcode.com/) ObjectScript contest.
## 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 git@github.com:intersystems-community/aoc-objectscript-template.git
```

Open the terminal in this directory and run:

```
$ docker-compose build
```

3. Run the IRIS container with your project:

```
$ docker-compose up -d
```

## How to Test it

Open IRIS terminal:

```
$ docker-compose exec iris iris session iris
USER>w ##class(dc.aoc2022.Day1).Run()
```
## How to start coding
This repository is ready to code in VSCode with ObjectScript plugin.
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.
Open /src/cls/PackageSample/ObjectScript.cls class and try to make changes - it will be compiled in running IRIS docker container.

Feel free to delete PackageSample folder and place your ObjectScript classes in a form
/src/Package/Classname.cls
[Read more about folder setup for InterSystems ObjectScript](https://community.intersystems.com/post/simplified-objectscript-source-folder-structure-package-manager)

The script in Installer.cls will import everything you place under /src into IRIS.


## What's inside the repository

### Dockerfile

The simplest dockerfile which starts IRIS and imports code from /src folder into it.
Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders.

### iris.script

Setup Objectscript code which is being executed during docker build phase

### .vscode/settings.json

Settings file to let you immedietly code in VSCode with [VSCode ObjectScript plugin](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript))

### .vscode/launch.json
Config file if you want to debug with VSCode ObjectScript

[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)
100 changes: 100 additions & 0 deletions data/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
55131
114008
145297
76135
50317
134036
122136
97704
51245
141732
120427
142020
88166
55313
110391
112436
78195
74294
128984
68240
137098
142016
83577
89257
107744
67357
131342
98247
137501
134577
65696
84925
50159
110319
91921
103303
84505
84683
100811
82626
66774
123216
95151
88237
60705
124319
102926
143160
92780
64283
132434
113935
84907
113698
117240
129327
78837
144841
138054
130990
100191
141768
138941
108165
62138
121690
117305
90147
134422
78031
121331
120947
120235
138880
141076
119480
66844
77660
106364
99187
144244
120483
77715
135703
125521
123253
127556
96458
91965
73924
95176
87540
122083
146013
67761
100413
145994
149450
94330
112824
63 changes: 63 additions & 0 deletions dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# useful commands
## clean up docker
```
docker system prune -f
```

## build container with no cache
```
docker-compose build --no-cache
```
## start iris container
```
docker-compose up -d
```

## open iris terminal in docker
```
docker-compose exec iris iris session iris -U IRISAPP
```

## load code from source folder to docker
it loads and compiles all the objectscript from /src folder
```
do $System.OBJ.LoadDir("/opt/irisapp/src","ck",,1)
```


## 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
```

## 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/
```

## 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!",!
```

zw ##class(community.csvgen).GenerateFromURL("https://github.com/h2oai/h2o-tutorials/raw/master/h2o-world-2017/automl/data/product_backorders.csv")

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.6'
services:
iris:
build:
context: .
dockerfile: Dockerfile
restart: always
command: --check-caps false
ports:
- 1972
- 52773
- 53773
volumes:
- ./:/irisdev/app
6 changes: 6 additions & 0 deletions iris.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
zn "%SYS"
Do ##class(Security.Users).UnExpireUserPasswords("*")

zn "USER"
zpm "load /opt/irisapp/ -v":1:1
halt
12 changes: 12 additions & 0 deletions module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Document name="aoc-template.ZPM">
<Module>
<Name>aoc-template</Name>
<Version>1.0.0</Version>
<Packaging>module</Packaging>
<SourcesRoot>src</SourcesRoot>
<Resource Name="dc.aoc2022.PKG"/>
</Module>
</Document>
</Export>
Loading

0 comments on commit 3409ca9

Please sign in to comment.