-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Nasruddin/feature/elastic-search
Cleaning up
- Loading branch information
Showing
29 changed files
with
414 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#stage 1 | ||
#Start with a base image containing Java runtime | ||
FROM openjdk:11-slim as build | ||
|
||
# Add Maintainer Info | ||
LABEL maintainer="Nasruddin <[email protected]>" | ||
|
||
# The application's jar file | ||
ARG JAR_FILE | ||
|
||
# Add the application's jar to the container | ||
COPY ${JAR_FILE} app.jar | ||
|
||
#unpackage jar file | ||
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf /app.jar) | ||
|
||
#stage 2 | ||
#Same Java runtime | ||
FROM openjdk:11-slim | ||
|
||
#Add volume pointing to /tmp | ||
VOLUME /tmp | ||
|
||
#Copy unpackaged application to new container | ||
ARG DEPENDENCY=/target/dependency | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib | ||
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app | ||
|
||
#execute the application | ||
ENTRYPOINT ["java","-cp","app:app/lib/*","com.javatab.gatewayservice.ApiGatewayServiceApplication"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "3.8" | ||
services: | ||
elasticsearch: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | ||
container_name: elasticsearch | ||
environment: | ||
- node.name=elasticsearch | ||
- discovery.type=single-node | ||
- cluster.name=docker-cluster | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
# volumes: | ||
# - esdata1:/usr/share/elasticsearch/data | ||
ports: | ||
- "9300:9300" | ||
- "9200:9200" | ||
networks: | ||
- backend | ||
|
||
networks: | ||
backend: | ||
driver: bridge | ||
|
||
#volumes: | ||
# esdata1: | ||
# driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,7 @@ services: | |
ports: | ||
- "6379:6379" | ||
networks: | ||
backend: | ||
aliases: | ||
- "redis" | ||
- backend | ||
|
||
networks: | ||
backend: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#stage 1 | ||
#Start with a base image containing Java runtime | ||
FROM openjdk:11-slim as build | ||
|
||
# Add Maintainer Info | ||
LABEL maintainer="Nasruddin <[email protected]>" | ||
|
||
# The application's jar file | ||
ARG JAR_FILE | ||
|
||
# Add the application's jar to the container | ||
COPY ${JAR_FILE} app.jar | ||
|
||
#unpackage jar file | ||
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf /app.jar) | ||
|
||
#stage 2 | ||
#Same Java runtime | ||
FROM openjdk:11-slim | ||
|
||
#Add volume pointing to /tmp | ||
VOLUME /tmp | ||
|
||
#Copy unpackaged application to new container | ||
ARG DEPENDENCY=/target/dependency | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib | ||
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app | ||
|
||
#execute the application | ||
ENTRYPOINT ["java","-cp","app:app/lib/*","com.javatab.searchengine.SearchEngineApplication"] |
11 changes: 11 additions & 0 deletions
11
search-engine/src/main/java/com/javatab/searchengine/StudentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.javatab.searchengine; | ||
|
||
import com.javatab.searchengine.domain.Student; | ||
import org.springframework.data.repository.reactive.ReactiveCrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Repository | ||
public interface StudentRepository extends ReactiveCrudRepository<Student, String> { | ||
Flux<Student> findStudentByUsername(String username); | ||
} |
37 changes: 37 additions & 0 deletions
37
search-engine/src/main/java/com/javatab/searchengine/api/SearchApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.javatab.searchengine.api; | ||
|
||
import com.javatab.searchengine.StudentRepository; | ||
import com.javatab.searchengine.domain.Student; | ||
import com.javatab.searchengine.service.StudentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.web.bind.annotation.*; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Supplier; | ||
|
||
@RestController | ||
@RequestMapping("/search") | ||
@RequiredArgsConstructor | ||
public class SearchApi { | ||
|
||
private final StudentService studentService; | ||
private final StudentRepository studentRepository; | ||
|
||
@PostMapping("/create-index") | ||
public Mono<Student> createStudentIndex(@RequestBody Student student) throws IOException { | ||
return studentRepository.save(student); | ||
} | ||
|
||
@GetMapping("/id/{userid}") | ||
public Mono<Student> getUserById(@PathVariable("userid") String id) throws IOException { | ||
return studentRepository.findById(id); | ||
} | ||
|
||
@GetMapping("/username/{username}") | ||
public Flux<Student> getUserByUsername(@PathVariable("username") String username) throws IOException { | ||
return studentRepository.findStudentByUsername(username); | ||
} | ||
} |
Oops, something went wrong.