diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8819946 --- /dev/null +++ b/.env.example @@ -0,0 +1,27 @@ +SPRING_PORT=8080 +SPRING_DB_URL=jdbc:mysql://mysql-db:3306/dashnetdb +SPRING_DB_USERNAME=root +SPRING_DB_PASSWORD=thispasswordisnotsafe +SPRING_REPLICAS=1 + +spring-jpa-ddl-auto=update +spring-sql-init-platform=mysql +spring-sql-dialect=org.hibernate.dialect.MySQLDialect + +MYSQL_PORT=3306 +MYSQL_PASSWORD=thispasswordisnotsafe +MYSQL_ROOT_PASSWORD=thispasswordisnotsafe +MYSQL_DB_NAME=dashnetdb +MYSQL_REPLICAS=1 + +PMA_HOST=mysql-db +PMA_DB_PORT=3306 +PMA_ARBITRARY=1 +PMA_REPLICAS=1 +PMA_PORT=8081 + +NODE_PORT=3000 +NODE_REPLICAS=1 + +SWAGGER_EDITOR_PORT=81 +SWAGGER_UI_PORT=82 diff --git a/.gitignore b/.gitignore index ee1138b..1f94aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,6 @@ build/ node_modules/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +.env \ No newline at end of file diff --git a/README.md b/README.md index e413700..746b6bc 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,25 @@ WELCOME ## Getting Started +REQUIREMENT: + [DOCKER](https://www.docker.com/products/docker-desktop/) + ### Using docker compose: #### Basic use +QA: + IN TERMINAL RUN FOLLOWING COMMAND + +```bash +docker compose --profile QA up -d --build +``` + +WHEN DONE TURN OFF SERVICES + +```bash +docker compose --profile QA DOWN +``` + To start all services use `default` profile ```bash @@ -40,11 +56,14 @@ docker compose --profile no-admin up -d --build # to run all services except php Profiles:
Run all services: `default`
+Run only services necessary for testing: `QA`
React front-end: `react`
MySQL: `mysql`
Spring + MySQL: `spring-mysql`
phpMyA + MySQL: `admin-mysql`
Spring + phpMyA + MySQL: `spr-mysql-adm`
+Spring + Swagger + MySQL: `'swg-spr-mysql'`
+Spring + Swagger + phpMyA + MySQL: `'swg-spr-adm-mysql'`
default but w/o myPHPAdmin: `no-admin`
#### Restart service @@ -82,4 +101,15 @@ Or w/ GUI you can go to: ## API documentation -Create [Swagger](https://swagger.io/) +In CLI start services profile `swg-spr-mysql` : + +```bash +docker compose --profile swg-spr-mysql up -d --build +``` + +THEN in browser open following links:
+
+To read and use API documentation: [SWAGGER UI](http//localhost:81)
+To edit API documentation: [SWAGGER__EDITOR](http//localhost:82) + +OR open local [swagger.yml](swagger.yml) file: \ No newline at end of file diff --git a/dashNet-swagger.yaml b/dashNet-swagger.yaml new file mode 100644 index 0000000..7f44f0e --- /dev/null +++ b/dashNet-swagger.yaml @@ -0,0 +1,157 @@ +openapi: 3.0.3 +info: + title: DashNET + description: DashNET modern project management dashboard + termsOfService: http://swagger.io/terms/ + contact: + email: info@dashnet.com + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: 1.0.0_beta +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: + - url: https://localhost:8081 +tags: + - name: Task + description: Everything about TASKS +paths: + /tasks: + get: + summary: Retrieve all users + description: Retrieves a list of all users in the system + responses: + '200': + description: A list of users + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + type: object + properties: + id: + type: integer + description: The unique identifier for the task + creatorId: + type: integer + description: The ID of the task creator + assigneeId: + type: integer + description: The ID of the task assignee + teamId: + type: integer + description: The ID of the team the task belongs to + commentTbId: + type: integer + description: The ID of the comment thread associated with the task + status: + type: integer + description: The status of the task + createdDate: + type: string + format: date + description: The date the task was created + deadlineDate: + type: string + format: date + description: The deadline date for the task + title: + type: string + description: The title of the task + description: + type: string + description: The description of the task + + /tasks/title/{titleName}: + get: + summary: Get tasks by title + description: Retrieves tasks matching the provided title (using 'like' SQL operator) + parameters: + - name: titleName + in: path + required: true + schema: + type: string + description: The title to search for + responses: + '200': + description: Tasks matching the title + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/Task' + '404': + description: Tasks not found + + /tasks/description/{description}: + get: + summary: Get tasks by description + description: Retrieves tasks matching the provided description (using 'like' SQL operator) + parameters: + - name: description + in: path + required: true + schema: + type: string + description: The description to search for + responses: + '200': + description: Tasks matching the description + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/Task' + '404': + description: Tasks not found + + /tasks/count: + get: + summary: Get task count + description: Retrieves counts of different task statuses + responses: + '200': + description: Counts of different task statuses + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + todo: + type: integer + description: Count of tasks to do + total: + type: integer + description: Total count of tasks + inProgress: + type: integer + description: Count of tasks in progress + notStarted: + type: integer + description: Count of tasks not started + done: + type: integer + description: Count of tasks done + status: + type: integer + description: Response status + '404': + description: Counts not found diff --git a/docker-compose.yml b/docker-compose.yml index f564b72..d6ff7cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,9 +6,12 @@ services: container_name: dashNet-spring platform: linux profiles: + - 'QA' - 'no-admin' - 'spring-mysql' - 'spr-mysql-adm' + - 'swg-spr-mysql' + - 'swg-spr-adm-mysql' - 'default' build: context: . @@ -16,9 +19,9 @@ services: restart: on-failure deploy: mode: replicated - replicas: 1 + replicas: ${SPRING_REPLICAS} ports: - - 8080:8080 + - ${SPRING_PORT}:8080 volumes: - .:/app networks: @@ -26,13 +29,14 @@ services: depends_on: - mysql-db environment: - - SPRING_DATASOURCE_URL=jdbc:mysql://mysql-db:3306/dashnetdb - - SPRING_DATASOURCE_USERNAME=root - - SPRING_DATASOURCE_PASSWORD=thispasswordisnotsafe + - SPRING_DATASOURCE_URL=${SPRING_DB_URL} + - SPRING_DATASOURCE_USERNAME=${SPRING_DB_USERNAME} + - SPRING_DATASOURCE_PASSWORD=${SPRING_DB_PASSWORD} nodejs-fe: container_name: dashNet-react-fe profiles: + - 'QA' - 'react' - 'no-admin' - 'default' @@ -43,11 +47,11 @@ services: networks: - dash-net ports: - - 3000:3000 + - ${NODE_PORT}:3000 restart: always deploy: mode: replicated - replicas: 1 + replicas: ${NODE_REPLICAS} volumes: - ./src/main/ui/:/usr/src/app/ @@ -57,28 +61,29 @@ services: dockerfile: MySql.Dockerfile container_name: dashNet-mysql profiles: + - 'QA' - 'mysql' - 'no-admin' - 'spring-mysql' - 'admin-mysql' - 'spr-mysql-adm' + - 'swg-spr-mysql' + - 'swg-spr-adm-mysql' - 'default' image: dashnet-mysql-image command: --default-authentication-plugin=mysql_native_password restart: always deploy: mode: replicated - replicas: 1 + replicas: ${MYSQL_REPLICAS} ports: - - 3306:3306 - expose: - - 3306 + - ${MYSQL_PORT}:3306 environment: - MYSQL_PASSWORD: "thispasswordisnotsafe" - MYSQL_ROOT_PASSWORD: "thispasswordisnotsafe" - MYSQL_DATABASE: "dashnetdb" + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DB_NAME} volumes: - - "dashnet-mysql:/var/lib/mysql" + - 'dashnet-mysql:/var/lib/mysql' networks: - dash-net @@ -89,19 +94,54 @@ services: - 'phpadmin' - 'admin-mysql' - 'spr-mysql-adm' + - 'swg-spr-adm-mysql' - 'default' links: - mysql-db environment: - PMA_HOST: mysql-db - PMA_PORT: 3306 - PMA_ARBITRARY: 1 + PMA_HOST: ${PMA_HOST} + PMA_PORT: ${PMA_DB_PORT} + PMA_ARBITRARY: ${PMA_ARBITRARY} restart: always deploy: mode: replicated - replicas: 1 + replicas: ${PMA_REPLICAS} ports: - - 8081:80 + - ${PMA_PORT}:80 + networks: + - dash-net + + swagger-editor: + image: swaggerapi/swagger-editor + container_name: 'swagger-editor-container' + ports: + - ${SWAGGER_EDITOR_PORT}:8080 + profiles: + - 'swagger' + - 'swg-spr-mysql' + - 'swg-spr-adm-mysql' + - 'default' + volumes: + - 'dashnet-swagger:/dashNet-swagger.yaml' + environment: + SWAGGER_FILE: ./dashNet-swagger.yaml + networks: + - dash-net + + swagger-ui: + image: swaggerapi/swagger-ui + container_name: 'swagger-ui-container' + profiles: + - 'swagger' + - 'swg-spr-mysql' + - 'swg-spr-adm-mysql' + - 'default' + ports: + - ${SWAGGER_UI_PORT}:8080 + volumes: + - 'dashnet-swagger:/dashNet-swagger.yaml' + environment: + SWAGGER_JSON: /dashNet-swagger.yaml networks: - dash-net @@ -109,4 +149,5 @@ networks: dash-net: { } volumes: - dashnet-mysql: \ No newline at end of file + dashnet-mysql: + dashnet-swagger: \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a604607..efcf3b2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,11 +1,13 @@ +spring.config.import=optional:file:.env + # Datasource connection -spring.sql.init.platform=mysql +spring.sql.init.platform=${spring-sql-init-platform} spring.sql.init.mode=always -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect +spring.jpa.properties.hibernate.dialect=${spring-sql-dialect} spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # Hibernate -spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.ddl-auto=${spring-jpa-ddl-auto} spring.jpa.show-sql: true # Logging