From d461687b7025a4b8a8ae887a46d99e30181ef7b9 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 17 Mar 2020 16:35:08 +0300 Subject: [PATCH] Added basic structure, dependencies and Dockerfile for job-service. --- .gitignore | 2 + README.md | 6 ++- docker/api-gateway/conf.d/default.conf | 8 ++- docker/api-gateway/conf.d/dev.conf | 8 ++- docker/docker-compose.override.yml | 3 ++ docker/docker-compose.yml | 5 ++ job-service/client/pom.xml | 15 ++++++ job-service/model/pom.xml | 13 +++++ job-service/pom.xml | 23 ++++++++ job-service/server/Dockerfile | 4 ++ job-service/server/pom.xml | 53 +++++++++++++++++++ .../server/JobServiceServerApplication.java | 11 ++++ .../server/src/main/resources/application.yml | 7 +++ .../JobServiceServerApplicationTest.java | 16 ++++++ pom.xml | 1 + 15 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 job-service/client/pom.xml create mode 100644 job-service/model/pom.xml create mode 100644 job-service/pom.xml create mode 100644 job-service/server/Dockerfile create mode 100644 job-service/server/pom.xml create mode 100644 job-service/server/src/main/java/org/verapdf/jobservice/server/JobServiceServerApplication.java create mode 100644 job-service/server/src/main/resources/application.yml create mode 100644 job-service/server/src/test/java/org/verapdf/jobservice/server/JobServiceServerApplicationTest.java diff --git a/.gitignore b/.gitignore index 0e14118a..0edf5e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ build/ *-local.yml /temp/ + +*local.conf diff --git a/README.md b/README.md index 331a3560..675c2d4e 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,11 @@ docker-compose up -d Once you started stack you can use the following services: * file storage service: http://localhost/api/file +* jobs service: http://localhost/api/jobs -To check service availability you can get its status using `/status` endpoint, e.g.: http://localhost/api/file/status +To check service availability you can get its status using `/status` endpoints, e.g.: +http://localhost/api/file/status +http://localhost/api/jobs/status **Stop service stack** ``` @@ -47,3 +50,4 @@ containers. Config assumes that you launch services on the following ports: * file storage service: `8090` + * jobs service: `8091` diff --git a/docker/api-gateway/conf.d/default.conf b/docker/api-gateway/conf.d/default.conf index 624ca064..af5520e0 100644 --- a/docker/api-gateway/conf.d/default.conf +++ b/docker/api-gateway/conf.d/default.conf @@ -7,4 +7,10 @@ server { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } -} \ No newline at end of file + + location /api/jobs { + proxy_pass http://job-service:8080/api/job; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + } +} diff --git a/docker/api-gateway/conf.d/dev.conf b/docker/api-gateway/conf.d/dev.conf index 5c063caf..5d5c9c5b 100644 --- a/docker/api-gateway/conf.d/dev.conf +++ b/docker/api-gateway/conf.d/dev.conf @@ -7,4 +7,10 @@ server { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } -} \ No newline at end of file + + location /api/jobs { + proxy_pass http://host.docker.internal:8091/api/job; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + } +} diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml index c541529d..2be6869a 100644 --- a/docker/docker-compose.override.yml +++ b/docker/docker-compose.override.yml @@ -8,3 +8,6 @@ services: profile: ${PROFILE} ports: - 80:80 + depends_on: + - local-storage-service + - job-service diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 081cfd3c..eb09fac1 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -5,3 +5,8 @@ services: expose: - 8080 restart: always + job-service: + build: ../job-service/server + expose: + - 8080 + restart: always diff --git a/job-service/client/pom.xml b/job-service/client/pom.xml new file mode 100644 index 00000000..5ace538f --- /dev/null +++ b/job-service/client/pom.xml @@ -0,0 +1,15 @@ + + + + job-service + org.verapdf + 0.1.0-SNAPSHOT + + 4.0.0 + + job-service-client + + + \ No newline at end of file diff --git a/job-service/model/pom.xml b/job-service/model/pom.xml new file mode 100644 index 00000000..1215ae0b --- /dev/null +++ b/job-service/model/pom.xml @@ -0,0 +1,13 @@ + + + + job-service + org.verapdf + 0.1.0-SNAPSHOT + + 4.0.0 + + job-service-model + \ No newline at end of file diff --git a/job-service/pom.xml b/job-service/pom.xml new file mode 100644 index 00000000..49b8c07a --- /dev/null +++ b/job-service/pom.xml @@ -0,0 +1,23 @@ + + + + + org.verapdf + verapdf-webapp-server + 0.1.0-SNAPSHOT + + + 4.0.0 + + job-service + 0.1.0-SNAPSHOT + + client + model + server + + pom + + diff --git a/job-service/server/Dockerfile b/job-service/server/Dockerfile new file mode 100644 index 00000000..e882ed51 --- /dev/null +++ b/job-service/server/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:11 +COPY target/job-service-server.jar job-service-server.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "job-service-server.jar"] \ No newline at end of file diff --git a/job-service/server/pom.xml b/job-service/server/pom.xml new file mode 100644 index 00000000..b89697b7 --- /dev/null +++ b/job-service/server/pom.xml @@ -0,0 +1,53 @@ + + + + job-service + org.verapdf + 0.1.0-SNAPSHOT + + 4.0.0 + + job-service-server + + + 11 + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + job-service-server + + + + + build-info + + + + + + + + \ No newline at end of file diff --git a/job-service/server/src/main/java/org/verapdf/jobservice/server/JobServiceServerApplication.java b/job-service/server/src/main/java/org/verapdf/jobservice/server/JobServiceServerApplication.java new file mode 100644 index 00000000..5ef08995 --- /dev/null +++ b/job-service/server/src/main/java/org/verapdf/jobservice/server/JobServiceServerApplication.java @@ -0,0 +1,11 @@ +package org.verapdf.jobservice.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class JobServiceServerApplication { + public static void main(String[] args) { + SpringApplication.run(JobServiceServerApplication.class, args); + } +} diff --git a/job-service/server/src/main/resources/application.yml b/job-service/server/src/main/resources/application.yml new file mode 100644 index 00000000..19beb01a --- /dev/null +++ b/job-service/server/src/main/resources/application.yml @@ -0,0 +1,7 @@ +server: + servlet: + context-path: /api/jobs +management: + endpoints: + web: + base-path: /status diff --git a/job-service/server/src/test/java/org/verapdf/jobservice/server/JobServiceServerApplicationTest.java b/job-service/server/src/test/java/org/verapdf/jobservice/server/JobServiceServerApplicationTest.java new file mode 100644 index 00000000..f5cfbe66 --- /dev/null +++ b/job-service/server/src/test/java/org/verapdf/jobservice/server/JobServiceServerApplicationTest.java @@ -0,0 +1,16 @@ +package org.verapdf.jobservice.server; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +@ActiveProfiles("test") +public class JobServiceServerApplicationTest { + @Test + public void contextLoads() { + } +} diff --git a/pom.xml b/pom.xml index 602b16ac..26ce04bc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,6 +5,7 @@ local-storage-service + job-service