chore: add JWT secret env config, jjwt deps, and docker-compose prod fixes

This commit is contained in:
Joakim Mörling 2026-05-01 17:38:03 +02:00
parent c03b5a1401
commit c6e2e509eb
5 changed files with 30 additions and 8 deletions

View file

@ -1,16 +1,25 @@
# BilHej Environment Variables # BilHej Environment Variables
# Copy this file to .env and fill in your keys. # Copy this file to .env and fill in your keys.
#
# cp .env.example .env
#
# Docker Compose reads .env from the project root automatically.
# PostgreSQL # ---------- PostgreSQL ----------
POSTGRES_DB=bilhej POSTGRES_DB=bilhej
POSTGRES_USER=bilhej POSTGRES_USER=bilhej
POSTGRES_PASSWORD=change_me POSTGRES_PASSWORD=change_me
# JWT # ---------- JWT ----------
# Generate a secure random secret:
# openssl rand -hex 32
JWT_SECRET=change_me_to_a_random_64_char_string JWT_SECRET=change_me_to_a_random_64_char_string
# Stripe # ---------- Stripe (Phase 1) ----------
# Test keys from Stripe Dashboard: https://dashboard.stripe.com/test/apikeys
STRIPE_SECRET_KEY=sk_test_... STRIPE_SECRET_KEY=sk_test_...
# Webhook secret from stripe CLI: stripe listen --print-secret
STRIPE_WEBHOOK_SECRET=whsec_... STRIPE_WEBHOOK_SECRET=whsec_...
# Price ID from Stripe Dashboard: https://dashboard.stripe.com/test/products
STRIPE_PRICE_ID=price_... STRIPE_PRICE_ID=price_...

View file

@ -24,10 +24,13 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-webmvc' implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.flywaydb:flyway-database-postgresql' implementation 'org.flywaydb:flyway-database-postgresql'
implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
developmentOnly 'org.springframework.boot:spring-boot-devtools' developmentOnly 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2' runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.postgresql:postgresql' runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test' testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-starter-flyway-test' testImplementation 'org.springframework.boot:spring-boot-starter-flyway-test'

View file

@ -11,3 +11,7 @@ spring:
jpa: jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect database-platform: org.hibernate.dialect.PostgreSQLDialect
app:
jwt:
secret: ${JWT_SECRET}

View file

@ -23,3 +23,7 @@ spring:
flyway: flyway:
enabled: true enabled: true
locations: classpath:db/migration locations: classpath:db/migration
app:
jwt:
secret: ${JWT_SECRET:dev-secret-change-in-production}

View file

@ -2,8 +2,6 @@ services:
postgres: postgres:
image: postgres:16 image: postgres:16
container_name: bilhej-postgres-prod container_name: bilhej-postgres-prod
ports:
- "5432:5432"
environment: environment:
POSTGRES_DB: ${POSTGRES_DB} POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
@ -22,8 +20,6 @@ services:
dockerfile: docker/backend.prod.Dockerfile dockerfile: docker/backend.prod.Dockerfile
context: . context: .
container_name: bilhej-backend-prod container_name: bilhej-backend-prod
ports:
- "8080:8080"
environment: environment:
SPRING_PROFILES_ACTIVE: docker SPRING_PROFILES_ACTIVE: docker
POSTGRES_DB: ${POSTGRES_DB} POSTGRES_DB: ${POSTGRES_DB}
@ -45,13 +41,19 @@ services:
container_name: bilhej-frontend-prod container_name: bilhej-frontend-prod
ports: ports:
- "3000:80" - "3000:80"
- "443:443"
depends_on: depends_on:
- backend - backend
volumes: volumes:
- certs:/etc/nginx/certs - certs:/etc/nginx/certs
networks:
- default
- web
restart: unless-stopped restart: unless-stopped
volumes: volumes:
pgdata-prod: pgdata-prod:
certs: certs:
networks:
web:
external: true