Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit d5e39ce

Browse files
committed
Fixed Actions & Docker
1 parent 27afbe7 commit d5e39ce

File tree

7 files changed

+154
-112
lines changed

7 files changed

+154
-112
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
env:
1010
JAVA_VERSION: 17
11+
JAVA_DISTRO: temurin
1112

1213
jobs:
1314
lint:
@@ -30,37 +31,22 @@ jobs:
3031
- name: Set up JDK ${{ env.JAVA_VERSION }}
3132
uses: actions/setup-java@v2
3233
with:
33-
distribution: adopt
3434
java-version: ${{ env.JAVA_VERSION }}
35+
distribution: ${{ env.JAVA_DISTRO }}
3536

3637
- name: Grant execute permission for gradlew
3738
run: chmod +x gradlew
3839

3940
- name: Lint with Gradle
40-
run: ./gradlew checkstyleMain checkstyleTest spotbugsMain spotbugsTest pmdMain pmdTest --stacktrace --no-daemon # javadoc
41-
42-
# - name: Annotate Checkstyle Issues
43-
# uses: jwgmeligmeyling/checkstyle-github-action@master
44-
# with:
45-
# path: '**/build/reports/checkstyle/*.xml'
46-
#
47-
# - name: Annotate SpotBugs Issues
48-
# uses: jwgmeligmeyling/spotbugs-github-action@master
49-
# with:
50-
# path: '**/build/reports/spotbugs/*.xml'
51-
#
52-
# - name: Annotate PMD Issues
53-
# uses: jwgmeligmeyling/pmd-github-action@master
54-
# with:
55-
# path: '**/build/reports/pmd/*.xml'
41+
run: ./gradlew checkstyleMain checkstyleTest spotbugsMain spotbugsTest pmdMain pmdTest --stacktrace --no-daemon
5642

5743
test:
5844
runs-on: ubuntu-latest
5945

6046
strategy:
6147
matrix:
62-
java-version: [ 11, 16 ]
63-
jvm-impl: [ 'hotspot', 'openj9' ]
48+
java-version: [ 17 ]
49+
java-distro: [ temurin, zulu, liberica, microsoft ]
6450

6551
steps:
6652
- uses: actions/checkout@v2
@@ -72,21 +58,21 @@ jobs:
7258
path: |
7359
~/.gradle/caches
7460
~/.gradle/wrapper
75-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
61+
key: ${{ runner.os }}-gradle-${{ matrix.java-distro }}-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
7662
restore-keys: |
77-
${{ runner.os }}-gradle-
63+
${{ runner.os }}-gradle-${{ matrix.java-distro }}-${{ matrix.java-version }}-
7864
7965
- name: Set up JDK ${{ matrix.java-version }}
8066
uses: actions/setup-java@v2
8167
with:
82-
distribution: adopt-${{ matrix.jvm-impl }}
8368
java-version: ${{ matrix.java-version }}
69+
distribution: ${{ matrix.java-distro }}
8470

8571
- name: Grant execute permission for gradlew
8672
run: chmod +x gradlew
8773

8874
- name: Run tests with Gradle
89-
run: ./gradlew test --no-daemon
75+
run: ./gradlew test --stacktrace --no-daemon
9076

9177
build:
9278
needs: [ lint, test ]
@@ -113,14 +99,14 @@ jobs:
11399
- name: Set up JDK ${{ env.JAVA_VERSION }}
114100
uses: actions/setup-java@v2
115101
with:
116-
distribution: adopt
117102
java-version: ${{ env.JAVA_VERSION }}
103+
distribution: ${{ env.JAVA_DISTRO }}
118104

119105
- name: Grant execute permission for gradlew
120106
run: chmod +x gradlew
121107

122108
- name: Build with Gradle
123-
run: ./gradlew :${{ matrix.service }}:bootJar --no-daemon
109+
run: ./gradlew :${{ matrix.service }}:shadowJar :${{ matrix.service }}:assemble --stacktrace --no-daemon
124110

