diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7319bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM openjdk:17-jdk-alpine +WORKDIR /app +COPY target/*.jar springboot-app.jar +EXPOSE 8080 +ENTRYPOINT ["java","-jar","springboot-app.jar"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8c2973b..864598d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: POSTGRES_USER: username POSTGRES_PASSWORD: password PGDATA: /data/postgres + POSTGRES_DB: jwt_security volumes: - postgres:/data/postgres ports: @@ -28,6 +29,23 @@ services: networks: - postgres restart: unless-stopped + springboot: + networks: + - postgres + build: + dockerfile: Dockerfile + image: springboot:jwt + container_name: sb3jwt + environment: + - "SPRING_PROFILES_ACTIVE=docker" + restart: always + ports: + - "8080:8080" + depends_on: + postgres: + condition: service_started + links: + - postgres networks: postgres: diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml new file mode 100644 index 0000000..e428e4c --- /dev/null +++ b/src/main/resources/application-docker.yml @@ -0,0 +1,23 @@ +spring: + datasource: + url: jdbc:postgresql://postgres-sql:5432/jwt_security + username: username + password: password + driver-class-name: org.postgresql.Driver + jpa: + hibernate: + ddl-auto: create-drop + show-sql: false + properties: + hibernate: + format_sql: true + database: postgresql + database-platform: org.hibernate.dialect.PostgreSQLDialect + +application: + security: + jwt: + secret-key: 404E635266556A586E3272357538782F413F4428472B4B6250645367566B5970 + expiration: 86400000 # a day + refresh-token: + expiration: 604800000 # 7 days diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..e10c4ef --- /dev/null +++ b/start.bat @@ -0,0 +1,5 @@ +call docker stop sb3jwt +call docker rm sb3jwt +call docker rmi springboot:jwt +call mvn clean package +call docker compose -f docker-compose.yml up --build -d \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..dc1e021 --- /dev/null +++ b/start.sh @@ -0,0 +1,5 @@ +docker stop sb3jwt +docker rm sb3jwt +docker rmi springboot:jwt +mvn clean package -DskipTests=true +docker compose -f docker-compose.yml up --build -d \ No newline at end of file diff --git a/stop.bat b/stop.bat new file mode 100644 index 0000000..ca853f8 --- /dev/null +++ b/stop.bat @@ -0,0 +1 @@ +call docker compose -f docker-compose.yml down \ No newline at end of file diff --git a/stop.sh b/stop.sh new file mode 100644 index 0000000..c7f2e39 --- /dev/null +++ b/stop.sh @@ -0,0 +1 @@ +docker compose -f docker-compose.yml down \ No newline at end of file