Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Compiled class files
*.class

# Log files
*.log
logs/

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Build directory
target/
out/

# IDE configuration files
.idea/
*.iml
*.ipr
*.iws
.classpath
.project
.settings/
.DS_Store

# Gradle
.gradle/
build/

Comment on lines +40 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Don’t ignore Gradle wrapper jar

*.jar will exclude gradle/wrapper/gradle-wrapper.jar, breaking the wrapper. Whitelist it.

 # Gradle
 .gradle/
 build/
+!gradle/wrapper/gradle-wrapper.jar
🤖 Prompt for AI Agents
In .gitignore around lines 40 to 43, the current rules ignore Gradle build
artifacts but a global *.jar ignore will also exclude
gradle/wrapper/gradle-wrapper.jar and break the wrapper; add an explicit
whitelist entry for the wrapper jar (for example:
!gradle/wrapper/gradle-wrapper.jar) placed before or near the *.jar rule so the
wrapper jar is not ignored, and verify the order of patterns ensures the
whitelist takes precedence.

# Environment files
.env

# Temporary files
*.swp
*.tmp
*~

# Backup files
*.bak
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build stage
FROM gradle:8.3-jdk17-alpine AS build
WORKDIR /app
COPY build.gradle.kts settings.gradle.kts /app/
COPY src /app/src
RUN gradle build --no-daemon
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Build will fail: copying .kts files while repo uses Groovy DSL

Repo contains settings.gradle (not settings.gradle.kts). Align COPY sources.

-COPY build.gradle.kts settings.gradle.kts /app/
+COPY build.gradle settings.gradle /app/
 COPY src /app/src
-RUN gradle build --no-daemon
+RUN gradle build --no-daemon

If you actually use Kotlin DSL, rename files consistently and update this Dockerfile.


🏁 Script executed:

#!/bin/bash
echo "Locating Gradle build and settings files..."
find . -maxdepth 2 -type f -name "settings.gradle*" -print
find . -maxdepth 2 -type f -name "build.gradle*" -print

Length of output: 248


Align Dockerfile with Groovy DSL filenames
Update Dockerfile lines 4–6 to copy build.gradle and settings.gradle (not .kts files):

-COPY build.gradle.kts settings.gradle.kts /app/
+COPY build.gradle settings.gradle /app/
🤖 Prompt for AI Agents
In Dockerfile around lines 4 to 6, the COPY commands reference Kotlin DSL
filenames (build.gradle.kts, settings.gradle.kts) but the project uses Groovy
DSL files; update those COPY lines to reference build.gradle and settings.gradle
instead, ensuring the correct filenames are copied into /app before running the
gradle build.


# Package stage
FROM openjdk:17-jdk-slim
WORKDIR /app
COPY --from=build /app/build/libs/*.jar /app/app.jar
EXPOSE 8080
CMD ["java", "-jar", "/app/app.jar"]
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id 'org.springframework.boot' version '3.1.4'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_17
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

}

tasks.named('test') {
useJUnitPlatform()
}
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
services:
postgres:
image: postgres:16
container_name: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=bitly
- POSTGRES_PASSWORD=bitly
- POSTGRES_DB=bitly
healthcheck:
test: ["CMD-SHELL", "pg_isready -U bitly -d bitly"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
memory: 512M

redis:
image: redis:7-alpine
container_name: redis
ports:
- "6379:6379"
command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
memory: 1G

# api:
# build: .
# container_name: api
# depends_on:
# postgres:
# condition: service_healthy
# redis:
# condition: service_healthy
# ports:
# - "8080:8080"
# environment:
# - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/bitly
# - SPRING_DATASOURCE_USERNAME=bitly
# - SPRING_DATASOURCE_PASSWORD=bitly
# - SPRING_REDIS_HOST=redis
# - SPRING_REDIS_PORT=6379
# deploy:
# resources:
# limits:
# memory: 1G
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Pin Gradle distribution SHA-256 to prevent supply‑chain tampering.
Add distributionSha256Sum for the exact ZIP you pin to.

Run to fetch the checksum and verify it locally, then add it:

Then update the wrapper properties:

 distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
+distributionSha256Sum=<paste-verified-sha256>

🏁 Script executed:

#!/bin/bash
url='https://services.gradle.org/distributions/gradle-8.14.2-bin.zip'
curl -fsSL "$url.sha256"
# Optional: verify after download
curl -fsSLO "$url" && curl -fsSL "$url.sha256" | sha256sum -c -

Length of output: 527


Pin Gradle distribution SHA-256
The SHA-256 checksum for gradle-8.14.2-bin.zip is

7197a12f450794931532469d4ff21a59ea2c1cd59a3ec3f89c035c3c420a6999

Add it to gradle/wrapper/gradle-wrapper.properties:

 distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
+distributionSha256Sum=7197a12f450794931532469d4ff21a59ea2c1cd59a3ec3f89c035c3c420a6999
🤖 Prompt for AI Agents
In gradle/wrapper/gradle-wrapper.properties around line 3, the Gradle
distribution URL is specified but the SHA-256 checksum is not pinned; add a line
distributionSha256Sum=7197a12f450794931532469d4ff21a59ea2c1cd59a3ec3f89c035c3c420a6999
immediately after the distributionUrl entry so the wrapper verifies the
downloaded gradle-8.14.2-bin.zip against the provided checksum.

networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading