Commit c65d5a03 authored by cnguyen2's avatar cnguyen2
Browse files

Add quarkus-container-image-docker and update dependency

parent cde8ece5
*
!data/*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
......@@ -8,11 +8,11 @@ variables:
build native:
stage: build
image: quay.io/quarkus/centos-quarkus-maven:20.3-java11
image: quay.io/quarkus/centos-quarkus-maven:21.0.0-java11
only:
- master
script:
- mvn -f $CI_PROJECT_DIR/pom.xml clean package -P native
- mvn -f $CI_PROJECT_DIR/pom.xml clean package -Pnative -Dquarkus.container-image.build=false
artifacts:
paths:
- $CI_PROJECT_DIR/target/*-runner
......
# Gene Info Service for the iBeetleBase project
This microservice is based on Quarkus (version 1.4.2).
It can be used for querying gene information in JSON format.
Currently, it holds gene information for Tribolium castaneum and Drosophila melanogaster.
# Gene Info Service for the iBeetle-Base project
## Running the application in dev mode
The easiest way to use the application is by starting it in dev mode:
```
./mvnw quarkus:dev
```
## Querying the Service
Once the service is running, gene information can be queried using cURL like this:
```
curl -X GET "http://localhost:8080/geneinfo/current/v1/DATABASE/ID"
```
where DATABASE is either `tribolium` or `flybase` and ID is the gene identifier.
Gene identifiers can be in TC format (e.g. `TC016101`) or in FBgn format (e.g. `FBgn0010400`).
Replacing ID with `identifiers` returns a list of all gene IDs for the specific database.
## Packaging and containerizing
The application can be packaged and containerized by one command (docker required)
Multiple genes can be queried with comma-separated requests:
```
curl -X GET "http://localhost:8080/geneinfo/current/v1/id?=TC016101,TC016102,FBgn10400"
./mvnw package
```
## Packaging and running the application
The application can be packaged using `./mvnw package`.
It produces the `geneinfoservice_new-1.0-SNAPSHOT-runner.jar` file in the `/target` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory.
The application is now runnable using `java -jar target/geneinfoservice_new-1.0-SNAPSHOT-runner.jar`.
## Creating a native executable
You can create a native executable using: `./mvnw package -Pnative`.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`.
You can then execute your native executable with: `./target/geneinfoservice_new-1.0-SNAPSHOT-runner`
If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image.
......@@ -12,10 +12,10 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.12.0.Final</quarkus-plugin.version>
<quarkus-plugin.version>1.13.7.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.12.0.Final</quarkus.platform.version>
<quarkus.platform.version>1.13.7.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
......@@ -52,6 +52,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the docker image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t ibb/api/geneinfoservice-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 ibb/api/geneinfoservice-jvm
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.5
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
......@@ -33,16 +15,17 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
COPY data/* /deployments/data/
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
\ No newline at end of file
ENTRYPOINT [ "/deployments/run-java.sh" ]
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:20.2.0-java11 AS build
COPY pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml -B de.qaware.maven:go-offline-maven-plugin:1.2.5:resolve-dependencies
COPY src /usr/src/app/src
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
COPY data/* /work/data/
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
#
# Before building the docker image run:
#
# mvn package -Pnative -Dquarkus.native.container-build=true
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native -t ibb/api/geneinfoservice .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 ibb/api/geneinfoservice
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
WORKDIR /work/
COPY target/*-runner /work/application
#COPY data/* /work/data/
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
......
......@@ -2,151 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GeneinfoService - 1.0-SNAPSHOT</title>
<style>
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.5rem;
font-weight: 400;
line-height: 1.5;
}
h1 {
font-size: 2.5rem;
}
h2 {
font-size: 2rem
}
h3 {
font-size: 1.75rem
}
h4 {
font-size: 1.5rem
}
h5 {
font-size: 1.25rem
}
h6 {
font-size: 1rem
}
.lead {
font-weight: 300;
font-size: 2rem;
}
.banner {
font-size: 2.7rem;
margin: 0;
padding: 2rem 1rem;
background-color: #00A1E2;
color: white;
}
body {
margin: 0;
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
code {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 87.5%;
color: #e83e8c;
word-break: break-word;
}
.left-column {
padding: .75rem;
max-width: 75%;
min-width: 55%;
}
.right-column {
padding: .75rem;
max-width: 25%;
}
.container {
display: flex;
width: 100%;
}
li {
margin: 0.75rem;
}
.right-section {
margin-left: 1rem;
padding-left: 0.5rem;
}
.right-section h3 {
padding-top: 0;
font-weight: 200;
}
.right-section ul {
border-left: 0.3rem solid #00A1E2;
list-style-type: none;
padding-left: 0;
}
</style>
<title>Geneinfo Service</title>
</head>
<body>
<div class="banner lead">
Your new Cloud-Native application is ready!
</div>
<div class="container">
<div class="left-column">
<p class="lead"> Congratulations, you have created a new Quarkus application.</p>
<h2>Why do you see this?</h2>
<p>This page is served by Quarkus. The source is in
<code>src/main/resources/META-INF/resources/index.html</code>.</p>
<h2>What can I do from here?</h2>
<p>If not already done, run the application in <em>dev mode</em> using: <code>mvn compile quarkus:dev</code>.
</p>
<ul>
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/application.properties</code>.
</li>
</ul>
<h2>How do I get rid of this page?</h2>
<p>Just delete the <code>src/main/resources/META-INF/resources/index.html</code> file.</p>
</div>
<div class="right-column">
<div class="right-section">
<h3>Application</h3>
<ul>
<li>GroupId: org.de.unigoettingen.ibeetlebase.api</li>
<li>ArtifactId: GeneinfoService</li>
<li>Version: 1.0-SNAPSHOT</li>
<li>Quarkus Version: 1.3.2.Final</li>
</ul>
</div>
<div class="right-section">
<h3>Next steps</h3>
<ul>
<li><a href="https://quarkus.io/guides/maven-tooling.html" target="_blank">Setup your IDE</a></li>
<li><a href="https://quarkus.io/guides/getting-started.html" target="_blank">Getting started</a></li>
<li><a href="https://quarkus.io" target="_blank">Quarkus Web Site</a></li>
</ul>
</div>
</div>
</div>
<a href="q/swagger-ui">Swagger UI</a>
</body>
</html>
\ No newline at end of file
......@@ -5,13 +5,20 @@ quarkus.http.cors=true
quarkus.http.root-path=/ibb/api/geneinfo/v1
quarkus.swagger-ui.always-include=true
data.drosophila.gene.tsv=/data/fbgn_fbtr_fbpp_expanded_fb_2020_02.tsv
data.drosophila.gene.tsv=/data/fbgn_fbtr_fbpp_expanded_fb_2020_02.tsv.gz
data.tribolium.gene.gff=/data/OGS3.gff.gz
data.tribolium.cds.fasta=/data/OGS3_CDS.fasta.gz
data.tribolium.mrna.fasta=/data/OGS3_mRNA.fasta.gz
data.tribolium.protein.fasta=/data/OGS3_proteins.fasta.gz
%dev.data.drosophila.gene.tsv=../sample_data/drosophila.gene.tsv
quarkus.container-image.group=ibb/api
quarkus.container-image.name=geneinfoservice
quarkus.container-image.tag=latest
quarkus.container-image.registry=docker.gitlab.gwdg.de
quarkus.container-image.build=true
%dev.quarkus.http.root-path=/
%dev.data.drosophila.gene.tsv=../sample_data/drosophila.gene.tsv.gz
%dev.data.tribolium.gene.gff=../sample_data/tribolium.gene.gff.gz
%dev.data.tribolium.cds.fasta=../sample_data/tribolium.cds.fasta.gz
%dev.data.tribolium.mrna.fasta=../sample_data/tribolium.mrna.fasta.gz
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment