Package Exports
- generator-jhipster-docker
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (generator-jhipster-docker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
generator-jhipster-docker
JHipster module, additional Docker support in your JHipster application
Introduction
This is a JHipster module, that is meant to be used in a JHipster application. This module is used to :
- Generate Dockerfile for Automated build at Docker Hub
- Generate additional docker-compose services
- Change the default Dockerfile
Table of contents
Prerequisites
As this is a JHipster module, we expect you have JHipster and its related tools already installed:
You have to install Docker and Docker Compose:
To use Automated build, you have to create an account at:
Installation
To install this module:
npm install -g generator-jhipster-docker
To update this module:
npm update -g generator-jhipster-docker
Usage
To run the module on a JHipster generated application:
yo jhipster-docker
You can use this command to generate the Dockerfile for Automated build with default options:
yo jhipster-docker default
To force the generator:
yo jhipster-docker default --force
1 - Automated build at the Docker Hub
1.1 - Description
When using the option Generate Dockerfile for Automated build, Docker Hub will build a Docker image everytime you commit to your repository.
1.2 - Generate the files
- Launch :
yo jhipster-docker
- Select the option :
Generate Dockerfile for Automated build at https://hub.docker.com/
- Answer the question:
- Put your Docker Hub ID
1.3 - Set your Docker Hub project
At GitHub
- Go to settings > Webhooks & services
- Verify the services: Docker => edit
- Click [x] active
- Click on update service
- Then, the next time you make a commit+push, the service Docker must be ✅ Docker
At Docker Hub
Go to https://hub.docker.com/r/username/ (replace username by yours)
Menu Create:
- Select Create Automated Build
- Select the repository
- Put a description, then click on create
Go to Build Settings
- Choose your branch or let master by default
- Put this Dockerfile location: /
- Click on Save Changes
Return to this project: git commit and push these changes!
Go to Build details: it should be a new line with Building
2 - Generate additional docker-compose services
2.1 - MailDev
The project djfarrelly/maildev is a simple way to test your project’s generated emails during development with an easy to use web interface.
You can launch: docker-compose -f src/main/docker/smtp.yml up
You can access to it: http://localhost:1080
3 - Change the default Dockerfile
3.1 - Description
On a generated project with JHipster, the file src/main/docker/Dockerfile is used to build a Docker image for running the JHipster application. This default image used java:openjdk-8-jre-alpine as base image.
This option proposed to use tomcat:8.0.36-jre8-alpine instead.
With maven: ./mvnw clean package -Pprod docker:build
With gradle: ./gradlew clean bootRepackage -Pprod buildDocker
You can read this documentation for more details: spring-boot-docker
3.2 - Examples
Default option
- Use this
.yo-rc.json
to generate your JHipster application (all options are default):
{
"generator-jhipster": {
"jhipsterVersion": "3.6.1",
"baseName": "jhipster",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": "no",
"buildTool": "maven",
"enableSocialSignIn": false,
"rememberMeKey": "7a8b2edfaf2353b83e9fe934a9a60e1a7992f399",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
]
}
}
- Launch :
yo jhipster-docker
- Select the option :
Change the default Dockerfile
- Select:
tomcat:8.0.36-jre8-alpine
- Type:
jhipster
- Type
a
to resolve all conflicts - Build the new docker image:
./mvnw clean package -Pdev docker:build
- Start the docker image:
docker run --rm -p 8080:8080 jhipster
- Go to tomcat (tomcat/JH!pst3r): http://localhost:8080
- Go to the application: http://localhost:8080/jhipster
You can define or override other spring boot, using environment variables
License
Apache-2.0 © Pascal Grimaud and the respective JHipster contributors