hello-world-service/Instructions.md

210 lines
7.3 KiB
Markdown
Raw Permalink Normal View History

2024-05-23 12:00:42 +02:00
# Instructions
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
## Execution
2024-02-27 12:45:01 +01:00
start the docker container
2024-05-23 12:00:42 +02:00
```sh
cd dockerize && ./buildImageAndStart.sh -e
2024-05-23 12:00:42 +02:00
```
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
debug the docker container (read [### DEBUG] for details)
```sh
cd dockerize && ./buildImageAndStart.sh -d
2024-05-23 12:00:42 +02:00
```
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
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"
2024-05-23 12:00:42 +02:00
```
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
### Test URLs
obtain OAuth Access Token at https://next.dev.d4science.org/group/gcube/home
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
replace {{TOKEN}} with your token
2024-05-23 12:00:42 +02:00
```sh
TOKEN={{TOKEN}}
curl -l 'http://localhost:8080/helloworld/guest'
2024-05-23 12:00:42 +02:00
curl -l 'http://localhost:8080/helloworld/hello' -h 'Authorization: $TOKEN'
curl -l 'http://localhost:8080/helloworld/details' -h 'Authorization: $TOKEN'
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
curl -l 'http://localhost:8080/helloworld/auth/org_member' -h 'Authorization: $TOKEN'
curl -l 'http://localhost:8080/helloworld/auth/member' -h 'Authorization: $TOKEN'
```
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
```sh
curl -l 'http://localhost:8080/helloworld/gcube/resource/metrics'
curl -l 'http://localhost:8080/helloworld/gcube/resource/health'
```
2024-02-27 12:45:01 +01:00
2024-05-23 12:00:42 +02:00
### Debug
2024-02-27 12:45:01 +01:00
start the docker container in debug Mode
```cd dockerize && ./buildImageAndStartWithDebug.sh -d```
2024-02-27 12:45:01 +01:00
connect the JAVA debugger to port 5005
* VSCODE: press the green play button and start "Debug (Attach)
2024-05-23 12:00:42 +02:00
## 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
2024-05-23 16:59:48 +02:00
# 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
2024-05-23 12:00:42 +02:00
├── gcube
│   └── extra-resources
│   └── WEB-INF
# # defines the smartgear application configuration
│   └── application.yaml
|
# project sources
2024-05-27 10:45:10 +02:00
├── src
│   ├── main
│   │   ├── java
│   │   │   └── org
│   │   │   └── gcube
│   │   │   └── service
│   │   │   └── helloworld
│   │   │   ├── HelloWorldManager.java
│   │   │   ├── annotation
│   │   │   │   └── PURGE.java
│   │   │   ├── beans
│   │   │   │   └── ResponseBean.java
│   │   │   ├── health
2024-05-27 17:32:34 +02:00
│   │   │   │   ├── CreateTempFileCheck.java
│   │   │   │   └── EmptyCheck.java
2024-05-27 10:45:10 +02:00
│   │   │   ├── rest
│   │   │   │   ├── AuthenticatedService.java
│   │   │   │   ├── ExcludeAuthorizationService.java
│   │   │   │   ├── HelloService.java
│   │   │   │   └── ServiceExceptionMapper.java
│   │   │   ├── serializers
│   │   │   └── utils
│   │   │   └── RestUtils.java
│   │   ├── resources
│   │   │   └── META-INF
│   │   │   └── enunciate
│   │   │   └── d4science_docs.fmt
2024-05-27 17:32:34 +02:00
│   │   ├── 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
2024-05-27 10:45:10 +02:00
│   │   └── api-docs
│   │   └── css
│   │   └── d4science_enunciate_custom.css
2024-05-23 12:00:42 +02:00
│   └── test
2024-05-27 10:45:10 +02:00
│   ├── java
│   └── resources
2024-05-27 17:32:34 +02:00
2024-05-23 12:00:42 +02:00
# optional, for local develop in docker containers
2024-05-27 17:32:34 +02:00
├── 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
2024-05-23 12:00:42 +02:00
├── Dockerfile
# optional, sphinx configuration
├── sphinx
│   ├── Makefile
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   └── tests.rst
2024-05-27 17:32:34 +02:00
# optional, vscode debug configuration
├── .vscode
│   ├── launch.json
│   └── container.dev.ini
2024-05-23 12:00:42 +02:00
# 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
2024-05-23 12:00:42 +02:00
* dockerize/configuration/container.ini: configurations for the docker container.
2024-05-23 12:00:42 +02:00
* 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
2024-05-23 12:00:42 +02:00
* 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.