新しい投稿

検索

ディスカッション (11)5
続けるにはログインするか新規登録を行ってください
記事
· 2025年12月28日 5m read

减小IRIS社区版Docker镜像的占用空间

InterSystems Ideas 门户网站上得票最多的想法-——获得 74 票——要求提供一个轻量级版本的 IRIS。虽然该平台已发展成为一个强大的数据引擎,但许多项目只需要其 SQL 数据库功能。本文演示了如何构建一个非官方的、紧凑的 IRIS 社区版镜像,该镜像只关注核心数据库功能,将镜像大小缩小了 80% 以上。

⚠️ 免责声明

本项目生成的是 InterSystems IRIS Community Edition 的非官方实验镜像

  • 不受InterSystems支持或认可
  • 使用风险自负。这些修改删除了核心平台功能,可能会破坏与工具、API 和预期行为的兼容性。
  • 提供任何担保或保证,包括对生产使用的适用性。
  • 仅供高级用户用于教育和实验目的

为什么选择轻量级 IRIS?

虽然 IRIS 目前包含丰富的互操作性、分析、机器学习、系统管理等功能,但许多项目只需要其核心 SQL 功能。官方社区版 Docker 镜像约为

  • 磁盘使用量3.5-3.8 GB
  • 压缩后大小:~1.1 GB

IRIS Light 可将其减少到

  • 磁盘使用量~575-583 MB
  • 压缩后大小:~144-148 MB

因此适用于

  • 微服务或容器化 SQL 使用
  • 具有更快启动和拉动速度的 CI 管道
  • 无需完整功能的横向扩展

镜像占用空间对比

IRIS 社区版官方镜像通常占用 3.5-3.8 GB 磁盘空间,压缩后大小约为 1.1 GB:

$ docker images containers.intersystems.com/intersystems/iris-community
IMAGE                                                                    ID             DISK USAGE   CONTENT SIZE
containers.intersystems.com/intersystems/iris-community:latest-cd        14c6314edcc5        3.8GB         1.17GB
containers.intersystems.com/intersystems/iris-community:latest-em        4c25627895eb       3.52GB         1.01GB
containers.intersystems.com/intersystems/iris-community:latest-preview   424e87dbb7d8       3.81GB         1.17GB

相比之下,通过这种方法创建的精简版 "IRIS Light "图像的压缩大小大约小 8 倍:

$ docker images caretdev/iris-community-light
IMAGE                                                                    ID             DISK USAGE   CONTENT SIZE
caretdev/iris-community-light:latest-cd                                  ce5c2d7fa173        583MB          148MB
caretdev/iris-community-light:latest-em                                  fd33a51a0e81        575MB          144MB
caretdev/iris-community-light:latest-preview                             f10c714117da        583MB          148MB

使用 Dive 分析镜像层

为了了解和优化 IRIS 社区版镜像,我们使用了dive,这是一款用于检查 Docker 镜像层和识别低效的工具。

优化前:Vanilla IRIS 社区版镜像

下面的截图显示了对 iris-community:latest-em 官方镜像的分析。其中最大的一层重达882 MB,包含 Java、系统库和其他非纯 SQL 工作负载严格要求的运行时组件。

最大的图层为 1.5GB,主要包含 IRIS 本身

优化后:IRIS Light镜像

通过移除不需要的软件包和压缩 IRIS 内部存储空间,最终图像可容纳在一个 320 MB 的图层中,实现了尺寸的大幅缩减。

如何构建 IRIS Light 镜像

该过程遵循多阶段 Dockerfile,从标准的 iris-community:latest-em 基础开始。关键步骤包括

1.禁用配置中的组件

  • iris.cpf 中关闭 WebServer、System Management Portal 和 Ensemble。

2.从 IRIS 内部删除未使用的软件包

在 IRIS 会话中使用 ObjectScript:

  • 删除软件包:%SYS.ML, DeepSee, Interop, OAuth2, Net, Report 等等。
  • 只保留必要的系统库(如 %Library%SQL%SYSTEM)。

3.存根类

如果需要,一些必备类(如启动类)会被最小化的无操作实现所取代。

4.清理数据库

压缩关键数据库并进行碎片整理,以减小其大小

5.文件系统清理

删除

  • 开发工具
  • 网络堆栈和 CSP
  • 互操作性库
  • Python/Java 支持
  • 本地数据、日志、临时文件、ODBC/JDBC 驱动程序

6.将清理过的内容复制到全新的 Ubuntu 基础上

最终镜像建立在 ubuntu:24.04 的基础上,只包含必要的文件和工具,并使用 tini 作为 PID 1。

结果

最终镜像的大小约为:

  • 压缩后大小: 约144-148 MB
  • 未压缩磁盘使用量~570-580 MB
  • SQL 功能:使用 sqlalchemy-iris 测试套件验证(619 次通过,912 次跳过,0 次失败)

这使得它非常适合于

  • 最低限度的 SQL 服务
  • 轻量级开发/测试容器
  • 嵌入式或边缘部署场景
  • 无状态水平扩展架构