125111
- uses: actions/upload-artifact@v2
126112
with:
@@ -131,37 +117,29 @@ jobs:
131117
needs: build
132118
runs-on: ubuntu-latest
133119

120+
permissions:
121+
packages: write
122+
134123
strategy:
135124
matrix:
136125
service: [ 'server', 'java-daemon', 'admin-panel' ]
137-
jvm-impl: [ hotspot, openj9 ]
138-
include:
139-
- jvm-impl: hotspot
140-
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
141-
- jvm-impl: openj9
142-
platforms: linux/amd64 #,linux/arm64/v8
143-
144-
env:
145-
IMAGE_NAME: crypticcp/${{ matrix.service }}
146126

147127
steps:
148128
- uses: actions/checkout@v2
149129
with:
150130
submodules: recursive
151131

152132
- name: Docker meta
153-
id: docker_meta
154-
uses: marcelcoding/ghaction-docker-meta@v1
155-
with:
156-
tag-edge: true
157-
images: |
158-
${{ env.IMAGE_NAME }}
159-
ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}
160-
tag-semver: |
161-
{{version}}
162-
{{major}}.{{minor}}
163-
flavor: ${{ matrix.jvm-impl }}
164-
main-flavor: ${{ matrix.jvm-impl == 'hotspot' }}
133+
id: meta
134+
uses: docker/metadata-action@v3
135+
with:
136+
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}
137+
tags: |
138+
type=edge
139+
type=ref,event=pr
140+
type=semver,pattern={{version}}
141+
type=semver,pattern={{major}}.{{minor}}
142+
type=semver,pattern={{major}}
165143
166144
- uses: docker/setup-qemu-action@v1
167145
- uses: docker/setup-buildx-action@v1
@@ -170,53 +148,39 @@ jobs:
170148
uses: actions/cache@v2
171149
with:
172150
path: /tmp/.buildx-cache
173-
key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ matrix.jvm-impl }}-${{ github.sha }}
151+
key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }}
174152
restore-keys: |
175-
${{ runner.os }}-buildx-${{ matrix.service }}-${{ matrix.jvm-impl }}-
176-
177-
- name: Login to Docker Hub
178-
if: ${{ github.event_name != 'pull_request' }}
179-
uses: docker/login-action@v1
180-
with:
181-
username: ${{ secrets.DOCKERHUB_USERNAME }}
182-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
153+
${{ runner.os }}-buildx-${{ matrix.service }}-
183154
184155
- name: Login to GitHub Container Registry
185-
if: ${{ github.event_name != 'pull_request' }}
186156
uses: docker/login-action@v1
157+
if: github.event_name != 'pull_request'
187158
with:
188159
registry: ghcr.io
189-
username: ${{ github.repository_owner }}
160+
username: ${{ github.actor }}
190161
password: ${{ github.token }}
191162

192163
- uses: actions/download-artifact@v2
193164
with:
194165
name: ${{ matrix.service }}
195-
path: dist
196166

197167
- name: Build
198168
uses: docker/build-push-action@v2
199169
with:
200170
context: .
201171
file: ./docker/Dockerfile.github-actions
202-
platforms: ${{ matrix.platforms }}
172+
platforms: linux/amd64,linux/arm64/v8 #${{ matrix.platforms }} linux/arm/v7,
203173
push: ${{ github.event_name != 'pull_request' }}
204-
tags: ${{ steps.docker_meta.outputs.tags }}
205-
labels: ${{ steps.docker_meta.outputs.labels }}
174+
tags: ${{ steps.meta.outputs.tags }}
175+
labels: ${{ steps.meta.outputs.labels }}
206176
build-args: |
207177
SERVICE_NAME=${{ matrix.service }}
208-
JAVA_VERSION=${{ env.JAVA_VERSION }}
209-
JVM_IMPL=${{ matrix.jvm-impl }}
178+
JVM_VERSION=${{ env.JAVA_VERSION }}
179+
# JVM_IMPL=${{ matrix.jvm-impl }}
210180
cache-from: type=local,src=/tmp/.buildx-cache
211181
cache-to: type=local,dest=/tmp/.buildx-cache-new
212182

