Skip to content

Commit 6ce290c

Browse files
author
shuaiwei_yu
committed
generate docker file for auth service
1 parent 0c7c98b commit 6ce290c

File tree

6 files changed

+88
-11
lines changed

6 files changed

+88
-11
lines changed

server/AuthService/.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.gradle
2+
build
3+
out
4+
*.iml
5+
*.log
6+
*.class
7+
.idea
8+
*.md
9+
*.bat
10+
*.sh
11+
target

server/AuthService/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Stage 1: Build with Gradle
2+
FROM gradle:8.7-jdk21 AS builder
3+
4+
WORKDIR /app
5+
6+
COPY gradle gradle
7+
COPY build.gradle settings.gradle gradlew /app/
8+
RUN ./gradlew --no-daemon build || true
9+
10+
COPY . .
11+
RUN ./gradlew bootJar --no-daemon
12+
13+
# Stage 2: Run the built JAR
14+
FROM eclipse-temurin:21-jdk-alpine
15+
16+
WORKDIR /app
17+
18+
COPY --from=builder /app/build/libs/*.jar app.jar
19+
20+
EXPOSE 8080
21+
22+
ENV SPRING_PROFILES_ACTIVE=docker
23+
24+
ENTRYPOINT ["java", "-jar", "app.jar"]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3.8'
2+
3+
services:
4+
postgres:
5+
image: postgres:15
6+
container_name: teamdrop-db
7+
environment:
8+
POSTGRES_DB: team-drop-database
9+
POSTGRES_USER: user
10+
POSTGRES_PASSWORD: password
11+
ports:
12+
- "5432:5432"
13+
volumes:
14+
- pgdata:/var/lib/postgresql/data
15+
16+
authservice:
17+
build: .
18+
container_name: authservice
19+
depends_on:
20+
- postgres
21+
ports:
22+
- "8080:8080"
23+
environment:
24+
SPRING_PROFILES_ACTIVE: docker
25+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/team-drop-database
26+
SPRING_DATASOURCE_USERNAME: user
27+
SPRING_DATASOURCE_PASSWORD: password
28+
29+
volumes:
30+
pgdata:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring:
2+
datasource:
3+
url: jdbc:postgresql://localhost:5432/team-drop-database
4+
username: user
5+
password: password
6+
driver-class-name: org.postgresql.Driver
7+
8+
jpa:
9+
hibernate:
10+
ddl-auto: create-drop
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring:
2+
datasource:
3+
url: ${SPRING_DATASOURCE_URL}
4+
username: ${SPRING_DATASOURCE_USERNAME}
5+
password: ${SPRING_DATASOURCE_PASSWORD}
6+
driver-class-name: org.postgresql.Driver
7+
8+
jpa:
9+
hibernate:
10+
ddl-auto: update
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
spring:
22
application:
3-
name: AuthService
4-
5-
datasource:
6-
url: jdbc:postgresql://localhost:5432/team-drop-database
7-
username: user
8-
password: password
9-
driver-class-name: org.postgresql.Driver
3+
name: AuthService
104

115
jpa:
12-
hibernate:
13-
ddl-auto: update
146
show-sql: false
157
properties:
168
hibernate:
@@ -23,6 +15,6 @@ application:
2315
jwt:
2416
private-key-path: classpath:keys/private.pem
2517
public-key-path: classpath:keys/public.pem
26-
expiration: 86400000 # a day
18+
expiration: 86400000 # 1 day
2719
refresh-token:
28-
expiration: 604800000 # 7 days
20+
expiration: 604800000 # 7 days

0 commit comments

Comments
 (0)