Skip to content

Commit

Permalink
Use docker/build-push-action to build multi-platform images
Browse files Browse the repository at this point in the history
Update default docker JDK/MavenJDK to eclipse-temurin-11
  • Loading branch information
zhx828 committed Nov 11, 2022
1 parent d870515 commit 72f41be
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ trim_trailing_whitespace = false
# Formats for HTML files only
[**.html]
insert_final_newline = false

[{*.yml, *.yaml}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
109 changes: 74 additions & 35 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docker Image CI
on:
push:
branches:
branches:
- master
- release-*
- rc
Expand All @@ -15,47 +15,86 @@ jobs:
if: github.repository == 'cBioPortal/cbioportal'
runs-on: ubuntu-latest
steps:
- name: 'Checkout git repo'
uses: actions/checkout@v1
- name: Extract branch or tag name
# The GITHUB_REF variable is like "refs/head/branch_name" or
# "refs/tag/tag_name". If the tag is prefixed with v, this is a new
# version and we want to push it with the tag "latest" as well because
# that is the version we refer to in the docucmentation. One can give
# the same image multiple tags by using ","
run: echo "##[set-output name=image_tag_names;]$(echo ${GITHUB_REF##*/} | sed 's/^v/latest,/g')"
id: extract_tags
- name: 'Docker build with cache'
uses: whoan/docker-build-with-cache-action@v5
- name: Checkout git repo
uses: actions/checkout@v3

- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
cbioportal/cbioportal
# The latest tag will also be generated on tag event with a valid semver tag
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
# The following two actions are required to build multi-platform images
# buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish Docker Image on Tag
uses: docker/build-push-action@v3
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
image_name: cbioportal/cbioportal
image_tag: ${{ steps.extract_tags.outputs.image_tag_names }}
context: .
dockerfile: docker/web-and-data/Dockerfile
pull_image_and_stages: false
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
file: docker/web-and-data/Dockerfile
cache-from: type=gha
cache-to: type=gha

build_and_publish_web:
if: github.repository == 'cBioPortal/cbioportal'
runs-on: ubuntu-latest
steps:
- name: 'Checkout git repo'
uses: actions/checkout@v1
- name: Extract branch or tag name
# For the web docker image we don't publish it as latest
# just extract branch/tag name and strip v prefix
run: echo "##[set-output name=image_tag_names;]$(echo ${GITHUB_REF##*/} | sed 's/^v//g')"
id: extract_tags
- name: 'Docker build with cache'
uses: whoan/docker-build-with-cache-action@v5
- name: Checkout git repo
uses: actions/checkout@v3

- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
cbioportal/cbioportal
# Do not generate latest tag
flavor: |
latest=false
suffix=-web-shenandoah
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
# The following two actions are required to build multi-platform images
# buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish Docker Image on Tag
uses: docker/build-push-action@v3
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
image_name: cbioportal/cbioportal
image_tag: ${{ steps.extract_tags.outputs.image_tag_names }}-web-shenandoah
context: .
dockerfile: docker/web/Dockerfile
pull_image_and_stages: false
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
file: docker/web/Dockerfile
cache-from: type=gha
cache-to: type=gha

# Reference: https://github.com/marketplace/actions/build-docker-images-using-cache
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
name: Integration tests
runs-on: ubuntu-latest
env:
env:
PORTAL_SOURCE_DIR: /home/runner/work/cbioportal/cbioportal/cbioportal
PORTAL_COMPOSE_DIR: /home/runner/work/cbioportal/cbioportal/cbioportal-docker-compose
PORTAL_INFO_DIR: /home/runner/work/cbioportal/cbioportal/portalInfo
Expand Down
7 changes: 4 additions & 3 deletions docker/web-and-data/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# NOTE: the .git folder is included in the build stage, but excluded
# from the final image. No confidential information is exposed.
# (see: stackoverflow.com/questions/56278325)
FROM maven:3-openjdk-11 as build
FROM maven:3-eclipse-temurin-11 as build

# download maven dependencies first to take advantage of docker caching
COPY pom.xml /cbioportal/
Expand All @@ -35,9 +35,10 @@ COPY portal/pom.xml portal/
RUN mvn dependency:go-offline --fail-never

COPY $PWD /cbioportal
RUN mvn -DskipTests clean install
# Use quite output so we can see the build steps easily
RUN mvn -DskipTests clean install -q

FROM openjdk:11-jre-slim
FROM eclipse-temurin:11

# download system dependencies first to take advantage of docker caching
RUN apt-get update; apt-get install -y --no-install-recommends \
Expand Down
9 changes: 5 additions & 4 deletions docker/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
#
# WARNING: the shendoah image is a nightly, untested, experimental build. If
# you want to use an official openjdk image instead use the web-and-data image.
FROM maven:3-openjdk-11 as build
FROM maven:3-eclipse-temurin-11 as build
COPY $PWD /cbioportal
WORKDIR /cbioportal
ARG MAVEN_OPTS=-DskipTests
RUN mvn ${MAVEN_OPTS} clean install
# Use quite output so we can see the build steps easily
RUN mvn ${MAVEN_OPTS} clean install -q

FROM shipilev/openjdk:11
FROM eclipse-temurin:11

ENV PORTAL_WEB_HOME=/cbioportal-webapp

Expand All @@ -29,4 +30,4 @@ COPY --from=build /cbioportal/portal/target/dependency/webapp-runner.jar /webapp
RUN mkdir -p $PORTAL_WEB_HOME
RUN cd $PORTAL_WEB_HOME && jar -xvf /app.war

CMD ["/bin/sh", "-c", "/usr/bin/java ${JAVA_OPTS} -jar /webapp-runner.jar ${WEBAPP_OPTS} ${PORTAL_WEB_HOME}"]
CMD ["java", "${JAVA_OPTS} -jar /webapp-runner.jar ${WEBAPP_OPTS} ${PORTAL_WEB_HOME}"]

0 comments on commit 72f41be

Please sign in to comment.