Skip to content
Merged
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
4 changes: 1 addition & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CORS_PATTERN=/**
CORS_ALLOWED_ORIGINS=*
CORS_ALLOWED_METHODS=GET,POST,PUT,PATCH,DELETE,OPTIONS
CORS_ALLOWED_HEADERS=*
CORS_ALLOW_CREDENTIALS=true
CORS_ALLOW_CREDENTIALS=false

KEYCLOAK_HOST=http://localhost:8090
KEYCLOAK_REALM=heroes
Expand All @@ -26,11 +26,9 @@ MAX_FILE_SIZE=2048MB
MAX_REQUEST_SIZE=100MB

LOG_PATH=log
ROOT_LOG_LEVEL=trace
ROOT_LOG_LEVEL_CONSOLE=info
ROOT_LOG_LEVEL_FILE=info
ROOT_LOG_LEVEL_JSON=info
CALLV2_LOG_LEVEL=trace
CALLV2_LOG_LEVEL_CONSOLE=debug
CALLV2_LOG_LEVEL_FILE=debug
CALLV2_LOG_LEVEL_JSON=debug
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ bin
.env

*.log
*.log.json
*log.json
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ COPY . .

RUN ./gradlew clean bootJar --no-daemon

FROM eclipse-temurin:21.0.7_6-jdk-alpine
FROM eclipse-temurin:21.0.7_6-jre-alpine

COPY --from=builder /usr/app/build/libs/application.jar /opt/app/application.jar

ENV STORAGE_LOCATION=/srv/drive/storage
RUN mkdir -p /var/log/drive-api
RUN mkdir -p /srv/drive/storage

RUN mkdir -p $STORAGE_LOCATION
RUN addgroup -S app && adduser -S app -G app
RUN chown -R app:app /srv/drive/storage/
USER app:app

RUN chown -R app:app /srv/drive/storage
RUN chown -R app:app /var/log/drive-api


EXPOSE 80
USER app:app

CMD ["sh", "-c", "java -jar /opt/app/application.jar"]
2 changes: 1 addition & 1 deletion infrastructure/src/main/resources/application-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ postgres:
db:
ddl-auto: ${DB_DDL_AUTO}

reuqest-timeout: ${REQUEST_TIMEOUT}
request-timeout: ${REQUEST_TIMEOUT}

storage:
max-file-size: ${MAX_FILE_SIZE}
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ server:

spring:
profiles:
active: ${SPRING_PROFILES_ACTIVE:prd}
active: ${SPRING_PROFILES_ACTIVE:env}
mvc:
async:
request-timeout: ${reuqest-timeout:30000}
request-timeout: ${request-timeout:30000}
servlet:
multipart:
enabled: true
Expand Down
48 changes: 23 additions & 25 deletions infrastructure/src/main/resources/log4j2-spring.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Properties>
<Property name="ROOT_LOG_LEVEL">${env:ROOT_LOG_LEVEL:-info}</Property>
<Property name="ROOT_LOG_LEVEL_CONSOLE">${env:ROOT_LOG_LEVEL_CONSOLE:-info}</Property>
<Property name="ROOT_LOG_LEVEL_FILE">${env:ROOT_LOG_LEVEL_FILE:-info}</Property>
<Property name="ROOT_LOG_LEVEL_JSON">${env:ROOT_LOG_LEVEL_JSON:-info}</Property>
<Property name="rootLogLevelConsole">${env:ROOT_LOG_LEVEL_CONSOLE:-info}</Property>
<Property name="rootLogLevelFile">${env:ROOT_LOG_LEVEL_FILE:-off}</Property>
<Property name="rootLogLevelJson">${env:ROOT_LOG_LEVEL_JSON:-off}</Property>

<Property name="CALLV2_LOG_LEVEL">${env:CALLV2_LOG_LEVEL:-info}</Property>
<Property name="CALLV2_LOG_LEVEL_CONSOLE">${env:CALLV2_LOG_LEVEL_CONSOLE:-info}</Property>
<Property name="CALLV2_LOG_LEVEL_FILE">${env:CALLV2_LOG_LEVEL_FILE:-info}</Property>
<Property name="CALLV2_LOG_LEVEL_JSON">${env:CALLV2_LOG_LEVEL_JSON:-info}</Property>

<Property name="LOG_PATH">${env:LOG_PATH:-log}</Property>
<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %X{traceId} %-5level %logger{36}.%M(%F:%L) - %msg%n</Property>
<Property name="callv2LogLevelConsole">${env:CALLV2_LOG_LEVEL_CONSOLE:-info}</Property>
<Property name="callv2LogLevelFile">${env:CALLV2_LOG_LEVEL_FILE:-off}</Property>
<Property name="callv2LogLevelJson">${env:CALLV2_LOG_LEVEL_JSON:-off}</Property>

<Property name="logPath">${env:LOG_PATH:-/var/log/drive-api}</Property>
<Property name="logPattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %X{traceId} %-5level %logger{36}.%M(%F:%L) - %msg%n</Property>
</Properties>

<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_PATTERN}" />
<PatternLayout pattern="${logPattern}" />
</Console>
<RollingFile
name="FileLog"
fileName="${LOG_PATH}/drive-api.log"
filePattern="${LOG_PATH}/drive-api-%d{yyyy-MM-dd}.log.gz">
<PatternLayout pattern="${LOG_PATTERN}" />
fileName="${logPath}/log.log"
filePattern="${logPath}/log-%d{yyyy-MM-dd}.log.gz">
<PatternLayout pattern="${logPattern}" />
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
<RollingFile
name="JsonLog"
fileName="${LOG_PATH}/drive-api.log.json"
filePattern="${LOG_PATH}/drive-api-%d{yyyy-MM-dd}.log.json.gz">
fileName="${logPath}/log.json"
filePattern="${logPath}/log-%d{yyyy-MM-dd}.log.json.gz">
<JsonLayout
compact="true"
eventEol="true"
Expand All @@ -44,42 +42,42 @@
</Appenders>

<Loggers>
<Root level="${ROOT_LOG_LEVEL}">
<Root level="all">
<AppenderRef ref="Console">
<Filters>
<ThresholdFilter level="${ROOT_LOG_LEVEL_CONSOLE}" onMatch="ACCEPT"
<ThresholdFilter level="${rootLogLevelConsole}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
<AppenderRef ref="FileLog">
<Filters>
<ThresholdFilter level="${ROOT_LOG_LEVEL_FILE}" onMatch="ACCEPT"
<ThresholdFilter level="${rootLogLevelFile}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
<AppenderRef ref="JsonLog">
<Filters>
<ThresholdFilter level="${ROOT_LOG_LEVEL_JSON}" onMatch="ACCEPT"
<ThresholdFilter level="${rootLogLevelJson}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
</Root>
<Logger name="com.callv2" level="${CALLV2_LOG_LEVEL}" additivity="false">
<Logger name="com.callv2" level="all" additivity="false">
<AppenderRef ref="Console">
<Filters>
<ThresholdFilter level="${CALLV2_LOG_LEVEL_CONSOLE}" onMatch="ACCEPT"
<ThresholdFilter level="${callv2LogLevelConsole}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
<AppenderRef ref="FileLog">
<Filters>
<ThresholdFilter level="${CALLV2_LOG_LEVEL_FILE}" onMatch="ACCEPT"
<ThresholdFilter level="${callv2LogLevelFile}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
<AppenderRef ref="JsonLog">
<Filters>
<ThresholdFilter level="${CALLV2_LOG_LEVEL_JSON}" onMatch="ACCEPT"
<ThresholdFilter level="${callv2LogLevelJson}" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</AppenderRef>
Expand Down