diff --git a/Dockerfile b/Dockerfile index b164bb0..6452c72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,63 @@ +# Build 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 && \ + 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 + +# build 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 DESTDIR=/tmp/install && \ + rm -rf /root/opensourcecobol4j-v1.1.7.tar.gz /root/opensourcecobol4j-1.1.7 + +# Download postgresql jar +RUN mkdir -p /tmp/install/usr/lib/Open-COBOL-ESQL-4j/ && \ + curl -L -o /tmp/install/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar + +# Build Open COBOL ESQL 4J +ENV PATH="$PATH:/root/.local/share/coursier/bin" +RUN 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 && \ + cd Open-COBOL-ESQL-4j-1.1.1 && \ + cp /tmp/install/usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib && \ + cp /tmp/install/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib && \ + ./configure --prefix=/usr/ && \ + make && \ + make install DESTDIR=/tmp/install && \ + rm -rf /root/Open-COBOL-ESQL-4j-1.1.1.tar.gz /root/Open-COBOL-ESQL-4j-1.1.1 + +# Runtime stage FROM almalinux:9 SHELL ["/bin/bash", "-c"] +# install runtime dependencies only +RUN dnf update -y && \ + dnf install -y java-11-openjdk-headless && \ + dnf clean all && \ + rm -rf /var/cache/dnf/* + +# copy built files from builder stage +COPY --from=builder /tmp/install/usr/ /usr/ + # 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 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/ &&\ - make &&\ - make install &&\ - rm /root/opensourcecobol4j-v1.1.7.tar.gz - -# 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 ADD cobol_sample /root/cobol_sample ADD ocesql4j_sample /root/ocesql4j_sample diff --git a/utf8.Dockerfile b/utf8.Dockerfile index ea3a280..8363e78 100644 --- a/utf8.Dockerfile +++ b/utf8.Dockerfile @@ -1,29 +1,47 @@ +# Build 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 && \ + 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 + +# build 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 DESTDIR=/tmp/install && \ + rm -rf /root/opensourcecobol4j-v1.1.7.tar.gz /root/opensourcecobol4j-1.1.7 + +# Runtime stage FROM almalinux:9 SHELL ["/bin/bash", "-c"] +# install runtime dependencies only +RUN dnf update -y && \ + dnf install -y java-11-openjdk-headless && \ + dnf clean all && \ + rm -rf /var/cache/dnf/* + +# copy built files from builder stage +COPY --from=builder /tmp/install/usr/ /usr/ + # classpath settings 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 cobol_sample /root/cobol_sample