Postgres integration
Some checks failed
sample gradle build and test / build (pull_request) Failing after 4m41s
Some checks failed
sample gradle build and test / build (pull_request) Failing after 4m41s
This commit is contained in:
parent
fb4ff60729
commit
c567cf766d
@ -27,6 +27,10 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
|
runtimeOnly 'org.postgresql:postgresql'
|
||||||
|
implementation 'org.hibernate.validator:hibernate-validator'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
@ -12,6 +12,23 @@ services:
|
|||||||
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
|
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
|
||||||
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
|
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
|
||||||
- HOST_PORT=${HOST_PORT}
|
- HOST_PORT=${HOST_PORT}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USERNAME}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
env_file:
|
env_file:
|
||||||
- stack.env
|
- .env
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
postgres:
|
||||||
|
image: postgres:15
|
||||||
|
container_name: cftunnel-db
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: cftunnel
|
||||||
|
POSTGRES_USER: ${POSTGRES_USERNAME}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- pgdata:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
pgdata: {}
|
||||||
@ -1 +1,8 @@
|
|||||||
api.corsResolveUrl=http://localhost:8080
|
api.corsResolveUrl=http://localhost:8080
|
||||||
|
|
||||||
|
management.health.db.enabled=true
|
||||||
|
management.endpoints.web.exposure.include=health
|
||||||
|
management.endpoint.health.show-details=always
|
||||||
|
|
||||||
|
logging.level.org.hibernate.SQL=DEBUG
|
||||||
|
debug=true
|
||||||
|
|||||||
@ -16,4 +16,15 @@ spring.security.oauth2.client.provider.cftunnels.authorization-uri=https://auth.
|
|||||||
spring.security.oauth2.client.provider.cftunnels.token-uri=https://auth.hithomelabs.com/application/o/token/
|
spring.security.oauth2.client.provider.cftunnels.token-uri=https://auth.hithomelabs.com/application/o/token/
|
||||||
spring.security.oauth2.client.provider.cftunnels.user-info-uri=https://auth.hithomelabs.com/application/o/userinfo/
|
spring.security.oauth2.client.provider.cftunnels.user-info-uri=https://auth.hithomelabs.com/application/o/userinfo/
|
||||||
spring.security.oauth2.client.provider.cftunnels.jwk-set-uri=https://auth.hithomelabs.com/application/o/cftunnels/jwks/
|
spring.security.oauth2.client.provider.cftunnels.jwk-set-uri=https://auth.hithomelabs.com/application/o/cftunnels/jwks/
|
||||||
spring.security.oauth2.client.provider.cftunnels.issuer-uri=https://auth.hithomelabs.com/application/o/cftunnels/
|
spring.security.oauth2.client.provider.cftunnels.issuer-uri=https://auth.hithomelabs.com/application/o/cftunnels/
|
||||||
|
|
||||||
|
spring.datasource.url=jdbc:postgresql://localhost:5432/cftunnel
|
||||||
|
spring.datasource.username=${POSTGRES_USERNAME}
|
||||||
|
spring.datasource.password=${POSTGRES_PASSWORD}
|
||||||
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
|
spring.sql.init.mode=always
|
||||||
|
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.jpa.show-sql=true
|
||||||
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
|
|||||||
37
src/main/resources/schema.sql
Normal file
37
src/main/resources/schema.sql
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
-- schema.sql
|
||||||
|
|
||||||
|
-- Roles table
|
||||||
|
CREATE TABLE IF NOT EXISTS roles (
|
||||||
|
role_id SERIAL PRIMARY KEY,
|
||||||
|
role_name VARCHAR(50) UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Users table
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
user_id SERIAL PRIMARY KEY,
|
||||||
|
user_name VARCHAR(100) NOT NULL,
|
||||||
|
password VARCHAR(255) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- User-Role Mapping table (many-to-many relationship)
|
||||||
|
CREATE TABLE IF NOT EXISTS user_role_mapping (
|
||||||
|
mapping_id SERIAL PRIMARY KEY,
|
||||||
|
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
|
||||||
|
role_id INTEGER NOT NULL REFERENCES roles(role_id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Tunnels table
|
||||||
|
CREATE TABLE IF NOT EXISTS tunnels (
|
||||||
|
tunnel_id SERIAL PRIMARY KEY,
|
||||||
|
tunnel_name VARCHAR(100) NOT NULL,
|
||||||
|
tunnel_type VARCHAR(50) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Mapping Requests table
|
||||||
|
CREATE TABLE IF NOT EXISTS mapping_requests (
|
||||||
|
request_id SERIAL PRIMARY KEY,
|
||||||
|
request_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
status VARCHAR(20) NOT NULL,
|
||||||
|
user_id INTEGER REFERENCES users(user_id) ON DELETE SET NULL,
|
||||||
|
tunnel_id INTEGER REFERENCES tunnels(tunnel_id) ON DELETE SET NULL
|
||||||
|
);
|
||||||
Loading…
Reference in New Issue
Block a user