Skip to content

Commit 6124e13

Browse files
committed
2 parents 272805d + cc21253 commit 6124e13

4 files changed

Lines changed: 154 additions & 0 deletions

File tree

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.github
3+
4+
.dockerignore
5+
.gitignore
6+
CHANGELOG.md
7+
Dockerfile
8+
Jenkinsfile
9+
README.md

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: release-gtp2chebi-update ci
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
push:
10+
branches:
11+
- main
12+
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
jobs:
18+
lint:
19+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
20+
runs-on: ubuntu-latest
21+
env:
22+
REPO_DIR: /opt/release-gtp2chebi-update
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Run lint
27+
run: |
28+
docker build --build-arg REPO_DIR="$REPO_DIR" --target setup-env -t lint-image .
29+
docker run --name lint-container lint-image
30+
31+
- name: Display lint errors
32+
if: failure()
33+
run: |
34+
docker cp lint-container:"$REPO_DIR"/lint.log .
35+
while IFS= read -r LINT_MSG; do echo "::warning::${LINT_MSG}"; done < lint.log
36+
exit 1
37+
38+
docker-build:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- uses: docker/setup-buildx-action@v3
44+
45+
- uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
file: Dockerfile
49+
tags: tmp-tag
50+
outputs: type=docker,dest=/tmp/image.tar
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: image-artifact
55+
path: /tmp/image.tar
56+
57+
docker-push:
58+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
59+
needs: docker-build
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/download-artifact@v4
63+
with:
64+
name: image-artifact
65+
path: /tmp
66+
67+
- id: get-hash
68+
run: |
69+
FULL_SHA=${{ github.sha }}
70+
echo "SHORT_SHA=${FULL_SHA:0:7}" >> $GITHUB_OUTPUT
71+
72+
- env:
73+
AWS_REGION: us-east-1
74+
uses: aws-actions/configure-aws-credentials@v4
75+
with:
76+
role-to-assume: ${{ vars.AWS_ROLE }}
77+
aws-region: ${{ env.AWS_REGION }}
78+
79+
- id: login-ecr
80+
uses: aws-actions/amazon-ecr-login@v2
81+
with:
82+
registry-type: public
83+
84+
- env:
85+
AWS_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
86+
AWS_REGISTRY_ALIAS: reactome
87+
AWS_REPO: release-gtp2chebi-update
88+
IMG_TAG: ${{ steps.get-hash.outputs.SHORT_SHA }}
89+
run: |
90+
AWS_URI=$AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO
91+
docker load --input /tmp/image.tar
92+
docker tag tmp-tag $AWS_URI:latest
93+
docker push $AWS_URI:latest
94+
docker tag $AWS_URI:latest $AWS_URI:$IMG_TAG
95+
docker push $AWS_URI:$IMG_TAG
96+

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
ARG REPO_DIR=/opt/release-gtp2chebi-update
2+
3+
4+
# ===== stage 1 =====
5+
FROM maven:3.9.6-eclipse-temurin-11-focal AS setup-env
6+
7+
ARG REPO_DIR
8+
9+
WORKDIR ${REPO_DIR}
10+
11+
COPY . .
12+
13+
SHELL ["/bin/bash", "-c"]
14+
15+
# run lint if container started
16+
ENTRYPOINT []
17+
18+
CMD mvn -B -q checkstyle:check | \
19+
grep -i --color=never '\.java\|failed to execute goal' > lint.log && \
20+
exit 1 || \
21+
exit 0
22+
23+
24+
# ===== stage 2 =====
25+
FROM setup-env AS build-jar
26+
27+
RUN mvn clean package
28+
29+
30+
# ===== stage 3 =====
31+
FROM eclipse-temurin:11-jre-focal
32+
33+
ARG REPO_DIR
34+
35+
ARG JAR_FILE=target/gtp-chebi-mapping-jar-with-dependencies.jar
36+
37+
WORKDIR ${REPO_DIR}
38+
39+
COPY --from=build-jar ${REPO_DIR}/${JAR_FILE} ./target/
40+

checkstyle.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE module PUBLIC
2+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
3+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
4+
<module name="Checker">
5+
<module name="LineLength">
6+
<property name="max" value="150"/>
7+
</module>
8+
<!-- Add more modules as needed -->
9+
</module>

0 commit comments

Comments
 (0)