213183
- name: Move cache
214184
run: |
215185
rm -rf /tmp/.buildx-cache
216186
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
217-
218-
- name: Check manifest
219-
if: ${{ github.event_name != 'pull_request' }}
220-
run: |
221-
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}
222-
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:${{ steps.docker_meta.outputs.version }}

admin-panel/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'org.springframework.boot'
33
id 'io.spring.dependency-management'
4+
id 'com.github.johnrengelman.shadow'
45
}
56

67
dependencies {

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ plugins {
1616
id 'com.github.spotbugs' version '4.7.5' apply(false)
1717
id 'org.springframework.boot' version "${springBootVersion}" apply false
1818
id 'io.spring.dependency-management' version '1.0.11.RELEASE' apply false
19+
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
1920
}
2021

2122
if (version.toString().endsWith('SNAPSHOT') || version.toString().isBlank()) {

docker/Dockerfile

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
ARG JAVA_VERSION=17
2-
ARG JVM_IMPL=hotspot
1+
ARG JVM_VERSION=17
32
ARG SERVICE_NAME=server
43

5-
FROM adoptopenjdk:${JAVA_VERSION}-jdk-${JVM_IMPL} AS builder
6-
7-
ARG SERVICE_NAME=server
4+
FROM eclipse-temurin:${JVM_VERSION}-jdk-focal AS builder
5+
ARG SERVICE_NAME
86

97
RUN set -o errexit -o nounset \
108
&& apt-get update \
@@ -13,25 +11,52 @@ RUN set -o errexit -o nounset \
1311
COPY . /src
1412
WORKDIR /src
1513

16-
RUN chmod +x ./gradlew \
17-
&& ./gradlew :${SERVICE_NAME}:bootJar --stacktrace --no-daemon
14+
RUN set -o errexit -o nounset \
15+
&& chmod +x ./gradlew \
16+
&& ./gradlew clean :${SERVICE_NAME}:shadowJar :${SERVICE_NAME}:assemble --stacktrace --no-daemon
17+
18+
FROM eclipse-temurin:${JVM_VERSION}-jdk-focal AS jre
19+
ARG JVM_VERSION
20+
ARG SERVICE_NAME
1821

19-
FROM adoptopenjdk:${JAVA_VERSION}-jre-${JVM_IMPL} AS extractor
22+
WORKDIR /src
2023

21-
ARG SERVICE_NAME=server
24+
COPY --from=builder /src/${SERVICE_NAME}/build/libs/${SERVICE_NAME}-*-all.jar ${SERVICE_NAME}.jar
25+
26+
RUN set -o errexit -o nounset \
27+
&& jdeps \
28+
--ignore-missing-deps \
29+
-q \
30+
--multi-release ${JVM_VERSION} \
31+
--print-module-deps \
32+
./${SERVICE_NAME}.jar > jre-deps.info \
33+
&& jlink \
34+
--add-modules $(cat jre-deps.info) \
35+
--strip-debug \
36+
--no-man-pages \
37+
--no-header-files \
38+
--compress 2 \
39+
--output ./jre
40+
41+
FROM eclipse-temurin:${JVM_VERSION}-jdk-focal AS extractor
42+
ARG SERVICE_NAME
2243

2344
WORKDIR /src
2445

25-
COPY --from=builder /src/${SERVICE_NAME}/build/libs/${SERVICE_NAME}*.jar cryptic.jar
26-
RUN java -Djarmode=layertools -jar cryptic.jar extract
46+
COPY --from=builder /src/${SERVICE_NAME}/build/libs/${SERVICE_NAME}-*.jar ${SERVICE_NAME}.jar
47+
RUN java -Djarmode=layertools -jar ${SERVICE_NAME}.jar extract
48+
49+
FROM ubuntu:focal
50+
ARG SERVICE_NAME
2751

28-
FROM adoptopenjdk:${JAVA_VERSION}-jre-${JVM_IMPL}
52+
ENV JAVA_HOME=/opt/jre
53+
ENV PATH="/opt/jre/bin:${PATH}"
2954

3055
ENV HTTP_PORT=8080
3156
ENV MANAGEMENT_PORT=8081
3257

33-
ARG CRYPTIC_USER=cryptic
34-
ARG CRYPTIC_GROUP=cryptic
58+
ARG CRYPTIC_USER=cryptic-${SERVICE_NAME}
59+
ARG CRYPTIC_GROUP=cryptic-${SERVICE_NAME}
3560
ARG DATA_DIR=/data
3661

3762
RUN set -o errexit -o nounset \
@@ -42,24 +67,34 @@ RUN set -o errexit -o nounset \
4267
&& chown --recursive ${CRYPTIC_USER}:${CRYPTIC_GROUP} /home/${CRYPTIC_USER} \
4368
\
4469
&& apt-get update \
45-
&& apt-get install -y --no-install-recommends curl jq \
46-
&& rm -rf /var/lib/apt/lists/*
70+
&& apt-get install -y --no-install-recommends curl jq ca-certificates \
71+
&& rm -rf /var/lib/apt/lists/* \
72+
\
73+
&& curl -fsSL https://raw.githubusercontent.com/fabric8io-images/run-java-sh/master/fish-pepper/run-java-sh/fp-files/run-java.sh -so /opt/run-java.sh \
74+
&& chmod +x /opt/run-java.sh
75+
76+
COPY --from=jre /src/jre ${JAVA_HOME}
4777

4878
WORKDIR ${DATA_DIR}
4979

80+
ENV JAVA_APP_DIR=${DATA_DIR}
81+
ENV JAVA_MAIN_CLASS=org.springframework.boot.loader.JarLauncher
82+
ENV JAVA_APP_NAME=cryptic-${SERVICE_NAME}
83+
ENV JAVA_CLASSPATH=/opt/cryptic-${SERVICE_NAME}
84+
5085
USER ${CRYPTIC_USER}:${CRYPTIC_GROUP}
5186
VOLUME ${DATA_DIR}
5287

5388
EXPOSE ${HTTP_PORT}
5489
EXPOSE ${MANAGEMENT_PORT}
5590

56-
COPY --from=extractor /src/dependencies/ /opt/cryptic
57-
COPY --from=extractor /src/spring-boot-loader/ /opt/cryptic
58-
COPY --from=extractor /src/snapshot-dependencies/ /opt/cryptic
59-
COPY --from=extractor /src/application/ /opt/cryptic
91+
COPY --from=extractor /src/dependencies/ /opt/cryptic-${SERVICE_NAME}
92+
COPY --from=extractor /src/spring-boot-loader/ /opt/cryptic-${SERVICE_NAME}
93+
COPY --from=extractor /src/snapshot-dependencies/ /opt/cryptic-${SERVICE_NAME}
94+
COPY --from=extractor /src/application/ /opt/cryptic-${SERVICE_NAME}
6095

61-
ENTRYPOINT ["java", "-cp", "/opt/cryptic", "org.springframework.boot.loader.JarLauncher"]
96+
ENTRYPOINT ["/opt/run-java.sh"]
6297

63-
HEALTHCHECK --start-period=10s --interval=30s --timeout=3s --retries=3 \
64-
CMD curl --silent --fail --request GET "http://localhost:${MANAGEMENT_PORT}/actuator/health" \
65-
| jq --exit-status '.status == "UP"' || exit 1
98+
#HEALTHCHECK --start-period=10s --interval=30s --timeout=3s --retries=3 \
99+
# CMD curl --silent --fail --request GET "http://localhost:${MANAGEMENT_PORT}/actuator/health" \
100+
# | jq --exit-status '.status == "UP"' || exit 1

0 commit comments

Comments
 (0)