Skip to content

Commit 2fa9643

Browse files
Created docker files and added LogRequest. Microservice enabled
1 parent 383e2e9 commit 2fa9643

File tree

12 files changed

+44
-9
lines changed

12 files changed

+44
-9
lines changed

docker/.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
FROM openjdk:8-jdk-alpine
1+
# Build (Uses JDK 21 & Maven)
2+
FROM eclipse-temurin:21-jdk AS build
3+
WORKDIR /app
24

3-
WORKDIR /Step4LoggerTesting
5+
# Copy project files
6+
COPY pom.xml .
7+
COPY src ./src
48

5-
COPY . .
9+
# Build JAR-file (Assume that tests have already passed)
10+
RUN apt-get update && apt-get install -y maven
11+
RUN mvn clean package -DskipTests
612

7-
RUN javac -d . *.java
13+
# Steg 2: Compiling phase (Using slim JRE 21)
14+
FROM eclipse-temurin:21-jre
15+
WORKDIR /app
816

9-
CMD ["java", "Main"]
17+
# Copy only finished JAR-file.
18+
COPY --from=build /app/target/*.jar app.jar
1019

11-
EXPOSE 8080
20+
# Create map for database.
21+
RUN mkdir -p /app/data
1222

13-
# docker build -t step4loggertesting .
23+
# Start application.
24+
ENTRYPOINT ["java", "-jar", "app.jar"]

docker/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.8'
2+
3+
services:
4+
logger-app:
5+
build:
6+
context: ..
7+
dockerfile: docker/Dockerfile
8+
container_name: java_logger_app
9+
volumes:
10+
- ./data:/app/data # save .db file on computer
11+
environment:
12+
# Decide where database will end up.
13+
- DATABASE_URL=jdbc:sqlite:/app/data/logs.db
14+
restart: always

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@
8989
<version>2.0.12</version>
9090
<scope>test</scope>
9191
</dependency>
92+
<!-- Javalin dependency-->
93+
<dependency>
94+
<groupId>io.javalin</groupId>
95+
<artifactId>javalin</artifactId>
96+
<version>6.1.3</version>
97+
</dependency>
98+
<!-- Jackson dependency-->
99+
<dependency>
100+
<groupId>com.fasterxml.jackson.core</groupId>
101+
<artifactId>jackson-databind</artifactId>
102+
<version>2.17.0</version>
103+
</dependency>
92104
</dependencies>
93105

94106
<!-- Plugins -->

target/classes/logger/Main.class

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-4 Bytes
Binary file not shown.
17 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)