diff --git a/.gitignore b/.gitignore
index 549e00a..bc69d4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,9 @@ build/
### VS Code ###
.vscode/
+
+*.DS_Store
+
+*.class
+*.jar
+.DS_Store
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..75c973c
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,45 @@
+version: '3.8'
+services:
+ gateway:
+ build:
+ context: .
+ dockerfile: gateway/Dockerfile
+ image: shared-gateway
+ container_name: shareit-gateway
+ ports:
+ - "8080:8080"
+ depends_on:
+ - server
+ environment:
+ - SHAREIT_SERVER_URL=http://server:9090
+
+ server:
+ build:
+ context: .
+ dockerfile: server/Dockerfile
+ image: shared-server
+ container_name: shareit-server
+ expose:
+ - 9090
+ ports:
+ - "9090:9090"
+ depends_on:
+ - db
+ environment:
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/shareit
+ - SPRING_DATASOURCE_USERNAME=root
+ - SPRING_DATASOURCE_PASSWORD=root
+ - SPRING_JPA_HIBERNATE_DDL_AUTO=update
+ command: -p 9090
+
+ db:
+ image: postgres:13.7-alpine
+ container_name: database
+ ports:
+ - "6541:5432"
+ volumes:
+ - ./server/resources:/schema.sql
+ environment:
+ - POSTGRES_PASSWORD=root
+ - POSTGRES_USER=root
+ - POSTGRES_DB=shareit
\ No newline at end of file
diff --git a/gateway/Dockerfile b/gateway/Dockerfile
new file mode 100644
index 0000000..c20c6ca
--- /dev/null
+++ b/gateway/Dockerfile
@@ -0,0 +1,3 @@
+FROM amazoncorretto:11
+COPY gateway/target/*.jar app.jar
+ENTRYPOINT ["java","-jar","/app.jar"]
\ No newline at end of file
diff --git a/gateway/pom.xml b/gateway/pom.xml
new file mode 100644
index 0000000..14fe65e
--- /dev/null
+++ b/gateway/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+
+ ru.practicum
+ shareit
+ 0.0.1-SNAPSHOT
+
+
+ shareit-gateway
+ 0.0.1-SNAPSHOT
+
+ ShareIt Gateway
+
+
+ 11
+ 11
+ UTF-8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java
new file mode 100644
index 0000000..4cbc16c
--- /dev/null
+++ b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java
@@ -0,0 +1,12 @@
+package ru.practicum.shareit;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ShareItGateway {
+ public static void main(String[] args) {
+ SpringApplication.run(ShareItGateway.class, args);
+ }
+
+}
\ No newline at end of file
diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java b/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java
new file mode 100644
index 0000000..cef20bd
--- /dev/null
+++ b/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java
@@ -0,0 +1,66 @@
+package ru.practicum.shareit.booking;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.DefaultUriBuilderFactory;
+import ru.practicum.shareit.booking.dto.BookingShortDto;
+import ru.practicum.shareit.booking.dto.BookingState;
+import ru.practicum.shareit.client.BaseClient;
+
+import java.util.Map;
+
+@Service
+public class BookingClient extends BaseClient {
+ private static final String API_PREFIX = "/bookings";
+
+ @Autowired
+ public BookingClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) {
+ super(
+ builder
+ .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX))
+ .requestFactory(HttpComponentsClientHttpRequestFactory::new)
+ .build()
+ );
+ }
+
+ public ResponseEntity