Skip to content

Commit

Permalink
Add time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
mfvanek committed Nov 6, 2024
1 parent 0be8242 commit 42af72c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,44 @@ curl http://localhost:8080/api/employee/all
```

## Run locally
```shell
mvn spring-boot:run -Dspring-boot.run.profiles=extern

### With database from Testcontainers

```
mvn spring-boot:run -Dspring-boot.run.profiles=local -Dspring-boot.run.jvmArguments="-Duser.timezone=Europe/Moscow"
```

### With external database

```
mvn spring-boot:run -Dspring-boot.run.profiles=extern -Dspring-boot.run.jvmArguments="-Duser.timezone=Europe/Moscow"
```

## Run in Docker

### Build image
```shell

```
mvn clean spring-boot:build-image -DskipTests -DskipSpotbugs=true
```

### Build native image

**_Unfortunately, built application doesn't start in container_**
```shell
```
mvn clean spring-boot:build-image -DskipTests -DskipSpotbugs=true -Pnative
```

### Docker Compose

#### Start

```shell
docker-compose --project-name="salary-calc" up -d
```

#### Stop

```shell
docker-compose --project-name="salary-calc" down
```
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ services:

salary-calc:
container_name: salary_calc_container
image: docker.io/mfvanek/salary.calc:0.4.3
image: docker.io/mfvanek/salary.calc:0.4.7
environment:
SPRING_PROFILES_ACTIVE: "docker"
TZ: Europe/Moscow
ports:
- "8080:8080"
- "8090:8090"
Expand All @@ -73,7 +74,7 @@ services:
resources:
limits:
cpus: '0.5'
memory: 512M
memory: 768M
networks:
- postgres

Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@
<target>${java.version}</target>
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -Xep:MissingSummary:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:TruthSelfEquals:OFF</arg>
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -Xep:MissingSummary:OFF
-Xep:FutureReturnValueIgnored:OFF -Xep:TruthSelfEquals:OFF
</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<failOnWarning>true</failOnWarning>
Expand Down Expand Up @@ -333,6 +335,9 @@
<configuration>
<image>
<name>mfvanek/${project.artifactId}:${project.version}</name>
<env>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
</env>
</image>
<excludes>
<exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import org.springframework.context.annotation.Configuration;

import java.time.Clock;
import java.time.ZoneId;

@Configuration(proxyBeanMethods = false)
public class ClockConfig {

@Bean
public Clock clock() {
return Clock.systemUTC();
return Clock.system(ZoneId.systemDefault());
}
}
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spring:
connection-timeout: 1000 # 1 second
maximum-pool-size: 5

user:
timezone: "Europe/Moscow"

server:
port: 8080
servlet:
Expand Down

0 comments on commit 42af72c

Please sign in to comment.