重要限制

  • 无管理门户(Management Portal)或网络服务(Web Services
    移除整个 CSP/web 堆栈。
  • 无互操作性、DeepSee、iKnow 或机器学习
    明确删除这些子系统。
  • 无内部或外部支持
    InterSystems 不对该镜像提供任何保证。兼容性和升级行为未定义。
  • 未来的 IRIS 版本可能会更改启动要求
    已删除软件包或文件的内部依赖性可能会导致未来版本无法使用此方法。

结论

IRIS Light 是 InterSystems IRIS 的精简版社区驱动 Docker 镜像,可显著减少以数据库为中心的用例的大小和复杂性。虽然没有官方支持,但它为实验、快速原型开发以及不需要完整 IRIS 功能的情况提供了基础。

我们鼓励用户查看 Dockerfile,根据自己的需求对其进行调整,并了解移除核心平台功能的影响。

我们鼓励用户进一步调整 Dockerfile,以适应自己的操作和安全限制。完整的构建过程是透明的,只使用公开的 Docker 基本镜像即可重现。


该项目可在此处获取

可在Docker Hub 上获取 IRIS Community Light Docker镜像。

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年12月28日

Are class queries only for SELECT?

Hi developers!

There is a neat feature of ObjectScript classes - Query element, which allows you to write in a clear SQL (without any & or ()), pass parameters to it and call it from ObjectScript as do QueryNameFunc() or via Call SQLProcedureName via SQL, .e.g.

Query MyQuery(p as %String) as %SQLQuery [SQLProc]

{ 

SELECT * FROM MyTable 

WHERE Name=:p

}

All works fine, but when I tried to use the same for a DELETE statement see the following error:

SELECT expected, DELETE found ^ DECLARE Q1 CURSOR FOR DELETE

Is the Query element for SELECT only? What am I doing wrong? )

4 Comments
ディスカッション (4)2
続けるにはログインするか新規登録を行ってください
記事
· 2025年12月28日 1m read

#DIM vs SET - Objectscript

SET assigns value to the variable at RUNTIME.

#DIM declare the variable and it's Data Type at COMPILE TIME.


SET #DIM
Makes the variables Dynamic. Improves Readability.
No Data Type Declaration. Enables IDE auto-completion.
Runtime Useful for Object references.

#DIM name As %String
Set name = "Micheal Scott"
#DIM age As %Numeric
Set age = 36
#DIM employer As App.Employer               ; compile time
Set employer = ##class(App.Employer).%New() ; runtime 

 

SET or #DIM? Your design, your rules.

18 Comments
ディスカッション (18)4
続けるにはログインするか新規登録を行ってください
記事
· 2025年12月28日 3m read

embeddedpy-bridge: A Toolkit for Embedded Python

Embeddedpy-bridge: A Toolkit for Embedded Python

Overview

Embedded Python is a game-changer for InterSystems IRIS, offering access to the vast Python ecosystem directly within the database. However, bridging the gap between ObjectScript and Python can sometimes feel like translating between two different worlds.

To make this transition seamless using embeddedpy-bridge.

This package is a developer-centric utility kit designed to provide high-level ObjectScript wrappers, familiar syntax, and robust error handling for Embedded Python. It allows developers to interact with Python data structures using the native IRIS patterns they are already comfortable with.

The Challenge

While the %SYS.Python library is powerful, developers often face a few hurdles:

  1. Handling Proxies: Navigating Python lists and dictionaries using raw proxies doesn't feel "native" to ObjectScript.
  2. Iteration: Standard ObjectScript While loops don't natively "talk" to Python iterators.
  3. Namespace Management: Ensuring Python utilities are available system-wide.

The Solution: embeddedpy-bridge

My goal was to create a "Bridge" that makes Python feel like a first-class citizen in ObjectScript.

Key Features:

  • The py Prefix Convention: All methods in the %ZPython.Utils class use a py prefix (e.g., pyDict(), pyList(), pyJSON()) to clearly distinguish Python-related logic from native IRIS code.
  • OO Wrappers: High-level classes for List and Dict that support familiar methods like GetAt(), SetAt(), and Count().
  • Smart Iterators: Integrated ListIterator and DictIterator allow you to traverse Python data using standard ObjectScript While loops.
  • Macro Support: A %ZPython.inc file provides shortcuts like $$$pyDict and $$$pyJSON for cleaner, faster development.

Usage Examples

1. Simple Syntax (Macros)

No more typing ##class(...) every time. Use short shortcuts:

  • $$$pyDict — Create a Python Dictionary.
  • $$$pyList — Create a Python List.
  • $$$pyJSON(dynObj) — Turn a JSON object into Python instantly.

2. Unified Dictionary Handling

Instead of managing raw Python proxies, use the wrapped dictionary:

Code snippet:

Include %ZPython
Set pyDict = $$$pyDict
Do pyDict.SetAt("Status", "Active")
Do pyDict.SetAt("Version", 1.0)

// Standard IRIS iteration
Set iter = pyDict.%GetIterator()
While iter.%GetNext(.key, .val) {
    Write "Key: ", key, " Val: ", val, !
}

 

Set pyList = $$$zpyList()

Do pyList.Append("First Item")
Do pyList.Append("Second Item")

Write "Total items: ", pyList.Count(), !

// Access by index
Write "Item 1: ", pyList.GetAt(0), !

2. Seamless Data Conversion

Convert IRIS Dynamic Objects to Python objects and back with one line:

Code snippet

Set dynObj = {"name": "John", "roles": ["Admin", "User"]}
Set pyObj = $$$pyJSON(dynObj)

// Verify Python type
Write ##class(%ZPython.Utils).IsType(pyObj, "dict") // 1

The goal of this project is to bridge the gap between two powerful worlds. While InterSystems IRIS provides the engine for Embedded Python, embeddedpy-bridge provides the steering wheel. 

1 Comment
ディスカッション (1)2
続けるにはログインするか新規登録を行ってください