ysubach / jersey-docker-demo Goto Github PK
View Code? Open in Web Editor NEWShows how to run Java RESTful API (based on Jersey framework) as a Docker container
Shows how to run Java RESTful API (based on Jersey framework) as a Docker container
I'm trying to containerize a new Maven/Jersey app with docker-compose.
My docker-compose.yml:
version: '2'
services:
maven:
build: ./maven
And my maven/Dockerfile:
# fetch basic image
FROM maven:3.3.9-jdk-8-alpine
# application placed into /opt/app
RUN mkdir -p /opt/app
WORKDIR /opt/app/
# selectively add the POM file and
# install dependencies
COPY api/pom.xml /opt/app/
RUN mvn install
# rest of the project
COPY api/src /opt/app/src
RUN mvn package
# local application port
EXPOSE 8080
# execute it
CMD ["mvn", "exec:java"]
api/ directory is my source application directory (as another git submodule).
But, when app is starting up, "docker-compose up" docker-compose process the script and "hit an enter" after docker maven is running, terminating the process. See the log:
maven_1 | [INFO] Scanning for projects...
maven_1 | [INFO]
maven_1 | [INFO] ------------------------------------------------------------------------
maven_1 | [INFO] Building jersey-docker-desafio 1.0-SNAPSHOT
maven_1 | [INFO] ------------------------------------------------------------------------
maven_1 | [INFO]
maven_1 | [INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ jersey-docker-desafio >>>
maven_1 | [INFO]
maven_1 | [INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ jersey-docker-desafio <<<
maven_1 | [INFO]
maven_1 | [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ jersey-docker-desafio ---
maven_1 | Jan 28, 2017 5:50:11 PM org.glassfish.grizzly.http.server.NetworkListener start
maven_1 | INFO: Started listener bound to [0.0.0.0:8080]
maven_1 | Jan 28, 2017 5:50:11 PM org.glassfish.grizzly.http.server.HttpServer start
maven_1 | INFO: [HttpServer] Started.
maven_1 | Jersey app started with WADL available at http://0.0.0.0:8080/desafio/application.wadl
maven_1 | Hit enter to stop it...
maven_1 | Jan 28, 2017 5:50:11 PM org.glassfish.grizzly.http.server.NetworkListener shutdownNow
maven_1 | INFO: Stopped listener bound to [0.0.0.0:8080]
maven_1 | [INFO] ------------------------------------------------------------------------
maven_1 | [INFO] BUILD SUCCESS
maven_1 | [INFO] ------------------------------------------------------------------------
maven_1 | [INFO] Total time: 3.594 s
maven_1 | [INFO] Finished at: 2017-01-28T17:50:11+00:00
maven_1 | [INFO] Final Memory: 10M/115M
maven_1 | [INFO] ------------------------------------------------------------------------
Pay attention to these log lines:
maven_1 | Jersey app started with WADL available at http://0.0.0.0:8080/desafio/application.wadl
maven_1 | Hit enter to stop it...
maven_1 | Jan 28, 2017 5:50:11 PM org.glassfish.grizzly.http.server.NetworkListener shutdownNow
maven_1 | INFO: Stopped listener bound to [0.0.0.0:8080]
Do you know how can I run the app without attaching the "input" from the terminal?
Something like an alternative to CMD in the Dockerfile ?
653MB
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.