From 6ca1117565d36c89ea2ee8e4f4220ccc429b1489 Mon Sep 17 00:00:00 2001 From: Sean Starkey Date: Fri, 29 May 2026 12:57:56 -0600 Subject: [PATCH] Add some scaffolding. --- .dockerignore | 10 ++ .gitignore | 26 ++++ Dockerfile | 12 ++ Makefile | 16 +++ docker-compose.yml | 28 +++++ pom.xml | 126 ++++++++++++++++++++ src/main/resources/application-postgres.yml | 15 +++ src/main/resources/application.yml | 31 +++++ 8 files changed, 264 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100644 pom.xml create mode 100644 src/main/resources/application-postgres.yml create mode 100644 src/main/resources/application.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6730ca6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.idea +.vscode +target/ +*.md +Makefile +docker-compose.yml +.env +.env.local +src/test/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5aaa015 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Maven +target/ +*.class +*.jar +*.war + +# IDE +.idea/ +*.iml +.vscode/ +*.eclipse +.project +.classpath +.settings/ + +# Environment +.env +.env.local + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log +logs/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e72b909 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM eclipse-temurin:21-jre-alpine + +WORKDIR /app + +COPY target/notesvault-0.0.1-SNAPSHOT.jar app.jar + +RUN addgroup -S appgroup && adduser -S appuser -G appgroup +USER appuser + +EXPOSE 8080 + +ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..78a41c0 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: run test docker-build docker-up docker-down + +run: + JWT_SECRET=dev-secret-change-me mvn spring-boot:run + +test: + mvn test + +docker-build: + docker build -t notesvault:latest . + +docker-up: + docker compose up -d + +docker-down: + docker compose down diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..791b81c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_DB: notesvault + POSTGRES_USER: notesvault + POSTGRES_PASSWORD: notesvault + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U notesvault"] + interval: 5s + timeout: 5s + retries: 5 + + api: + build: . + ports: + - "8080:8080" + environment: + SPRING_PROFILES_ACTIVE: postgres + DATASOURCE_URL: jdbc:postgresql://postgres:5432/notesvault + DATASOURCE_USERNAME: notesvault + DATASOURCE_PASSWORD: notesvault + JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set} + depends_on: + postgres: + condition: service_healthy diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f15748d --- /dev/null +++ b/pom.xml @@ -0,0 +1,126 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.3.0 + + + + com.seanstarkey + notesvault + 0.0.1-SNAPSHOT + notesvault + Secure Notes Vault API + + + 21 + 0.12.6 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-security + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + org.springframework.boot + spring-boot-starter-validation + + + + + com.h2database + h2 + runtime + + + + + org.postgresql + postgresql + runtime + + + + + org.flywaydb + flyway-core + + + + + io.jsonwebtoken + jjwt-api + ${jjwt.version} + + + io.jsonwebtoken + jjwt-impl + ${jjwt.version} + runtime + + + io.jsonwebtoken + jjwt-jackson + ${jjwt.version} + runtime + + + + + org.projectlombok + lombok + true + + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/resources/application-postgres.yml b/src/main/resources/application-postgres.yml new file mode 100644 index 0000000..21603b0 --- /dev/null +++ b/src/main/resources/application-postgres.yml @@ -0,0 +1,15 @@ +spring: + datasource: + url: ${DATASOURCE_URL:jdbc:postgresql://localhost:5432/notesvault} + driver-class-name: org.postgresql.Driver + username: ${DATASOURCE_USERNAME:notesvault} + password: ${DATASOURCE_PASSWORD:notesvault} + jpa: + database-platform: org.hibernate.dialect.PostgreSQLDialect + hibernate: + ddl-auto: validate + flyway: + locations: classpath:db/migration + h2: + console: + enabled: false diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..0ad04a8 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,31 @@ +spring: + datasource: + url: jdbc:h2:mem:notesvault;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;NON_KEYWORDS=VALUE + driver-class-name: org.h2.Driver + username: sa + password: "" + jpa: + database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: validate + open-in-view: false + flyway: + locations: classpath:db/migration + h2: + console: + enabled: false + +app: + jwt: + secret: ${JWT_SECRET:dev-secret-change-me-do-not-use-in-production} + expiration-seconds: 86400 + +--- +spring: + config: + activate: + on-profile: dev + h2: + console: + enabled: true + path: /h2-console