|
| 1 | +# Todolist Helidon backend |
| 2 | + |
| 3 | +Todolist application backend built with Helidon SE, using Oracle JDBC |
| 4 | +- __App Version `v2.1.0`__ |
| 5 | +- __Oracle JDBC Version `v23.4.0.24.05`__ |
| 6 | +- __Helidon SE Version `v2.4.2`__ |
| 7 | + |
| 8 | +## Environment Variables |
| 9 | +The following environment variables are expected by the application. |
| 10 | +In order to successfully run the application, the environment variables below are __REQUIRED__. |
| 11 | + |
| 12 | +| Variable | Name | Default | Description | |
| 13 | +|---------------------|-------------------|---------|-----------------------------------------------------------------| |
| 14 | +| `database.url` | Database URL | - | Connection to URL, in the form of `jdbc:oracle:thin:@<details>` | |
| 15 | +| `database.user` | Database User | - | Database user with access to the necessary tables | |
| 16 | +| `database.password` | Database Password | - | Database user credentials | |
| 17 | + |
| 18 | +## API Endpoints |
| 19 | + |
| 20 | +The following endpoints are endpoints used by the application. |
| 21 | + |
| 22 | +| Method | REST Endpoint | Sample Data | Description | |
| 23 | +|--------|-------------------------------------------|----------------------------------------|-----------------------| |
| 24 | +| GET | `http://localhost:8080/api/todolist` | - | Retrieves all Todos | |
| 25 | +| POST | `http://localhost:8080/api/todolist` | `{"description" : "Second new task!"}` | Saves a new Todo | |
| 26 | +| GET | `http://localhost:8080/api/todolist/{id}` | - | Retrieves a Todo item | |
| 27 | +| PUT | `http://localhost:8080/api/todolist/{id}` | `{"description": "...", "done": true}` | Updates a Todo item | |
| 28 | +| DELETE | `http://localhost:8080/api/todolist/{id}` | - | Deletes a Todo item | |
| 29 | + |
| 30 | + |
| 31 | +## SQL Schema, Tables and Queries |
| 32 | + |
| 33 | +The application expects and makes use of the following: |
| 34 | + |
| 35 | +- __Database Schemas__: `TODOOWNER` |
| 36 | +- __Database Tables__: `TODOITEM` |
| 37 | +- __Database Queries and Privilege__: |
| 38 | + - `select, insert, update, delete` on `TODOOWNER.TODOITEM` |
| 39 | + |
| 40 | + |
| 41 | +# Building the Application |
| 42 | +The application uses Maven to build and manage the project with its dependencies. |
| 43 | +Since the [Dockerfile](./src/main/docker/Dockerfile) expects the JAR, you need to run mvn first. |
| 44 | +```bash |
| 45 | +mvn clean package |
| 46 | +``` |
| 47 | + |
| 48 | +When building for docker, you can use the following command: |
| 49 | +```bash |
| 50 | +docker build -f src/main/docker/Dockerfile -t <image> . |
| 51 | +``` |
| 52 | + |
| 53 | +# Deploying to Kubernetes |
| 54 | +To deploy the application on Kubernetes, |
| 55 | +the environment variables and image must be replaced. |
| 56 | + |
| 57 | +For example, you can create the following manifest.yaml file: |
| 58 | +```yaml |
| 59 | +# manifest |
| 60 | +apiVersion: apps/v1 |
| 61 | +kind: Deployment |
| 62 | +metadata: |
| 63 | + name: backend-deployment |
| 64 | + labels: |
| 65 | + app: backendapp |
| 66 | +spec: |
| 67 | + replicas: 1 |
| 68 | + selector: |
| 69 | + matchLabels: |
| 70 | + app: backendapp |
| 71 | + template: |
| 72 | + metadata: |
| 73 | + labels: |
| 74 | + app: backendapp |
| 75 | + spec: |
| 76 | + containers: |
| 77 | + - name: app |
| 78 | + image: example:v1 # update with your container image |
| 79 | + env: |
| 80 | + - name: database.user |
| 81 | + value: myUser # update with your database user |
| 82 | + - name: database.url |
| 83 | + value: "jdbc:oracle:thin:@<details>" # update with your database URL |
| 84 | + - name: database.password |
| 85 | + valueFrom: |
| 86 | + secretKeyRef: |
| 87 | + name: myDatabasePWDSecret # update with your database secret |
| 88 | + key: password |
| 89 | + ports: |
| 90 | + - containerPort: 8080 |
| 91 | + |
| 92 | + # if database wallet is required |
| 93 | + volumeMounts: |
| 94 | + - name: creds |
| 95 | + mountPath: /app/creds # update with the right path to the wallet |
| 96 | + # end if |
| 97 | + |
| 98 | + restartPolicy: Always |
| 99 | + |
| 100 | + # if database wallet is required |
| 101 | + volumes: |
| 102 | + - name: creds |
| 103 | + secret: |
| 104 | + secretName: db-wallet-secret # update with the actual secret |
| 105 | + # end if |
| 106 | + |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +apiVersion: v1 |
| 111 | +kind: Service |
| 112 | +metadata: |
| 113 | + name: backend-service |
| 114 | +spec: |
| 115 | + type: ClusterIP |
| 116 | + ports: |
| 117 | + - port: 8080 |
| 118 | + targetPort: 8080 |
| 119 | + selector: |
| 120 | + app: backendapp |
| 121 | +``` |
| 122 | +
|
| 123 | +This configuration requires the following secret to be created: |
| 124 | +```bash |
| 125 | +kubectl create secret generic myDatabasePWDSecret --from-literal=password=<value> |
| 126 | +``` |
| 127 | + |
| 128 | +If a wallet is necessary, you can run the following command to create the wallet secret |
| 129 | +```bash |
| 130 | +kubectl create secret generic wallet --from-file=<wallet_location> |
| 131 | +``` |
0 commit comments