generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #48 from Arquisoft/46-docker-backend
46 docker backend
- Loading branch information
Showing
31 changed files
with
1,549 additions
and
296 deletions.
There are no files selected for viewing
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,24 @@ | ||
######################################## | ||
# Build stage | ||
######################################## | ||
# Maven base image | ||
FROM maven:3.9.6-eclipse-temurin-17-alpine AS build | ||
# Working directory | ||
WORKDIR /app | ||
# Copy project | ||
COPY pom.xml . | ||
COPY src ./src | ||
# Build jar file | ||
RUN mvn clean package | ||
|
||
######################################## | ||
# Package stage | ||
######################################## | ||
# Java base image | ||
FROM openjdk:17-jdk-alpine | ||
# Copy jar file built in previous stage | ||
COPY --from=build /app/target/wiq-0.0.1-SNAPSHOT.jar wiq-0.0.1-SNAPSHOT.jar | ||
# Expose port | ||
EXPOSE 8090 | ||
# Launch application | ||
CMD ["java","-jar","/wiq-0.0.1-SNAPSHOT.jar"] |
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,17 @@ | ||
package com.wiq.wiq; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class CustomConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("http://localhost:3000") | ||
.allowedMethods("GET", "POST", "PUT", "DELETE") | ||
.allowedHeaders("*"); | ||
} | ||
} |
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
12 changes: 0 additions & 12 deletions
12
backend/wiq/src/main/java/com/wiq/wiq/model/TestClass.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
backend/wiq/src/main/java/com/wiq/wiq/services/QuestionGeneratorService.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,49 @@ | ||
package com.wiq.wiq.services; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.json.JSONObject; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.wiq.wiq.services.questionGenerator.QuestionGenerator; | ||
import com.wiq.wiq.services.questionGenerator.question.QuestionType; | ||
|
||
@Service | ||
public class QuestionGeneratorService { | ||
|
||
private QuestionType[] types = {QuestionType.POPULATION, QuestionType.CAPITAL, QuestionType.SIZE, | ||
QuestionType.LANGUAGE}; | ||
|
||
public String getQuestions() { | ||
QuestionGenerator qg = new QuestionGenerator("en"); | ||
List<String> toRet = new ArrayList<>(); | ||
for(QuestionType t : types) { | ||
toRet.addAll(run(qg, t)); | ||
} | ||
return this.listToJSON(toRet); | ||
|
||
} | ||
|
||
private List<String> run(QuestionGenerator qg, QuestionType type) { | ||
List<String> toRet = new ArrayList<>(); | ||
for(int i=0; i<3; i++) { | ||
toRet.add(qg.generateQuestion(type)); | ||
System.out.println("Generated"); | ||
} | ||
return toRet; | ||
} | ||
|
||
/** | ||
* Receives a list of Strings in JSON format and creates a JSON with the keys 0-N, N = size of list | ||
* @param list | ||
* @return String in JSON format | ||
*/ | ||
private String listToJSON(List<String> list){ | ||
JSONObject json = new JSONObject(); | ||
for(int i = 0; i < list.size(); i++) | ||
json.accumulate((i + ""), list.get(i)); | ||
return json.toString(); | ||
} | ||
|
||
} |
21 changes: 0 additions & 21 deletions
21
backend/wiq/src/main/java/com/wiq/wiq/services/TestService.java
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
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 |
---|---|---|
@@ -1,110 +1,120 @@ | ||
version: '3' | ||
services: | ||
mongodb: | ||
container_name: mongodb-${teamname:-defaultASW} | ||
image: mongo | ||
profiles: ["dev", "prod"] | ||
volumes: | ||
- mongodb_data:/data/db | ||
ports: | ||
- "27017:27017" | ||
networks: | ||
- mynetwork | ||
version: '3' | ||
services: | ||
mongodb: | ||
container_name: mongodb-${teamname:-defaultASW} | ||
image: mongo | ||
profiles: ["dev", "prod"] | ||
volumes: | ||
- mongodb_data:/data/db | ||
ports: | ||
- "27017:27017" | ||
networks: | ||
- mynetwork | ||
|
||
authservice: | ||
container_name: authservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/authservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./users/authservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8002:8002" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
authservice: | ||
container_name: authservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/authservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./users/authservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8002:8002" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
|
||
userservice: | ||
container_name: userservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/userservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./users/userservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8001:8001" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
userservice: | ||
container_name: userservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/userservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./users/userservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8001:8001" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
|
||
gatewayservice: | ||
container_name: gatewayservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/gatewayservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./gatewayservice | ||
depends_on: | ||
- mongodb | ||
- userservice | ||
- authservice | ||
ports: | ||
- "8000:8000" | ||
networks: | ||
- mynetwork | ||
environment: | ||
AUTH_SERVICE_URL: http://authservice:8002 | ||
USER_SERVICE_URL: http://userservice:8001 | ||
backend: | ||
container_name: backend_wiq-${teamname:-defaultASW} | ||
profiles: ["dev", "prod"] | ||
build: | ||
context: ./backend/wiq | ||
dockerfile: Dockerfile | ||
ports: | ||
- 8090:8090 | ||
|
||
webapp: | ||
container_name: webapp-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/webapp:latest | ||
profiles: ["dev", "prod"] | ||
build: ./webapp | ||
depends_on: | ||
- gatewayservice | ||
ports: | ||
- "3000:3000" | ||
gatewayservice: | ||
container_name: gatewayservice-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/gatewayservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./gatewayservice | ||
depends_on: | ||
- mongodb | ||
- userservice | ||
- authservice | ||
- backend | ||
ports: | ||
- "8000:8000" | ||
networks: | ||
- mynetwork | ||
environment: | ||
AUTH_SERVICE_URL: http://authservice:8002 | ||
USER_SERVICE_URL: http://userservice:8001 | ||
|
||
prometheus: | ||
image: prom/prometheus | ||
container_name: prometheus-${teamname:-defaultASW} | ||
profiles: ["dev"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- ./gatewayservice/monitoring/prometheus:/etc/prometheus | ||
- prometheus_data:/prometheus | ||
ports: | ||
- "9090:9090" | ||
depends_on: | ||
- gatewayservice | ||
|
||
grafana: | ||
image: grafana/grafana | ||
container_name: grafana-${teamname:-defaultASW} | ||
profiles: ["dev"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- grafana_data:/var/lib/grafana | ||
- ./gatewayservice/monitoring/grafana/provisioning:/etc/grafana/provisioning | ||
environment: | ||
- GF_SERVER_HTTP_PORT=9091 | ||
- GF_AUTH_DISABLE_LOGIN_FORM=true | ||
- GF_AUTH_ANONYMOUS_ENABLED=true | ||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
ports: | ||
- "9091:9091" | ||
depends_on: | ||
- prometheus | ||
webapp: | ||
container_name: webapp-${teamname:-defaultASW} | ||
image: ghcr.io/arquisoft/wiq_en1b/webapp:latest | ||
profiles: ["dev", "prod"] | ||
build: ./webapp | ||
depends_on: | ||
- gatewayservice | ||
ports: | ||
- "3000:3000" | ||
|
||
prometheus: | ||
image: prom/prometheus | ||
container_name: prometheus-${teamname:-defaultASW} | ||
profiles: ["dev"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- ./gatewayservice/monitoring/prometheus:/etc/prometheus | ||
- prometheus_data:/prometheus | ||
ports: | ||
- "9090:9090" | ||
depends_on: | ||
- gatewayservice | ||
|
||
grafana: | ||
image: grafana/grafana | ||
container_name: grafana-${teamname:-defaultASW} | ||
profiles: ["dev"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- grafana_data:/var/lib/grafana | ||
- ./gatewayservice/monitoring/grafana/provisioning:/etc/grafana/provisioning | ||
environment: | ||
- GF_SERVER_HTTP_PORT=9091 | ||
- GF_AUTH_DISABLE_LOGIN_FORM=true | ||
- GF_AUTH_ANONYMOUS_ENABLED=true | ||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
ports: | ||
- "9091:9091" | ||
depends_on: | ||
- prometheus | ||
|
||
volumes: | ||
mongodb_data: | ||
prometheus_data: | ||
grafana_data: | ||
|
||
networks: | ||
mynetwork: | ||
driver: bridge | ||
volumes: | ||
mongodb_data: | ||
prometheus_data: | ||
grafana_data: | ||
|
||
networks: | ||
mynetwork: | ||
driver: bridge |
Oops, something went wrong.