diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9a9744d --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +POSTGRES_USER=blueprint_admin_backend +POSTGRES_PASSWORD=postgres +POSTGRES_DB=postgres \ No newline at end of file diff --git a/.gitignore b/.gitignore index d5336b1..79f0736 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,7 @@ out/ .vscode/ ### Docker ### -postgres-data \ No newline at end of file +postgres-data + +### ENVIRONMENT ### +.env diff --git a/Dockerfile b/Dockerfile index 5b60a28..b9de65e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM gradle:8.7.0-jdk17 AS build -COPY --chown=gradle:gradle . /home/gradle/src -WORKDIR /home/gradle/src -RUN gradle build --no-daemon -x test +FROM openjdk:17-slim -FROM openjdk:8-jre-slim +WORKDIR /app -EXPOSE 8080 +COPY gradlew /app/ +COPY gradle /app/gradle +COPY build.gradle /app/ + +RUN ./gradlew --no-daemon dependencies -RUN mkdir /app +COPY build/libs/*.jar app.jar -COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar +EXPOSE 8080 -ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/spring-boot-application.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/README.md b/README.md index ecf0b43..452a4ac 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ Spring Java application that hosts the backend for our Blueprint Admin application. This project will help us manage Blueprint members. ## Running the service +Copy the environment variables from .env.example +``` +cp .env.example .env +``` Initialize docker container with postgres service. If you don't have docker installed you can install [here](https://docs.docker.com/engine/install/). ``` docker-compose up -d @@ -11,6 +15,16 @@ Build the application ./gradlew build ``` Run the application. (You have to run the ```admin/BlueprintAdmin.java``` this is the entry point of the Spring application). +Else, you can use the following command to run the Spring application: +``` +./gradlew bootRun +``` +You should see the following output in your terminal +``` +o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '' +com.sitblueprint.admin.BlueprintAdmin : Started BlueprintAdmin in 2.255 seconds (process running for 2.392) + +``` ## How to connect to database in Docker Container? Start the docker container diff --git a/docker-compose.yaml b/docker-compose.yaml index 50edb8e..73e9a41 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,9 +4,9 @@ services: image: postgres:10.5 restart: always environment: - - POSTGRES_USER=blueprint_admin_backend - - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=postgres + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} logging: options: max-size: 10m diff --git a/src/main/java/com/sitblueprint/admin/controller/applications/ApplicationFormController.java b/src/main/java/com/sitblueprint/admin/controller/applications/ApplicationFormController.java index add3c85..777f4cd 100644 --- a/src/main/java/com/sitblueprint/admin/controller/applications/ApplicationFormController.java +++ b/src/main/java/com/sitblueprint/admin/controller/applications/ApplicationFormController.java @@ -19,11 +19,6 @@ public List getApplicationForms() { return applicationFormService.getApplicationForms(); } - @GetMapping - public ApplicationForm getApplicationFormById(@Param("applicationFormId") String applicationFormId) { - return applicationFormService.getApplicationFormById(Long.parseLong(applicationFormId)); - } - @PostMapping("/submit") public ApplicationForm submitApplicationForm(@RequestBody ApplicationForm applicationForm) { return applicationFormService.createApplicationForm(applicationForm);