Browse Source
invoke - docker build -f src/main/docker/Dockerfile.multistage -t quarkus-quickstart/getting-started .master
6 changed files with 79 additions and 11 deletions
@ -1,5 +0,0 @@
|
||||
* |
||||
!target/*-runner |
||||
!target/*-runner.jar |
||||
!target/lib/* |
||||
!target/quarkus-app/* |
||||
@ -0,0 +1,31 @@
|
||||
## Stage 1 : build with maven builder image with native capabilities |
||||
FROM quay.io/quarkus/centos-quarkus-maven:20.1.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 |
||||
|
||||
EXPOSE 8080 |
||||
USER 1001 |
||||
|
||||
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] |
||||
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,29 @@
|
||||
package org.acme.getting.started; |
||||
|
||||
import javax.inject.Inject; |
||||
import javax.ws.rs.GET; |
||||
import javax.ws.rs.Path; |
||||
import javax.ws.rs.Produces; |
||||
import javax.ws.rs.core.MediaType; |
||||
|
||||
import org.jboss.resteasy.annotations.jaxrs.PathParam; |
||||
|
||||
@Path("/hello") |
||||
public class GreetingResource { |
||||
|
||||
@Inject |
||||
GreetingService service; |
||||
|
||||
@GET |
||||
@Produces(MediaType.TEXT_PLAIN) |
||||
@Path("/greeting/{name}") |
||||
public String greeting(@PathParam String name) { |
||||
return service.greeting(name); |
||||
} |
||||
|
||||
@GET |
||||
@Produces(MediaType.TEXT_PLAIN) |
||||
public String hello() { |
||||
return "hello"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package org.acme.getting.started; |
||||
|
||||
import javax.enterprise.context.ApplicationScoped; |
||||
|
||||
@ApplicationScoped |
||||
public class GreetingService { |
||||
|
||||
public String greeting(String name) { |
||||
//return "Hey " + name;
|
||||
return "Hey " + name + ", You're an idiot"; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue