2024年12月21日土曜日

Oracle Spatial Studioのコンテナ・イメージを作成する

Oracle Spatial Studioのコンテナ・イメージを作成してみました。

TL;DR


APEX向けの構成スクリプトのリポジトリに、Oracle Spatial Studioのコンテナを作るためのファイルを追加しました。
git clone https://github.com/ujnak/apex-podman-setup
cd apex-podman-setup/spatial
製品rpmは以下のページよりダウンロードします。V*-01.zipという名前のファイルで、ZIPを展開するとOracle_Spatial_Studioというディレクトリが作成されます。このファイルをディレクトリspatial/files以下に配置します。

https://www.oracle.com/database/technologies/spatial-studio/oracle-spatial-studio-downloads.html

JDK17のアーカイブを以下のページよりダウンロードします。DockerfileのJAVA_SHA256にファイルのチェックサムが記載されているため、JDK17.0.16でないとチェックサム・エラーが発生します。こちらはアーキテクチャに合わせてjdk-17.0.16_linux-x64_bin.tar.gzjdk-17.0.16_linux-aarch64_bin.tar.gzのどちらかをディレクトリspatial/files以下に配置します。

https://www.oracle.com/java/technologies/downloads/#java17

以上で準備は完了です。コンテナ・イメージをビルドしてコンテナの作成と実行を行います。
podman build --file Dockerfile --tag oracle/spatialstudio:latest .
podman run -d --name spatialstudio -p 8090:8080 -p 4040:4040 localhost/oracle/spatialstudio:latest

構築手順の紹介



Oracle社が提供しているOracle Linux 8とJava 17のDockerfileを元にしています。


Oracle Spatial Studioを動かすための修正を少々加えています。

イメージの作成には、macOSのpodmanを使いました。

# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle JDK 17 on Oracle Linux 8
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) jdk-17.XX_linux-x64_bin.tar.gz or jdk-17.XX_linux-aarch64_bin.tar.gz
# Download from https://www.oracle.com/java/technologies/downloads
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/jdk:17 .
#
# This command is already scripted in build.sh so you can alternatively run
# $ bash build.sh
#
# The builder image will be used to uncompress the tar.gz file with the Java Runtime.
#
#####################################################################################################
#
# NOTE for Oracle Spatial Studio:
#
# 1. Oracle Spatial Studio archive
# https://www.oracle.com/database/technologies/spatial-studio/oracle-spatial-studio-downloads.html
#
# Place the downloaded V*-01.zip file under **files** directory.
# Make sure that there is only one file matching the pattern V*-01.zip.
#
# When V*-01.zip is extracted, it is expected to create a directory named Oracle_Spatial_Studio.
#
# 2. Oracle Java
# https://www.oracle.com/java/technologies/downloads/#java17
#
# Place the jdk-17.*_linux-<arch>_bin.tar.gz file that matches your architecture under **files** directory.
# The file’s checksum varies depending on the JDK version.
# Currently, the checksum for version 17.0.16 is set in JAVA_SHA256.
# If you change the version from 17.0.16, you need to update JAVA_SHA256 accordingly.
#
# Oracle Spatial Studio did not work with JDK21.
#
# https://www.oracle.com/a/tech/docs/17-0-16-checksum.html
#
# HISTORY:
# 2025/08/01 ynakakos initial version.
#
#####################################################################################################
FROM oraclelinux:8 as builder
# LABEL maintainer="Aurelio Garcia-Ribeyro <aurelio.garciaribeyro@oracle.com>"
# Since the files are compressed as tar.gz first dnf install tar. gzip is already in oraclelinux:8
# FOR Spatial Studio - add unzip
RUN dnf install -y tar unzip
# FOR Spatial Studio - import Oracle Spatial Studio
COPY ./files/V*-01.zip /tmp/
# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8
# Environment variables for the builder image.
# Required to validate that you are using the correct file
ENV JAVA_HOME=/usr/java/jdk-17
##
COPY ./files/*.tar.gz /tmp/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN set -eux; \
ARCH="$(uname -m)" && \
if [ "$ARCH" = "x86_64" ]; \
then \
mv "$(ls /tmp/jdk-17*_linux-x64_bin.tar.gz)" /tmp/jdk.tar.gz ; \
JAVA_SHA256=f07da5571c693675a41603adbd6752e01f3defa272751b4fee582a7f29cacc75 ; \
else \
mv "$(ls /tmp/jdk-17*_linux-aarch64_bin.tar.gz)" /tmp/jdk.tar.gz ; \
JAVA_SHA256=49c92d1b5a2607fbda0e5bbc3fa16c31ec8f50d264a7040c4a99e36233bb4b30 ; \
fi && \
echo "$JAVA_SHA256 */tmp/jdk.tar.gz" | sha256sum -c -; \
mkdir -p "$JAVA_HOME"; \
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1 ; \
unzip -d /opt/oracle /tmp/V*-01.zip
# FOR Spatial Studio - add unzip to the last line of RUN
## Get a fresh version of Oracle Linux 8 for the final image
FROM oraclelinux:8
# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8
ENV JAVA_HOME=/usr/java/jdk-17
ENV PATH $JAVA_HOME/bin:$PATH
# If you need the Java Version you can read it from the release file with
# JAVA_VERSION=$(sed -n '/^JAVA_VERSION="/{s///;s/"//;p;}' "$JAVA_HOME"/release);
# Copy the uncompressed Java Runtime from the builder image
COPY --from=builder $JAVA_HOME $JAVA_HOME
# FOR Spatial Studio - copy Spatial Studio from builder
COPY --from=builder /opt/oracle/Oracle_Spatial_Studio /opt/oracle/Oracle_Spatial_Studio
COPY ./Start_Spatial_Studio.sh /opt/oracle/Oracle_Spatial_Studio/
RUN set -eux; \
# Ensure we get the latest OL 8 updates available at build time
dnf -y update; \
# JDK assumes freetype is available
dnf install -y \
freetype fontconfig unzip which \
; \
rm -rf /var/cache/dnf; \
ln -sfT "$JAVA_HOME" /usr/java/default; \
ln -sfT "$JAVA_HOME" /usr/java/latest; \
for bin in "$JAVA_HOME/bin/"*; do \
base="$(basename "$bin")"; \
[ ! -e "/usr/bin/$base" ]; \
alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \
done;
# FOR Spatial Studio - start spatial studio
EXPOSE 8080 4040
WORKDIR /opt/oracle/Oracle_Spatial_Studio
CMD ["sh", "-c", "/opt/oracle/Oracle_Spatial_Studio/Start_Spatial_Studio.sh"]
#CMD ["jshell"]
view raw Dockerfile hosted with ❤ by GitHub
適当なディクレトリを作成し、以下の4つのファイルを配置します。JavaについてはAMD64かARMでファイルが異なります。また、Javaは17限定です。Oracle Spatial StudioのZIPファイルはディレクトリfilesを作成し、その下に配置します。Oracle Spatial Studioは新しいバージョンでも、Dockerfileは変更せずにイメージが作れるはずです。
  • 上記のDockerfile
  • Oracle Spatial Studio Quick StartのZIPファイル(filesの下) - V1050194-01.zip(バージョンが上がるとファイル名が変わります)
  • Oracle JAVAのtar.gzファイル - jdk-17.0.16_linux-aarch64_bin.tar.gz
  • Spatial Studioのコンテナ向け起動スクリプトStart_Spatial_Studio.sh
JDK17のアーカイブについてはDockerfile内にチェックサムが記載されているため、17.0.16とは異なるバージョンのアーカイブを配置した場合は、DockerfileにJAVA_SHA256として記載されているチェックサムを置き換える必要があります。

以下のコマンドを実行して、oracle/spatialstudio:latestのコンテナ・イメージを作成します。

podman build --file Dockerfile --tag oracle/spatialstudio:latest .

% podman build --file Dockerfile --tag oracle/spatialstudio:latest .

[1/2] STEP 1/8: FROM oraclelinux:8 AS builder

[1/2] STEP 2/8: RUN dnf install -y tar unzip

Oracle Linux 8 BaseOS Latest (aarch64)           10 MB/s | 137 MB     00:13    

Oracle Linux 8 Application Stream (aarch64)      10 MB/s |  64 MB     00:06    

Last metadata expiration check: 0:00:09 ago on Fri Aug  1 08:53:19 2025.

Package tar-2:1.30-9.el8.aarch64 is already installed.

Dependencies resolved.

================================================================================

 Package    Architecture Version                   Repository              Size

================================================================================

Installing:

 unzip      aarch64      6.0-48.0.1.el8_10         ol8_baseos_latest      189 k

Upgrading:

 tar        aarch64      2:1.30-10.el8_10          ol8_baseos_latest      830 k


Transaction Summary

================================================================================

Install  1 Package

Upgrade  1 Package


[中略]



++ basename /usr/java/jdk-17/bin/serialver

+ base=serialver

+ '[' '!' -e /usr/bin/serialver ']'

+ alternatives --install /usr/bin/serialver serialver /usr/java/jdk-17/bin/serialver 20000

--> 370818a642c2

[2/2] STEP 9/11: EXPOSE 8080 4040

--> aa39701c135f

[2/2] STEP 10/11: WORKDIR /opt/oracle/Oracle_Spatial_Studio

--> a26b388c8f55

[2/2] STEP 11/11: CMD ["sh", "-c", "/opt/oracle/Oracle_Spatial_Studio/Start_Spatial_Studio.sh"]

[2/2] COMMIT oracle/spatialstudio:latest

--> 1c9b6de485df

Successfully tagged localhost/oracle/spatialstudio:latest

1c9b6de485df57b9a0315754965284c0d79ed392c0463e29604cc560037c1044

% 


作成されたコンテナ・イメージからコンテナを作成して、Oracle Spatial Studioにアクセスします。私の環境ではポート番号8080が使用されているため8090にマップしています。ただし、Oracle Spatial StudioはHTTPSで動作するため、アクセス先は4040番ポートです

podman run -d --name spatialstudio -p 8090:8080 -p 4040:4040 localhost/oracle/spatialstudio:latest

% podman run -d --name spatialstudio -p 8090:8080 -p 4040:4040 localhost/oracle/spatialstudio:latest

42eddba20281a7c9701840934feb1f0d521cbd14faec636dbe4b36891d0d1925

%


ブラウザより以下のURLにアクセスします。自己署名証明書を使っているため、HTTPSの接続時に警告が表示されます。



Oracle Spatial Studioのデフォルトのユーザー設定なので、admin/welcome1で接続できます。リポジトリの接続設定から始めることができます。


今回の記事は以上になります。