Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BASEPROJECT_DATABASE_HOST=postgres
BASEPROJECT_DATABASE_PORT=5434
BASEPROJECT_DATABASE_NAME=mynewdatabase
BASEPROJECT_DATABASE_USERNAME=postgres
BASEPROJECT_DATABASE_PASSWORD=root
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM bellsoft/liberica-openjdk-alpine:22 AS builder
WORKDIR /application
COPY . .
RUN --mount=type=cache,target=/root/.m2 chmod +x mvnw && ./mvnw clean install -Dmaven.test.skip

FROM bellsoft/liberica-openjre-alpine:22 AS layers
WORKDIR /application
COPY --from=builder /application/target/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract

FROM bellsoft/liberica-openjre-alpine:22
VOLUME /tmp
RUN adduser -S spring-user
USER spring-user
COPY --from=layers /application/dependencies/ ./
COPY --from=layers /application/spring-boot-loader/ ./
COPY --from=layers /application/snapshot-dependencies/ ./
COPY --from=layers /application/application/ ./

ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Практическое задание 1 # Spring ToDo

Создайте простое RESTful API веб-сервиса с использованием Spring Boot. Должно быть разработано TODO приложение, которое позволяет вести список дел
Создайте простое RESTful API веб-сервиса с использованием Spring Boot. Должно быть разработано TODO приложение,
которое позволяет вести список дел

**Описание:**<br>
- [x] В качестве БД используйте PostgreSQL<br>
Expand All @@ -18,3 +19,22 @@
3. После выполнения работы открыть Pull Request в master **!!!СВОЕГО РЕПОЗИТОРИЯ!!!**
4. Назначить ментора ревьювером
5. Отправить ссылку на PR в тг чат ментору

------------------------------------------------------------------------------------------------

Swagger находится по адресу - http://localhost:8081/swagger-ui/index.html#
PgAdmin находится по адресу - http://localhost:5050/, логин admin@admin.com, пароль root

Для того, чтобы поднять проект в докере(редис, пгадмин, приложение, БД), необходимо установить переменные среды на ПК, в
*Переменных среды для пользователя <имя пользователя>*

* Имя переменной: `BASEPROJECT_DATABASE_USERNAME`
Значение: `postgres`
* Имя переменной: `BASEPROJECT_DATABASE_PASSWORD`
Значение `root`
* Имя переменной: `BASEPROJECT_DATABASE_PORT`
Значение: `5434`(если порт свободен)
* Имя переменной: `BASEPROJECT_DATABASE_NAME`
Значение: `mynewdatabase`
* Имя переменной: `BASEPROJECT_DATABASE_HOST`
Значение: `localhost`
64 changes: 64 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
services:
postgres:
image: postgres:17.2
restart: "no"
ports:
- "5434:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${BASEPROJECT_DATABASE_USERNAME}
POSTGRES_PASSWORD: ${BASEPROJECT_DATABASE_PASSWORD}
POSTGRES_DB: ${BASEPROJECT_DATABASE_NAME}
healthcheck:
test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
interval: 10s
timeout: 5s
start_period: 10s
retries: 5

pgadmin:
image: dpage/pgadmin4:latest
restart: "no"
depends_on:
- postgres
ports:
- "5050:80" # внешний порт 5050 -> внутренний 80 (интерфейс pgAdmin)
environment:
PGADMIN_DEFAULT_EMAIL: "admin@admin.com" # любой логин
PGADMIN_DEFAULT_PASSWORD: "root" # любой пароль

spring-to-do:
image: spring-to-do:latest
build:
context: .
args:
DOCKER_BUILDKIT: 1
restart: "no"
ports:
- "8081:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/mynewdatabase
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: root
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
depends_on:
- postgres
- redis
redis:
image: redis:7.4.2
restart: "no"
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
start_period: 10s
retries: 5
volumes:
postgres_data:
redis_data:
56 changes: 55 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,75 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>3.4.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-core -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.31.0</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>3.4.2</version>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/emobile/springtodo/config/OpenApiConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.emobile.springtodo.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;

@OpenAPIDefinition(info = @Info(
title = "TO-DO List",
description = "TO-DO List System",
version = "1.0.0",
contact = @Contact(
name = "Sirik Vadim"
)
))
class OpenApiConfig {
}
Loading