diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 696a37b..d47d59e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,12 +36,22 @@ jobs: run: | docker tag opensourcecobol/opensourcecobol4j:"$version_string_prefix" opensourcecobol/opensourcecobol4j:latest + - name: Show Docker image size + run: | + docker images opensourcecobol/opensourcecobol4j:"$version_string_prefix" --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" + - name: Check the version of installed software run: | docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "cobj --version | grep 'opensource COBOL 4J $opensource_COBOL_4J_version'" docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "! cobj --version | grep 'unicode/utf-8 support'" docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "ocesql --version | grep 'Version $Open_COBOL_ESQL_4J_version'" + - name: Run simple tests inside the container + run: | + docker run -itd --name test_container opensourcecobol/opensourcecobol4j:latest + docker exec test_container sh -c "cd /root/cobol_sample && cobj HELLO.cbl && java HELLO" + docker rm -f test_container + - name: Login to Docker Hub if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true uses: docker/login-action@v3 @@ -73,11 +83,21 @@ jobs: docker build -t opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" . -f utf8.Dockerfile \ --build-arg opensource_COBOL_4J_version="$opensource_COBOL_4J_version" + - name: Show Docker image size + run: | + docker images opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" + - name: Check the version of installed software run: | docker run --rm opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" sh -c "cobj --version | grep 'opensource COBOL 4J $opensource_COBOL_4J_version'" docker run --rm opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" sh -c "cobj --version | grep 'unicode/utf-8 support'" + - name: Run simple tests inside the container + run: | + docker run -itd --name test_container opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" + docker exec test_container sh -c "cd /root/cobol_sample && cobj HELLO.cbl && java HELLO" + docker rm -f test_container + - name: Login to Docker Hub if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true uses: docker/login-action@v3 diff --git a/Dockerfile b/Dockerfile index a2e3e48..6d21e58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ # Build stage -FROM almalinux:9 AS builder +FROM almalinux:9-minimal AS builder ARG opensource_COBOL_4J_version=dummy_value Open_COBOL_ESQL_4J_version=dummy_value 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 +RUN microdnf update -y && \ + microdnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel tar gzip && \ + microdnf clean all # install sbt RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ @@ -43,17 +43,17 @@ RUN cd /root/ && \ rm -rf /root/Open-COBOL-ESQL-4j-${Open_COBOL_ESQL_4J_version}.tar.gz /root/Open-COBOL-ESQL-4j-${Open_COBOL_ESQL_4J_version} # Runtime stage -FROM almalinux:9 +FROM almalinux:9-minimal ARG opensource_COBOL_4J_version=dummy_value Open_COBOL_ESQL_4J_version=dummy_value SHELL ["/bin/bash", "-c"] # install runtime dependencies only -RUN dnf update -y && \ - dnf install -y java-11-openjdk-devel && \ - dnf clean all && \ - rm -rf /var/cache/dnf/* +RUN microdnf update -y && \ + microdnf install -y java-11-openjdk-devel && \ + microdnf clean all && \ + rm -rf /var/cache/microdnf/* # create required directories RUN mkdir -p /usr/lib/opensourcecobol4j \ diff --git a/utf8.Dockerfile b/utf8.Dockerfile index 5357d1b..2b7c750 100644 --- a/utf8.Dockerfile +++ b/utf8.Dockerfile @@ -1,14 +1,14 @@ # Build stage -FROM almalinux:9 AS builder +FROM almalinux:9-minimal AS builder ARG opensource_COBOL_4J_version=dummy_value 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 +RUN microdnf update -y && \ + microdnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel tar gzip && \ + microdnf clean all # install sbt RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ @@ -20,26 +20,34 @@ RUN cd /root && \ curl -L -o opensourcecobol4j-v${opensource_COBOL_4J_version}.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v${opensource_COBOL_4J_version}.tar.gz && \ tar zxvf opensourcecobol4j-v${opensource_COBOL_4J_version}.tar.gz && \ cd opensourcecobol4j-${opensource_COBOL_4J_version} && \ - mkdir -p /tmp/usr/ &&\ - ./configure --prefix=/tmp/usr/ --enable-utf8 && \ + ./configure --prefix=/usr/ --enable-utf8 && \ touch cobj/*.m4 && \ make && \ make install && \ rm -rf /root/opensourcecobol4j-v${opensource_COBOL_4J_version}.tar.gz /root/opensourcecobol4j-${opensource_COBOL_4J_version} # Runtime stage -FROM almalinux:9 +FROM almalinux:9-minimal + +ARG opensource_COBOL_4J_version=dummy_value SHELL ["/bin/bash", "-c"] # install runtime dependencies only -RUN dnf update -y && \ - dnf install -y java-11-openjdk-devel && \ - dnf clean all && \ - rm -rf /var/cache/dnf/* +RUN microdnf update -y && \ + microdnf install -y java-11-openjdk-devel && \ + microdnf clean all && \ + rm -rf /var/cache/microdnf/* # copy built files from builder stage -COPY --from=builder /tmp/usr/ /usr/ +COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ +COPY --from=builder /usr/bin/cob-config /usr/bin/cob-config +COPY --from=builder /usr/bin/cobj /usr/bin/cobj +COPY --from=builder /usr/bin/cobj-api /usr/bin/cobj-api +COPY --from=builder /usr/bin/cobj-idx /usr/bin/cobj-idx +COPY --from=builder /usr/bin/cobjrun /usr/bin/cobjrun +COPY --from=builder /usr/include/libcobj.h /usr/include/libcobj.h +COPY --from=builder /usr/share/opensource-cobol-4j-${opensource_COBOL_4J_version} /usr/share/opensource-cobol-4j-${opensource_COBOL_4J_version} # classpath settings ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar