Skip to content

Commit 00ecb9c

Browse files
committed
Added Docker support and CI for automatic build of docker image on new
tag push. Fixed jar packaging and added resources/version.properties file.
1 parent 5441cfd commit 00ecb9c

4 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Publish Container Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v0.*' # Triggers on tags like 0.39, 0.40 etc.
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '8'
23+
distribution: 'temurin'
24+
cache: 'maven'
25+
26+
- name: Build with Maven
27+
run: mvn -B clean package
28+
29+
- name: Unzip Trimmomatic artifact
30+
run: unzip target/Trimmomatic-*.zip
31+
32+
- name: Log in to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract version from tag
40+
id: get_version
41+
# Removes 'refs/tags/' prefix to get the clean version number
42+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
43+
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
push: true
50+
tags: ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.VERSION }}
51+
build-args: |
52+
TRIMMOMATIC_VERSION=${{ steps.get_version.outputs.VERSION }}

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# --- Stage 1: Unpack and Prepare ---
2+
FROM eclipse-temurin:8-jre-focal as preparer
3+
# Re-declare ARG for this stage
4+
ARG TRIMMOMATIC_VERSION
5+
RUN apt-get update && apt-get install -y unzip
6+
WORKDIR /app
7+
# Copy the zip file
8+
COPY target/Trimmomatic-${TRIMMOMATIC_VERSION}.zip trimmomatic.zip
9+
RUN unzip trimmomatic.zip
10+
11+
# --- Stage 2: Build the Final Image ---
12+
FROM eclipse-temurin:8-jre-focal
13+
# Re-declare ARG for this stage
14+
ARG TRIMMOMATIC_VERSION
15+
WORKDIR /opt/trimmomatic
16+
# Copy the jar file
17+
COPY --from=preparer /app/trimmomatic-${TRIMMOMATIC_VERSION}.jar trimmomatic.jar
18+
COPY --from=preparer /app/adapters ./adapters
19+
# MODIFIED: Specify the main class explicitly
20+
ENTRYPOINT ["java", "-cp", "trimmomatic.jar", "org.usadellab.trimmomatic.Trimmomatic"]
21+
CMD ["-version"]

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
</repositories>
5050

5151
<build>
52+
<resources>
53+
<resource>
54+
<directory>resources</directory>
55+
<filtering>true</filtering>
56+
</resource>
57+
</resources>
5258
<plugins>
5359
<plugin>
5460
<groupId>org.apache.maven.plugins</groupId>
@@ -76,6 +82,18 @@
7682
</execution>
7783
</executions>
7884
</plugin>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-jar-plugin</artifactId>
88+
<version>3.3.0</version>
89+
<configuration>
90+
<archive>
91+
<manifest>
92+
<mainClass>org.usadellab.trimmomatic.Trimmomatic</mainClass>
93+
</manifest>
94+
</archive>
95+
</configuration>
96+
</plugin>
7997
</plugins>
8098
</build>
8199
</project>

resources/version.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=${project.version}

0 commit comments

Comments
 (0)