hello-world-service/Instructions.md

210 lines
7.3 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Instructions
## Execution
start the docker container
```sh
cd dockerize && ./buildImageAndStart.sh -e
```
debug the docker container (read [### DEBUG] for details)
```sh
cd dockerize && ./buildImageAndStart.sh -d
```
to compile and push to harbor registry with a custom container.ini file:
```sh
cd dockerize && ./buildImageAndStart.sh -r -m -l -c "./docker/container-XXX.ini"
```
### Test URLs
obtain OAuth Access Token at https://next.dev.d4science.org/group/gcube/home
replace {{TOKEN}} with your token
```sh
TOKEN={{TOKEN}}
curl -l 'http://localhost:8080/helloworld/guest'
curl -l 'http://localhost:8080/helloworld/hello' -h 'Authorization: $TOKEN'
curl -l 'http://localhost:8080/helloworld/details' -h 'Authorization: $TOKEN'
curl -l 'http://localhost:8080/helloworld/auth/org_member' -h 'Authorization: $TOKEN'
curl -l 'http://localhost:8080/helloworld/auth/member' -h 'Authorization: $TOKEN'
```
```sh
curl -l 'http://localhost:8080/helloworld/gcube/resource/metrics'
curl -l 'http://localhost:8080/helloworld/gcube/resource/health'
```
### Debug
start the docker container in debug Mode
```cd dockerize && ./buildImageAndStartWithDebug.sh -d```
connect the JAVA debugger to port 5005
* VSCODE: press the green play button and start "Debug (Attach)
## Project Structure
```sh
# gitignore configuration
│ .gitignore
# readme, license, instruction files
├── CHANGELOG.md
├── FUNDING.md
├── Instructions.md
├── LICENSE.md
├── README.md
│ 
# maven configuration for the project
├── pom.xml
# the files in the gcube folder are processed by mvn parent during the packing fase
# the variables ${VAR} are resolved using the values found in pom.xml
# and the generated file are copied (respecting the gcube folder structure) inside the folder generated in ./target and so in the corrisponding war file
├── gcube
│   └── extra-resources
│   └── WEB-INF
# # defines the smartgear application configuration
│   └── application.yaml
|
# project sources
├── src
│   ├── main
│   │   ├── java
│   │   │   └── org
│   │   │   └── gcube
│   │   │   └── service
│   │   │   └── helloworld
│   │   │   ├── HelloWorldManager.java
│   │   │   ├── annotation
│   │   │   │   └── PURGE.java
│   │   │   ├── beans
│   │   │   │   └── ResponseBean.java
│   │   │   ├── health
│   │   │   │   ├── CreateTempFileCheck.java
│   │   │   │   └── EmptyCheck.java
│   │   │   ├── rest
│   │   │   │   ├── AuthenticatedService.java
│   │   │   │   ├── ExcludeAuthorizationService.java
│   │   │   │   ├── HelloService.java
│   │   │   │   └── ServiceExceptionMapper.java
│   │   │   ├── serializers
│   │   │   └── utils
│   │   │   └── RestUtils.java
│   │   ├── resources
│   │   │   └── META-INF
│   │   │   └── enunciate
│   │   │   └── d4science_docs.fmt
│   │   ├── webapp
# #  # # WEB-INF resources are accessible to the resource loader of your Web-Application
# # # # and not served directly to a client by the container
│   │   │ ├── WEB-INF
# # # # # deployment descriptor
│   │   │ │   └── web.xml
│   │   │   └── api-docs
│   │   │   └── css
│   │   │   └── d4science_enunciate_custom.css
│   │   └── webapp copy
│   │   └── api-docs
│   │   └── css
│   │   └── d4science_enunciate_custom.css
│   └── test
│   ├── java
│   └── resources
# optional, for local develop in docker containers
├── dockerize
│   ├── buildImageAndStart.sh
│   ├── build_conf
│   ├── configuration
│   │   ├── .gitignore
│   │   ├── container.default.ini
│   │   ├── container.ini -> container.xxx.ini
│   │   ├── devsec.gcubekey
│   │   └── logback.xml
│   ├── docker.conf
│   ├── loginHarborHub.sh
│   ├── pull_docker.sh
│   ├── push_docker.sh
│   ├── start_docker.sh
│   └── stop_docker.sh
# documentation config
├── documentation
# # postman collections to test the API
│   ├── postman
│   │   ├── Hello World Env for devVRE.postman_environment.json
│   │   └── Hello World Service.postman_collection.json
│ │
# # enunciate configuration
│   ├── enunciate.xml
│ │
# # sphinx configuration
│   └── sphinx
│   ├── Makefile
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   └── tests.rst
# Docker file
├── Dockerfile
# optional, sphinx configuration
├── sphinx
│   ├── Makefile
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   └── tests.rst
# optional, vscode debug configuration
├── .vscode
│   ├── launch.json
│   └── container.dev.ini
# optional, enunciate configuration
├── enunciate.xml
# project documentation
├── documentation
│   ├── dockerizing.md
│ │
# # postman collections to test the API
│   └── postman
│   ├── gcube-devsec-devVRE.postman_environment.json
│   └── Smartgears4 helloword.postman_collection.json
# the output of maven package
└── target
```
### file details
* gitignore: gitignore file for java projects
* pom.xml
* <parent>: maven-parent configuration. currently 1.2.0 version
* <properties><webappDirectory> : path for web.xml
* <scm> ???
* <dependencyManagement> gcube dependency manager
* dockerize/configuration folder: folder with the configurations for the exevution of the application. are copied in the docker container during building
* dockerize/configuration/container.ini: configurations for the docker container.
* create your own configuration copying an existing template
* the default execution uses dockerize/configuration/container.ini, it can be a simlink to a custom config
* gitignore ignores all container*.ini files in the folder excepting container.default.ini
*
* mode: [online/offline]: register the service on IS. use offline for local docker instances
* gcube folder: the files in the gcube folder are processed by maven-parent, the variables ${VAR} ara resolved using the values found in pom.xml and the generated file are put in the target folder and in the war file.