From c64a71c574d6538b072b052f53864f31c8506405 Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 12 Mar 2018 18:14:22 +0100 Subject: [PATCH 01/10] Initial dockerfile --- Dockerfile | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..075c057 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +# Development Dockerfile for Microservices +# ---------------------------------------- +# This dockerfile can be used to build +# a distribution which can then be run +# within a number of different Docker images. + +# By default, building this dockerfile will use +# the IMAGE argument below for the runtime image: + +ARG IMAGE=verx/vertx3 + +# To install the built distribution into other runtimes +# pass a build argument, e.g.: +# +# docker build --build-arg IMAGE=openjdk:9 ... +# + +# Similarly, the GRADLE_IMAGE argument can be overwritten +# but this is generally not needed. +ARG GRADLE_IMAGE=gradle:jdk-alpine + +# +# Build phase: Use the gradle image for building. +# +FROM ${GRADLE_IMAGE} as gradle +RUN mkdir -p /src/target + +## RUN apt-get update && \ +## apt-get install -y python-sphinx + +RUN useradd -ms /bin/bash ms +COPY . /src +RUN chown -R ms /src +USER ms +WORKDIR /src +RUN git submodule update --init +RUN ./gradlew installDist + +# +# Install phase: Copy the built distribution into a +# clean container to minimize size. +# +FROM ${IMAGE} +COPY --from=gradle /src/ /opt/build + +ENV VERTICLE_NAME com.glencoesoftware +ENV VERTICLE_FILE target/ +ENV VERTICLE_HOME /usr/verticles +ENV JAVA_OPTS "-Xmx1GB" + +COPY $VERTICLE_FILE $VERTICLE_HOME/ +EXPOSE 8080 + +RUN useradd -ms /bin/bash vertx +USER vertx + +WORKDIR $VERTICLE_HOME +ENTRYPOINT ["sh", "-c"] +CMD ["exec vertx run $VERTICLE_NAME -cp $VERTCILE_HOME/*"] From bda5f001df97ae2514b55e5c8043a078b9f4e5db Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 12 Mar 2018 17:43:44 +0000 Subject: [PATCH 02/10] Building dockerfile --- Dockerfile | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 075c057..a80ad41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # By default, building this dockerfile will use # the IMAGE argument below for the runtime image: -ARG IMAGE=verx/vertx3 +ARG IMAGE=vertx/vertx3 # To install the built distribution into other runtimes # pass a build argument, e.g.: @@ -23,37 +23,23 @@ ARG GRADLE_IMAGE=gradle:jdk-alpine # Build phase: Use the gradle image for building. # FROM ${GRADLE_IMAGE} as gradle -RUN mkdir -p /src/target +RUN mkdir -p ms -## RUN apt-get update && \ -## apt-get install -y python-sphinx +COPY build.gradle ms/ +COPY src ms/src +WORKDIR ms +RUN gradle installDist -RUN useradd -ms /bin/bash ms -COPY . /src -RUN chown -R ms /src -USER ms -WORKDIR /src -RUN git submodule update --init -RUN ./gradlew installDist # # Install phase: Copy the built distribution into a # clean container to minimize size. # FROM ${IMAGE} -COPY --from=gradle /src/ /opt/build +COPY --from=gradle /home/gradle/ms/build/install/ms /usr/verticles/ms -ENV VERTICLE_NAME com.glencoesoftware -ENV VERTICLE_FILE target/ -ENV VERTICLE_HOME /usr/verticles -ENV JAVA_OPTS "-Xmx1GB" - -COPY $VERTICLE_FILE $VERTICLE_HOME/ EXPOSE 8080 -RUN useradd -ms /bin/bash vertx -USER vertx - -WORKDIR $VERTICLE_HOME -ENTRYPOINT ["sh", "-c"] -CMD ["exec vertx run $VERTICLE_NAME -cp $VERTCILE_HOME/*"] +ENV JAVA_OPTS "-Xmx1G" +WORKDIR /usr/verticles/ms +ENTRYPOINT ["bash", "bin/ms"] From e8af88e10bdf85dfb5deb4caa50ca628097eab3f Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 12 Mar 2018 17:49:11 +0000 Subject: [PATCH 03/10] Running dockerfile --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a80ad41..13cc6e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,12 @@ FROM ${IMAGE} COPY --from=gradle /home/gradle/ms/build/install/ms /usr/verticles/ms EXPOSE 8080 - ENV JAVA_OPTS "-Xmx1G" + WORKDIR /usr/verticles/ms + + +ARG REDIS_SERVER=redis +RUN sed -i "s/127.0.0.1:6379/$REDIS_SERVER:6379/" conf/config.yaml + ENTRYPOINT ["bash", "bin/ms"] From 4adbd859dec007560678ff39c2d8e4a67a1b994b Mon Sep 17 00:00:00 2001 From: jmoore Date: Tue, 13 Mar 2018 13:34:27 +0000 Subject: [PATCH 04/10] Allow configuration of OMERO.server --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 13cc6e4..ba02e8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,9 @@ ENV JAVA_OPTS "-Xmx1G" WORKDIR /usr/verticles/ms +ARG OMERO_SERVER=omero ARG REDIS_SERVER=redis RUN sed -i "s/127.0.0.1:6379/$REDIS_SERVER:6379/" conf/config.yaml +RUN sed -i "s/localhost/$OMERO_SERVER/" conf/config.yaml ENTRYPOINT ["bash", "bin/ms"] From 2fbcfe36406d4f43761bb765e96fe239e97e15aa Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 23 Jul 2020 12:14:35 +0200 Subject: [PATCH 05/10] Bump to SNAPSHOT --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3365a01..244ec2b 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'com.glencoesoftware.omero' -version = '0.5.0' +version = '0.5.1-SNAPSHOT' mainClassName = 'io.vertx.core.Launcher' From 401d37e67447b9c93efc5754a71eef7694291feb Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 23 Jul 2020 12:15:06 +0200 Subject: [PATCH 06/10] Add bumpversion config for syncing versions --- .bumpversion.cfg | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..21ad3ac --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,22 @@ +[bumpversion] +current_version = 0.5.1-SNAPSHOT +commit = True +tag = True +sign_tags = True +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(?P-[a-zA-Z]+)? +serialize = + {major}.{minor}.{patch}{release} + {major}.{minor}.{patch} + +[bumpversion:part:release] +optional_value = -GA +first_value = -SNAPSHOT +values = + -SNAPSHOT + -GA + +[bumpversion:part:build] + +[bumpversion:file:build.gradle] + +[bumpversion:file:Dockerfile] From 2e4ed56ab8819fc4b9a2a6402e71f49af503dbf1 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 23 Jul 2020 12:14:19 +0200 Subject: [PATCH 07/10] Add GH Action for pushing to Docker Hub copied from omero-ms-zarr --- .github/workflows/dockerpublish.yml | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/dockerpublish.yml diff --git a/.github/workflows/dockerpublish.yml b/.github/workflows/dockerpublish.yml new file mode 100644 index 0000000..cf7aba3 --- /dev/null +++ b/.github/workflows/dockerpublish.yml @@ -0,0 +1,69 @@ +name: Docker + +on: + push: + # Publish `master` as Docker `latest` image. + branches: + - master + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + +env: + IMAGE_NAME: openmicroscopy/omero-ms-zarr + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + if [ -f docker-compose.test.yml ]; then + docker-compose --file docker-compose.test.yml build + docker-compose --file docker-compose.test.yml run sut + fi + + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + # Ensure test job passes before pushing image. + needs: test + + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build . --file Dockerfile --tag $IMAGE_NAME + + - name: Log into registry + run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u omereleases --password-stdin + + - name: Push image + run: | + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + + echo IMAGE_NAME=$IMAGE_NAME + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION + docker push $IMAGE_NAME:$VERSION From 09f863c272855cb0f945b9a7546933eb7c149431 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 23 Jul 2020 12:16:19 +0200 Subject: [PATCH 08/10] Update action to use 0.5.x --- .github/workflows/dockerpublish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerpublish.yml b/.github/workflows/dockerpublish.yml index cf7aba3..1f7d60d 100644 --- a/.github/workflows/dockerpublish.yml +++ b/.github/workflows/dockerpublish.yml @@ -2,9 +2,9 @@ name: Docker on: push: - # Publish `master` as Docker `latest` image. + # Publish `0.5.x` as Docker `latest` image. branches: - - master + - 0.5.x # Publish `v1.2.3` tags as releases. tags: @@ -14,7 +14,7 @@ on: pull_request: env: - IMAGE_NAME: openmicroscopy/omero-ms-zarr + IMAGE_NAME: openmicroscopy/omero-ms-thumbnail jobs: # Run tests. @@ -60,7 +60,7 @@ jobs: [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + [ "$VERSION" == "0.5.x" ] && VERSION=latest echo IMAGE_NAME=$IMAGE_NAME echo VERSION=$VERSION From 0b6294fb9b2d4fd014c8ed2f0bb33f0b5d34e50a Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 27 Jul 2020 12:15:20 +0200 Subject: [PATCH 09/10] Use adopopenjdk rather than vertx base image --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba02e8b..087bc75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # By default, building this dockerfile will use # the IMAGE argument below for the runtime image: -ARG IMAGE=vertx/vertx3 +ARG IMAGE=adoptopenjdk/openjdk11:jre-11.0.7_10-alpine # To install the built distribution into other runtimes # pass a build argument, e.g.: @@ -36,12 +36,12 @@ RUN gradle installDist # clean container to minimize size. # FROM ${IMAGE} -COPY --from=gradle /home/gradle/ms/build/install/ms /usr/verticles/ms +COPY --from=gradle /home/gradle/ms/build/install/ms /opt/ms EXPOSE 8080 ENV JAVA_OPTS "-Xmx1G" -WORKDIR /usr/verticles/ms +WORKDIR /opt/ms ARG OMERO_SERVER=omero @@ -49,4 +49,4 @@ ARG REDIS_SERVER=redis RUN sed -i "s/127.0.0.1:6379/$REDIS_SERVER:6379/" conf/config.yaml RUN sed -i "s/localhost/$OMERO_SERVER/" conf/config.yaml -ENTRYPOINT ["bash", "bin/ms"] +ENTRYPOINT ["sh", "bin/ms"] From 11dc159c148afce1af1890cc9305f838b8574e99 Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 27 Jul 2020 12:30:27 +0200 Subject: [PATCH 10/10] Use gradlew to simplify versioning --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 087bc75..b86f8f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ ARG IMAGE=adoptopenjdk/openjdk11:jre-11.0.7_10-alpine # Similarly, the GRADLE_IMAGE argument can be overwritten # but this is generally not needed. -ARG GRADLE_IMAGE=gradle:jdk-alpine +ARG GRADLE_IMAGE=gradle:jdk # # Build phase: Use the gradle image for building. @@ -27,8 +27,10 @@ RUN mkdir -p ms COPY build.gradle ms/ COPY src ms/src +COPY gradle ms/gradle +COPY gradlew ms/gradlew WORKDIR ms -RUN gradle installDist +RUN /bin/bash ./gradlew installDist #