From e495f99093dae4adea9a39ebcb06ec313a73702f Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Tue, 3 Jun 2025 21:59:45 +0900 Subject: [PATCH 1/5] build: introduce multi stage builds --- Dockerfile | 103 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index b164bb0..178cab8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,78 @@ -FROM almalinux:9 +# Builder stage +FROM almalinux:9 AS builder SHELL ["/bin/bash", "-c"] -# classpath settings -ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/opensourcecobol4j/ocesql4j.jar -RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar' >> ~/.bashrc +# Install build dependencies +RUN dnf update -y && \ + dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel curl gzip tar && \ + dnf clean all -# install dependencies -RUN dnf update -y -RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel +# Install sbt +RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ + chmod +x cs && \ + echo Y | ./cs setup -# install sbt -RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && echo Y | ./cs setup +# Set PATH for sbt +ENV PATH="$PATH:/root/.local/share/coursier/bin" -# install opensourcecobol4j -RUN cd /root &&\ - curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz &&\ - tar zxvf opensourcecobol4j-v1.1.7.tar.gz &&\ - cd opensourcecobol4j-1.1.7 &&\ - ./configure --prefix=/usr/ &&\ - make &&\ - make install &&\ - rm /root/opensourcecobol4j-v1.1.7.tar.gz +# Build opensourcecobol4j +RUN cd /tmp && \ + curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz && \ + tar zxf opensourcecobol4j-v1.1.7.tar.gz && \ + cd opensourcecobol4j-1.1.7 && \ + ./configure --prefix=/usr/ && \ + make && \ + make install -# Install Open COBOL ESQL 4J -ENV PATH="$PATH:/root/.local/share/coursier/bin" -RUN mkdir -p /usr/lib/Open-COBOL-ESQL-4j &&\ - cd /root/ &&\ - curl -L -o Open-COBOL-ESQL-4j-1.1.1.tar.gz https://github.com/opensourcecobol/Open-COBOL-ESQL-4j/archive/refs/tags/v1.1.1.tar.gz &&\ - tar zxvf Open-COBOL-ESQL-4j-1.1.1.tar.gz &&\ - rm Open-COBOL-ESQL-4j-1.1.1.tar.gz &&\ - cd Open-COBOL-ESQL-4j-1.1.1 &&\ - mkdir -p /usr/lib/Open-COBOL-ESQL-4j/ &&\ - curl -L -o /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar &&\ - cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib &&\ - cp /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib &&\ - ./configure --prefix=/usr/ &&\ - make &&\ - make install &&\ - rm -rf /root/Open-COBOL-ESQL-4j-1.1.1 - -# add sample programs +# Build Open COBOL ESQL 4J +RUN mkdir -p /usr/lib/Open-COBOL-ESQL-4j && \ + cd /tmp && \ + curl -L -o Open-COBOL-ESQL-4j-1.1.1.tar.gz https://github.com/opensourcecobol/Open-COBOL-ESQL-4j/archive/refs/tags/v1.1.1.tar.gz && \ + tar zxf Open-COBOL-ESQL-4j-1.1.1.tar.gz && \ + cd Open-COBOL-ESQL-4j-1.1.1 && \ + curl -L -o /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar && \ + cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib && \ + cp /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib && \ + ./configure --prefix=/usr/ && \ + make && \ + make install + +# Runtime stage +FROM almalinux:9 + +SHELL ["/bin/bash", "-c"] + +# Install only runtime dependencies +RUN dnf update -y && \ + dnf install -y java-11-openjdk-headless && \ + dnf clean all + +# Copy installed files from builder +# Copy opensourcecobol4j executables +COPY --from=builder /usr/bin/cobj /usr/bin/ +COPY --from=builder /usr/bin/cobjrun /usr/bin/ +COPY --from=builder /usr/bin/cob-config /usr/bin/ +COPY --from=builder /usr/bin/cobj-idx /usr/bin/ +COPY --from=builder /usr/bin/cobj-api /usr/bin/ +# Copy Open COBOL ESQL 4J executable +COPY --from=builder /usr/bin/ocesql4j /usr/bin/ +# Copy JAR libraries +COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ +COPY --from=builder /usr/lib/Open-COBOL-ESQL-4j/ /usr/lib/Open-COBOL-ESQL-4j/ +# Copy configuration and copy files +COPY --from=builder /usr/share/opensource-cobol-4j-1.1.8-hotfix1/ /usr/share/opensource-cobol-4j-1.1.8-hotfix1/ +# Copy header file +COPY --from=builder /usr/include/libcobj.h /usr/include/ + +# Set classpath +ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar +RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar' >> ~/.bashrc + +# Add sample programs ADD cobol_sample /root/cobol_sample ADD ocesql4j_sample /root/ocesql4j_sample WORKDIR /root/ -CMD ["/bin/bash"] +CMD ["/bin/bash"] \ No newline at end of file From 0d396647efce3ea94d2d359b3e20f85aa945000d Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Wed, 4 Jun 2025 21:12:31 +0900 Subject: [PATCH 2/5] change: introduce multi stage builds into utf8.Dockerfile --- Dockerfile | 8 +++--- README.md | 3 ++- utf8.Dockerfile | 72 +++++++++++++++++++++++++++++++++++-------------- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 178cab8..0ea1a99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,9 @@ ENV PATH="$PATH:/root/.local/share/coursier/bin" # Build opensourcecobol4j RUN cd /tmp && \ - curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz && \ - tar zxf opensourcecobol4j-v1.1.7.tar.gz && \ - cd opensourcecobol4j-1.1.7 && \ + curl -L -o opensourcecobol4j-v1.1.9.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.9.tar.gz && \ + tar zxf opensourcecobol4j-v1.1.9.tar.gz && \ + cd opensourcecobol4j-1.1.9 && \ ./configure --prefix=/usr/ && \ make && \ make install @@ -61,7 +61,7 @@ COPY --from=builder /usr/bin/ocesql4j /usr/bin/ COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ COPY --from=builder /usr/lib/Open-COBOL-ESQL-4j/ /usr/lib/Open-COBOL-ESQL-4j/ # Copy configuration and copy files -COPY --from=builder /usr/share/opensource-cobol-4j-1.1.8-hotfix1/ /usr/share/opensource-cobol-4j-1.1.8-hotfix1/ +COPY --from=builder /usr/share/opensource-cobol-4j-1.1.9/ /usr/share/opensource-cobol-4j-1.1.9/ # Copy header file COPY --from=builder /usr/include/libcobj.h /usr/include/ diff --git a/README.md b/README.md index ce5fbdf..2f99de0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # opensource COBOL 4J development environment (Docker) ## Docker image + Versions : - OS: Ubuntu -- opensource COBOL 4J: v1.1.7 +- opensource COBOL 4J: v1.1.9 - Open COBOL ESQL 4J: v1.1.1 In order to "Hello World" program, run the following commands in the docker container diff --git a/utf8.Dockerfile b/utf8.Dockerfile index ea3a280..176cd59 100644 --- a/utf8.Dockerfile +++ b/utf8.Dockerfile @@ -1,32 +1,64 @@ +# Builder stage +FROM almalinux:9 AS builder + +SHELL ["/bin/bash", "-c"] + +# Install build dependencies +RUN dnf update -y && \ + dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel curl gzip tar && \ + dnf clean all + +# Install sbt +RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ + chmod +x cs && \ + echo Y | ./cs setup + +# Set PATH for sbt +ENV PATH="$PATH:/root/.local/share/coursier/bin" + +# Build opensourcecobol4j with UTF-8 support +RUN cd /tmp && \ + curl -L -o opensourcecobol4j-v1.1.9.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.9.tar.gz && \ + tar zxf opensourcecobol4j-v1.1.9.tar.gz && \ + cd opensourcecobol4j-1.1.9 && \ + ./configure --prefix=/usr/ --enable-utf8 && \ + touch cobj/*.m4 && \ + make && \ + make install + +# Runtime stage FROM almalinux:9 SHELL ["/bin/bash", "-c"] -# classpath settings +# Install only runtime dependencies +RUN dnf update -y && \ + dnf install -y java-11-openjdk-headless && \ + dnf clean all + +# Copy installed files from builder +# Copy opensourcecobol4j executables +COPY --from=builder /usr/bin/cobj /usr/bin/ +COPY --from=builder /usr/bin/cobjrun /usr/bin/ +COPY --from=builder /usr/bin/cob-config /usr/bin/ +COPY --from=builder /usr/bin/cobj-idx /usr/bin/ +COPY --from=builder /usr/bin/cobj-api /usr/bin/ +# Copy JAR libraries +COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ +# Copy configuration and copy files +COPY --from=builder /usr/share/opensource-cobol-4j-1.1.9/ /usr/share/opensource-cobol-4j-1.1.9/ +# Copy header file +COPY --from=builder /usr/include/libcobj.h /usr/include/ + +# Set classpath ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar' >> ~/.bashrc -# install dependencies -RUN dnf update -y -RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel - -# install sbt -RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && echo Y | ./cs setup - -# install opensourcecobol4j -RUN cd /root &&\ - curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz &&\ - tar zxvf opensourcecobol4j-v1.1.7.tar.gz &&\ - cd opensourcecobol4j-1.1.7 &&\ - ./configure --prefix=/usr/ --enable-utf8 &&\ - touch cobj/*.m4 &&\ - make &&\ - make install &&\ - rm /root/opensourcecobol4j-v1.1.7.tar.gz - -# add sample programs +# Add sample programs ADD cobol_sample /root/cobol_sample WORKDIR /root/ CMD ["/bin/bash"] + +CMD ["/bin/bash"] From a945b002d4104a7dfb72357a680ad6163a50e29c Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Wed, 4 Jun 2025 21:19:57 +0900 Subject: [PATCH 3/5] fix: Dockerfile and utf8.Dockerfile --- Dockerfile | 2 +- utf8.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ea1a99..850b3da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ SHELL ["/bin/bash", "-c"] # Install build dependencies RUN dnf update -y && \ - dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel curl gzip tar && \ + dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel gzip tar && \ dnf clean all # Install sbt diff --git a/utf8.Dockerfile b/utf8.Dockerfile index 176cd59..b29813c 100644 --- a/utf8.Dockerfile +++ b/utf8.Dockerfile @@ -5,7 +5,7 @@ SHELL ["/bin/bash", "-c"] # Install build dependencies RUN dnf update -y && \ - dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel curl gzip tar && \ + dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel gzip tar && \ dnf clean all # Install sbt From 3cc9bc5c55e3eb37b974c8f7a125d8582fc38566 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Wed, 4 Jun 2025 21:23:40 +0900 Subject: [PATCH 4/5] fix: a COPY command in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 850b3da..d04e792 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,7 @@ COPY --from=builder /usr/bin/cob-config /usr/bin/ COPY --from=builder /usr/bin/cobj-idx /usr/bin/ COPY --from=builder /usr/bin/cobj-api /usr/bin/ # Copy Open COBOL ESQL 4J executable -COPY --from=builder /usr/bin/ocesql4j /usr/bin/ +COPY --from=builder /usr/bin/ocesql /usr/bin/ # Copy JAR libraries COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ COPY --from=builder /usr/lib/Open-COBOL-ESQL-4j/ /usr/lib/Open-COBOL-ESQL-4j/ From b2220e59ef55de8ab9da1e7b8d9de9c70673857e Mon Sep 17 00:00:00 2001 From: yutaro-sakamoto <80912876+yutaro-sakamoto@users.noreply.github.com> Date: Thu, 5 Jun 2025 09:00:24 +0900 Subject: [PATCH 5/5] Update utf8.Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- utf8.Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/utf8.Dockerfile b/utf8.Dockerfile index b29813c..e1762e0 100644 --- a/utf8.Dockerfile +++ b/utf8.Dockerfile @@ -61,4 +61,3 @@ WORKDIR /root/ CMD ["/bin/bash"] -CMD ["/bin/bash"]