Skip to content

Commit 6febfd5

Browse files
committed
added docker support
1 parent 26226ff commit 6febfd5

File tree

8 files changed

+38
-4
lines changed

8 files changed

+38
-4
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gradle
2+
build
3+
out

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM openjdk:8-jdk-alpine
2+
COPY . /app
3+
WORKDIR /app
4+
RUN /app/gradlew -v
5+
CMD ["/app/gradlew", "bootRun"]

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
A simple jwt project created with kotlin and spring boot 2.
1+
A simple jwt project created with kotlin, spring boot 2 and docker
22

33
Login, sign up and a test endpoint to test the jwt created
44

55
Spring security is not used
66

7-
### Structure
7+
## How to run
8+
go to the project's root:
9+
10+
docker-compose up
11+
12+
or simply
13+
14+
./gradlew bootRun
15+
16+
## Structure
817

918
- UserController: standard rest controller where you can login and sign-up
1019
- JwtService / UserService: contains logic for jwt and user management

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ apply plugin: 'kotlin-spring'
1919
apply plugin: 'kotlin-jpa'
2020
apply plugin: 'org.springframework.boot'
2121
apply plugin: 'io.spring.dependency-management'
22-
apply plugin: 'war'
2322

2423
group = 'com'
2524
version = '0.0.1-SNAPSHOT'
@@ -41,6 +40,12 @@ repositories {
4140
mavenCentral()
4241
}
4342

43+
configurations {
44+
developmentOnly
45+
runtimeClasspath {
46+
extendsFrom developmentOnly
47+
}
48+
}
4449

4550
dependencies {
4651
compile('org.springframework.boot:spring-boot-starter-data-jpa')
@@ -54,6 +59,7 @@ dependencies {
5459
// Uncomment the next line if you want to use RSASSA-PSS (PS256, PS384, PS512) algorithms:
5560
//'org.bouncycastle:bcprov-jdk15on:1.60',
5661
'io.jsonwebtoken:jjwt-jackson:0.10.2'
62+
developmentOnly("org.springframework.boot:spring-boot-devtools")
5763
testCompile('org.springframework.boot:spring-boot-starter-test') {
5864
exclude module: 'junit'
5965
}

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3.3"
2+
3+
services:
4+
jwt_app:
5+
image: kotest
6+
build: .
7+
volumes:
8+
- .:/app
9+
ports:
10+
- "8080:8080"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip

gradlew

100644100755
File mode changed.

src/main/kotlin/com/demo/filter/AuthFilter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class AuthFilter(val jwtService: JwtService) : HandlerInterceptor {
1818

1919
return try {
2020
val authorizationHeader = request.getHeader("Authorization")
21+
?: throw JwtException("Authorization header should not be null")
2122

2223
// throws exceptions if the jwt is not valid
2324
jwtService.getJwtClaims(authorizationHeader)

0 commit comments

Comments
 (0)