Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile #14

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_USER=blueprint_admin_backend
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ out/
.vscode/

### Docker ###
postgres-data
postgres-data

### ENVIRONMENT ###
.env
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
ENTRYPOINT ["java", "-jar", "app.jar"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ public List<ApplicationForm> 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);
Expand Down
Loading