Skip to content

Commit e08eeb7

Browse files
authored
Merge pull request #153 from conorheffron/docker-up
Docker compose up
2 parents fdc08e4 + dee5042 commit e08eeb7

12 files changed

+55
-13
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
FROM eclipse-temurin:21-jdk
22

33
VOLUME /tmp
4+
# for CI
45
ADD *.war app.war
6+
# for local
7+
#ADD build/libs/*.war app.war
58
RUN sh -c 'touch /app.war'
69

710
ENTRYPOINT [ "sh", "-c", "java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.war" ]

README.md

+33-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This project is a sample data manager. It provides a basic template for Java/Spr
1515
Users can view, add, delete person objects from the database via web UI.
1616

1717
## Technologies Used
18-
Java 21 (LTS Version), Spring Boot 3, Hibernate, MySQL, JSP, Gradle 8
18+
Java 21 (LTS Version), Spring Boot 3, Hibernate, MySQL, JSP, Gradle 8.5
1919

2020
## Run
2121
MySql
@@ -30,26 +30,54 @@ docker inspect test-mysql
3030
![load-db](./screenshots/run-starter-db-script.png?raw=true "Load DB")
3131
![verify-db](./screenshots/verify-db-load.png?raw=true "Verify DB")
3232

33+
## Create Network
34+
```
35+
docker network create my-network
36+
docker inspect network my-network
37+
```
38+
39+
## Link container to same network for access:
40+
```
41+
docker network connect test-mysql
42+
```
43+
44+
## Inspect network configurations & update application properties with IPv4Address instead of localhost if mac user (IPv4Address for my-sql etc.)
3345
- Get IP address from inspect cmd and test connection from MySql workbench with new host IP. Run StarterDb.sql.
46+
```
47+
docker inspect network my-network
48+
```
49+
50+
## Build ironoc-db, run unit & integration tests, & generate war file.
51+
```
52+
gradle build
53+
```
3454

35-
Run 'com.ironoc.db.App.java' directly from IntelliJ or via CLI (build / spin up docker image):
55+
## Run 'com.ironoc.db.App.java' directly from IntelliJ (can use localhost for spring.datasource.url) or via CLI (build & spin up docker image, use docker network IP address for test-mysql process):
3656
```
37-
docker compose up
57+
docker image build -t ironoc-db .
58+
docker compose up -d
3859
```
60+
![docker-cli](./screenshots/CLI-docker.png?raw=true "CLI Docker")
3961

4062
## Tear-down:
4163
```
4264
docker stop test-mysql
4365
docker remove test-mysql
4466
```
4567

68+
## Alternatively, Docker Desktop is good if you prefer to not use the terminal/command line (CLI)
69+
![docker-desktop-containers](./screenshots/docker-desktop-containers.png?raw=true "Docker Desktop containers")
70+
71+
## Can tail the logs by scrolling within the container logs:
72+
![docker-desktop-ironoc-db-logs](./screenshots/docker-desktop-ironoc-db-logs.png?raw=true "Docker Desktop ironoc-db logs")
73+
4674
## Screenshot Home
4775
![Home](./screenshots/DBManager.png?raw=true "Home Page")
4876

4977
## Screenshot Form Validation Error for Add Person Call
50-
![image](https://github.com/user-attachments/assets/3b5edddb-4b6e-40a4-bbb5-99f5367bccad)
78+
![ui-form-validation](./screenshots/ui-form-validation.png?raw=true "UI form validation")
5179

5280
## Screenshot Form Validation Error for Delete Operation
53-
![image](https://github.com/user-attachments/assets/d4086af9-02a1-467e-9a75-93c507c7966d)
81+
![ui-delete-validation](./screenshots/ui-delete-validation.png?raw=true "UI delete validation")
5482

5583

SECURITY.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
| Version | Supported |
66
|-----------| ------------------ |
7-
| 4.2.14 | :white_check_mark: |
8-
| <= 4.2.13 | :x: |
7+
| 4.2.15 | :white_check_mark: |
8+
| <= 4.2.14 | :x: |
99
| 3.x.x | :x: |
1010

1111
## Reporting a Vulnerability

build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ buildscript {
77
}
88
}
99

10-
apply plugin: 'java'
10+
plugins {
11+
id 'java'
12+
id 'org.springframework.boot' version '3.3.1'
13+
}
14+
1115
apply plugin: 'eclipse'
1216
apply plugin: 'idea'
1317
apply plugin: 'war'
1418

1519
group = 'conorheffron'
16-
version = '4.2.14'
20+
version = '4.2.15'
1721
description = "Sample Data Manager"
1822

1923
sourceCompatibility = 21

docker-compose.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
version: '3'
21
services:
32
web:
4-
image: "conorheffron/ironoc-db:1.5.4"
3+
image: "ironoc-db"
54
ports:
65
- "8080:8080"
6+
networks:
7+
- my-network
78
volumes:
8-
- .:/tmp
9+
- .:/tmp
10+
11+
networks:
12+
my-network:
13+
external: true

screenshots/CLI-docker.png

532 KB
Loading
119 KB
Loading
418 KB
Loading

screenshots/ui-delete-validation.png

59.4 KB
Loading

screenshots/ui-form-validation.png

49.7 KB
Loading

src/main/java/com/ironoc/db/controller/PersonController.java

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.springframework.web.bind.annotation.RequestMethod;
1717
import org.springframework.web.bind.annotation.RequestParam;
1818
import org.springframework.web.servlet.view.RedirectView;
19-
2019
import java.util.List;
2120

2221
@Controller

src/main/resources/application.properties

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Data Source
2+
# docker run
3+
#spring.datasource.url=jdbc:mysql://172.19.0.2:3306/test?autoReconnect=true&useSSL=false
4+
# Intellij run
25
spring.datasource.url=jdbc:mysql://localhost:3306/test?autoReconnect=true&useSSL=false
36
spring.datasource.username=root
47
spring.datasource.password=mypassword

0 commit comments

Comments
 (0)