Skip to content

Commit b971c44

Browse files
robkooperlmarini
andauthored
Docker updates (#362)
* use docker build action also cross platform building and cache * don't build arm for elasticsearch * mongo-init amd64 only * update version calc * missing quotes * newline * update docker - use newer java version (fixes #361) - build arm version (fixes #322) * fix error in action * fix tags * update tags pushed * special case for clowder image * add names to steps * push * push image - needed for cache * only push to dockerhub * use github.actor * disable fail-fast * explicit set permissions * push to branch tag for cache * remove cache * version bump * Updated CHANGELOG.md. Co-authored-by: Luigi Marini <lmarini@illinois.edu>
1 parent 68baf98 commit b971c44

6 files changed

Lines changed: 123 additions & 83 deletions

File tree

.github/workflows/docker.yml

Lines changed: 109 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ env:
2929
jobs:
3030
docker:
3131
runs-on: ubuntu-latest
32+
permissions:
33+
packages: write
3234
strategy:
33-
fail-fast: true
35+
fail-fast: false
3436
matrix:
3537
name:
3638
- clowder
@@ -42,126 +44,159 @@ jobs:
4244
FOLDER: "."
4345
IMAGE: clowder
4446
README: README.md
47+
PLATFORM: "linux/amd64,linux/arm64"
4548
- name: mongo-init
4649
FOLDER: scripts/mongo-init
4750
IMAGE: mongo-init
4851
README: ""
52+
PLATFORM: "linux/amd64"
4953
- name: monitor
5054
FOLDER: scripts/monitor
5155
IMAGE: monitor
5256
README: ""
57+
PLATFORM: "linux/amd64,linux/arm64"
5358
- name: elasticsearch
5459
FOLDER: scripts/elasticsearch
5560
IMAGE: elasticsearch
5661
README: ""
62+
PLATFORM: "linux/amd64"
5763

5864
steps:
59-
- uses: actions/checkout@v2
65+
- uses: actions/checkout@v3
6066

6167
# calculate some variables that are used later
62-
- name: github branch
68+
- name: variable setup
6369
run: |
6470
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
6571
BRANCH="${{ github.event.release.target_commitish }}"
72+
elif [[ $GITHUB_REF =~ pull ]]; then
73+
BRANCH="$(echo $GITHUB_REF | sed 's#refs/pull/\([0-9]*\)/merge#PR-\1#')"
6674
else
6775
BRANCH=${GITHUB_REF##*/}
6876
fi
69-
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
77+
7078
if [ "$BRANCH" == "master" ]; then
7179
version="$(awk '/version = / { print $4 }' project/Build.scala | sed 's/"//g')"
7280
tags="latest"
7381
oldversion=""
7482
while [ "${oldversion}" != "${version}" ]; do
7583
oldversion="${version}"
76-
tags="${tags},${version}"
84+
tags="${tags} ${version}"
7785
version=${version%.*}
7886
done
79-
echo "CLOWDER_VERSION=$(awk '/version = / { print $4 }' project/Build.scala | sed 's/"//g')" >> $GITHUB_ENV
80-
echo "CLOWDER_TAGS=${tags}" >> $GITHUB_ENV
87+
version="$(awk '/version = / { print $4 }' project/Build.scala | sed 's/"//g')"
8188
elif [ "$BRANCH" == "develop" ]; then
82-
echo "CLOWDER_VERSION=develop" >> $GITHUB_ENV
83-
echo "CLOWDER_TAGS=develop" >> $GITHUB_ENV
89+
version="develop"
90+
tags="develop"
8491
else
85-
echo "CLOWDER_VERSION=testing" >> $GITHUB_ENV
86-
echo "CLOWDER_TAGS=" >> $GITHUB_ENV
92+
version="test"
93+
tags="${BRANCH}"
8794
fi
8895
89-
# build the docker image, this will always run to make sure
90-
# the Dockerfile still works.
91-
- name: Build image
92-
uses: elgohr/Publish-Docker-Github-Action@2.22
93-
env:
94-
BRANCH: ${{ env.GITHUB_BRANCH }}
95-
VERSION: ${{ env.CLOWDER_VERSION }}
96-
BUILDNUMBER: ${{ github.run_number }}
97-
GITSHA1: ${{ github.sha }}
96+
push_tags=""
97+
for tag in ${tags}; do
98+
push_tags="${push_tags}${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}:${tag},"
99+
push_tags="${push_tags}ghcr.io/${{ github.repository_owner }}/${{ matrix.IMAGE }}:${tag},"
100+
done
101+
push_tags="${push_tags%,*}"
102+
103+
echo "BRANCH=${BRANCH}"
104+
echo "VERSION=${version}"
105+
echo "TAGS=${tags}"
106+
echo "PUSH_TAGS=${push_tags}"
107+
108+
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
109+
echo "VERSION=${version}" >> $GITHUB_ENV
110+
echo "TAGS=${push_tags}" >> $GITHUB_ENV
111+
112+
# setup docker build
113+
- name: Set up QEMU
114+
uses: docker/setup-qemu-action@v2
115+
116+
- name: Set up Docker Buildx
117+
id: buildx
118+
uses: docker/setup-buildx-action@v2
119+
120+
- name: Inspect Builder
121+
run: |
122+
echo "Name: ${{ steps.buildx.outputs.name }}"
123+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
124+
echo "Status: ${{ steps.buildx.outputs.status }}"
125+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
126+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
127+
128+
# login to registries
129+
- name: Login to DockerHub
130+
uses: docker/login-action@v2
131+
with:
132+
username: ${{ secrets.DOCKERHUB_USERNAME }}
133+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
134+
135+
- name: Login to GitHub Container Registry
136+
uses: docker/login-action@v2
98137
with:
99-
registry: docker.pkg.github.com
100-
name: ${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.IMAGE }}
138+
registry: ghcr.io
101139
username: ${{ github.actor }}
102140
password: ${{ secrets.GITHUB_TOKEN }}
141+
142+
# build the clowder docker images
143+
- name: Build and push ${{ matrix.IMAGE }}-build
144+
if: matrix.IMAGE == 'clowder'
145+
uses: docker/build-push-action@v2
146+
with:
147+
push: true
103148
context: ${{ matrix.FOLDER }}
104-
tags: "${{ env.TAGS }}"
105-
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1
106-
no_push: true
107-
108-
# this will publish to github container registry
109-
- name: Publish to GitHub
110-
if: github.event_name != 'pull_request' && github.repository == env.MASTER_REPO
111-
uses: elgohr/Publish-Docker-Github-Action@2.22
112-
env:
113-
BRANCH: ${{ env.GITHUB_BRANCH }}
114-
VERSION: ${{ env.CLOWDER_VERSION }}
115-
BUILDNUMBER: ${{ github.run_number }}
116-
GITSHA1: ${{ github.sha }}
149+
platforms: ${{ matrix.PLATFORM }}
150+
target: ${{ matrix.IMAGE }}-build
151+
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-build-cache:${{ env.BRANCH }}
152+
cache-to: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-build-cache:${{ env.BRANCH }},mode=max
153+
tags: ${{ env.TAGS }}
154+
build-args: |
155+
BRANCH=${{ env.BRANCH }}
156+
VERSION=${{ env.VERSION }}
157+
BUILDNUMBER=${{ github.run_number }}
158+
GITSHA1=${{ github.sha }}
159+
160+
- name: Build and push ${{ matrix.IMAGE }}-runtime
161+
if: matrix.IMAGE == 'clowder'
162+
uses: docker/build-push-action@v2
117163
with:
118-
registry: ghcr.io
119-
name: ${{ github.repository_owner }}/${{ matrix.IMAGE }}
120-
username: ${{ secrets.GHCR_USERNAME }}
121-
password: ${{ secrets.GHCR_PASSWORD }}
164+
push: true
122165
context: ${{ matrix.FOLDER }}
123-
tags: "${{ env.CLOWDER_TAGS }}"
124-
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1
166+
platforms: ${{ matrix.PLATFORM }}
167+
target: ${{ matrix.IMAGE }}-runtime
168+
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-runtime-cache:${{ env.BRANCH }}
169+
cache-to: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-runtime-cache:${{ env.BRANCH }}
170+
tags: ${{ env.TAGS }}
171+
build-args: |
172+
BRANCH=${{ env.BRANCH }}
173+
VERSION=${{ env.VERSION }}
174+
BUILDNUMBER=${{ github.run_number }}
175+
GITSHA1=${{ github.sha }}
125176
126-
# this will publish to the clowder dockerhub repo
127-
- name: Publish to Docker Hub
128-
if: github.event_name != 'pull_request' && github.repository == env.MASTER_REPO
129-
uses: elgohr/Publish-Docker-Github-Action@2.22
130-
env:
131-
BRANCH: ${{ env.GITHUB_BRANCH }}
132-
VERSION: ${{ env.CLOWDER_VERSION }}
133-
BUILDNUMBER: ${{ github.run_number }}
134-
GITSHA1: ${{ github.sha }}
177+
# build the other docker images
178+
- name: Build and push ${{ matrix.IMAGE }}
179+
if: matrix.IMAGE != 'clowder'
180+
uses: docker/build-push-action@v2
135181
with:
136-
name: ${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}
137-
username: ${{ secrets.DOCKERHUB_USERNAME }}
138-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
182+
push: true
139183
context: ${{ matrix.FOLDER }}
140-
tags: "${{ env.CLOWDER_TAGS }}"
141-
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1
184+
platforms: ${{ matrix.PLATFORM }}
185+
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-cache:${{ env.BRANCH }}
186+
cache-to: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}-cache:${{ env.BRANCH }},mode=max
187+
tags: ${{ env.TAGS }}
188+
build-args: |
189+
BRANCH=${{ env.BRANCH }}
190+
VERSION=${{ env.VERSION }}
191+
BUILDNUMBER=${{ github.run_number }}
192+
GITSHA1=${{ github.sha }}
142193
143-
# this will update the README of the dockerhub repo
144-
- name: check file
145-
id: filecheck
146-
run: |
147-
if [ "${{ matrix.README }}" != "" ]; then
148-
if [ -e "${{ matrix.README }}" ]; then
149-
echo "##[set-output name=readme;]${{ matrix.README }}"
150-
else
151-
echo "##[set-output name=readme;]"
152-
fi
153-
else
154-
if [ -e "${{ matrix.FOLDER }}/README.md" ]; then
155-
echo "##[set-output name=readme;]${{ matrix.FOLDER }}/README.md"
156-
else
157-
echo "##[set-output name=readme;]"
158-
fi
159-
fi
194+
# update README at DockerHub
160195
- name: Docker Hub Description
161-
if: github.event_name == 'push' && github.repository == env.MASTER_REPO && env.BRANCH == 'master' && steps.filecheck.outputs.readme != ''
196+
if: matrix.README != '' && github.event_name == 'push' && github.repository == env.MASTER_REPO && env.BRANCH == 'master'
162197
uses: peter-evans/dockerhub-description@v2
163198
env:
164199
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
165200
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
166201
DOCKERHUB_REPOSITORY: ${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }}
167-
README_FILEPATH: ${{ steps.filecheck.outputs.readme }}
202+
README_FILEPATH: ${{ matrix.README }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## 1.20.3 - 2022-06-10
9+
10+
### Fixed
11+
- docker images are build using newest java version [#361](https://github.com/clowder-framework/clowder/issues/361)
12+
13+
### Changed
14+
- docker builds images for amd64 and arm64 [#322](https://github.com/clowder-framework/clowder/issues/322)
15+
816
## 1.20.2 - 2022-04-30
917

1018
### Fixed

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ----------------------------------------------------------------------
22
# BUILD CLOWDER DIST
33
# ----------------------------------------------------------------------
4-
FROM java:jdk-alpine as clowder-build
4+
FROM openjdk:8-jdk-bullseye as clowder-build
55

66
ARG BRANCH="unknown"
77
ARG VERSION="unknown"
@@ -30,7 +30,7 @@ RUN rm -rf target/universal/clowder-*.zip clowder clowder-* \
3030
&& ./sbt dist \
3131
&& unzip -q target/universal/clowder-*.zip \
3232
&& mv clowder-* clowder \
33-
&& apk add --no-cache zip \
33+
&& apt-get update && apt-get -y install zip \
3434
&& for x in $(find clowder -name \*.jar); do \
3535
zip -d $x org/apache/log4j/net/JMSAppender.class org/apache/log4j/net/SocketServer.class | grep 'deleting:' && echo "fixed $x"; \
3636
done; \
@@ -40,10 +40,7 @@ RUN rm -rf target/universal/clowder-*.zip clowder clowder-* \
4040
# ----------------------------------------------------------------------
4141
# BUILD CLOWDER
4242
# ----------------------------------------------------------------------
43-
FROM java:jre-alpine
44-
45-
# add bash
46-
RUN apk add --no-cache bash curl
43+
FROM openjdk:8-jre-bullseye as clowder-runtime
4744

4845
# environemnt variables
4946
ARG BRANCH="unknown"

doc/src/sphinx/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'Luigi Marini'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '1.20.2'
25+
release = '1.20.3'
2626

2727

2828
# -- General configuration ---------------------------------------------------

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NativePackagerKeys._
1313
object ApplicationBuild extends Build {
1414

1515
val appName = "clowder"
16-
val version = "1.20.2"
16+
val version = "1.20.3"
1717
val jvm = "1.7"
1818

1919
def appVersion: String = {

public/swagger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ info:
99
Clowder is a customizable and scalable data management system to support any
1010
data format and multiple research domains. It is under active development
1111
and deployed for a variety of research projects.
12-
version: 1.20.2
12+
version: 1.20.3
1313
termsOfService: https://clowder.ncsa.illinois.edu/clowder/tos
1414
contact:
1515
name: Clowder

0 commit comments

Comments
 (0)