Skip to content

Commit dc44f41

Browse files
authored
feat: implements fullstack Java app (#661)
* chore: add initial thymeleaf + tailwind integration * feat: switches frontend to vite react app, integrates clerk auth * chore: separates react static files to a different path * chore: adds react build to java config * chore: setup app for running react separate from server * chore: sets up fly.io deployment * chore: adds fly and vercel tools for deployment * chore: makes secrets configurable * chore: ensures redis secrets are loaded from config * feat: finish wiring up api to frontend * chore: makes member var final * chore: add redis database to devcontainer.
1 parent 77d3ef4 commit dc44f41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5767
-1
lines changed

Diff for: .devcontainer/devcontainer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"ghcr.io/devcontainers-contrib/features/ts-node:1": {},
1717
"ghcr.io/devcontainers/features/sshd:1": {},
1818
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {},
19-
"ghcr.io/devcontainers/features/github-cli:1": {}
19+
"ghcr.io/devcontainers/features/github-cli:1": {},
20+
"ghcr.io/devcontainers-extra/features/vercel-cli:1": {},
21+
"ghcr.io/audacioustux/devcontainers/flyctl:1": {},
22+
"ghcr.io/itsmechlark/features/redis-server:1": {}
2023
},
2124
"portsAttributes": {
2225
"80": {

Diff for: lib/java/fullstack_demo/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/gradlew text eol=lf
2+
*.bat text eol=crlf
3+
*.jar binary

Diff for: lib/java/fullstack_demo/.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
bin/
17+
!**/src/main/**/bin/
18+
!**/src/test/**/bin/
19+
20+
### IntelliJ IDEA ###
21+
.idea
22+
*.iws
23+
*.iml
24+
*.ipr
25+
out/
26+
!**/src/main/**/out/
27+
!**/src/test/**/out/
28+
29+
### NetBeans ###
30+
/nbproject/private/
31+
/nbbuild/
32+
/dist/
33+
/nbdist/
34+
/.nb-gradle/
35+
36+
### VS Code ###
37+
.vscode/
38+
39+
src/main/resources/react-static

Diff for: lib/java/fullstack_demo/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Use an official OpenJDK runtime as a parent image
2+
FROM openjdk:17-jdk-alpine
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the current directory contents into the container at /app
8+
COPY ./build /app
9+
10+
# Expose port 8080 to the outside world
11+
EXPOSE 8080
12+
13+
# Run the application
14+
CMD ["java", "-jar", "libs/fullstack_demo-0.0.1-SNAPSHOT.jar"]

Diff for: lib/java/fullstack_demo/build.gradle.kts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
plugins {
2+
java
3+
application
4+
eclipse
5+
id("com.diffplug.spotless") version "6.25.0"
6+
id("com.adarshr.test-logger") version "4.0.0"
7+
id("io.freefair.lombok") version "8.6"
8+
id("io.spring.dependency-management") version "1.1.6"
9+
id("org.springframework.boot") version "3.4.0"
10+
}
11+
12+
apply(plugin = "io.spring.dependency-management")
13+
14+
group = "com.codedifferently"
15+
version = "0.0.1-SNAPSHOT"
16+
17+
java {
18+
toolchain {
19+
languageVersion = JavaLanguageVersion.of(17)
20+
}
21+
}
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
dependencies {
28+
implementation("com.clerk:backend-api:1.4.0")
29+
implementation("com.google.code.gson:gson:2.11.0")
30+
implementation("org.json:json:20240303")
31+
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
32+
implementation("org.springframework.boot:spring-boot-starter-web")
33+
implementation("redis.clients:jedis:5.2.0")
34+
testImplementation("org.springframework.boot:spring-boot-starter-test")
35+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
36+
}
37+
38+
tasks.withType<Test> {
39+
useJUnitPlatform()
40+
}
41+
42+
// Define Node.js tasks
43+
val npmInstall by tasks.registering(Exec::class) {
44+
workingDir = file("src/main/frontend")
45+
commandLine("npm", "install")
46+
}
47+
48+
val npmBuild by tasks.registering(Exec::class) {
49+
dependsOn(npmInstall)
50+
workingDir = file("src/main/frontend")
51+
commandLine("npm", "run", "build")
52+
}
53+
54+
val copyReactBuild by tasks.registering(Copy::class) {
55+
dependsOn(npmBuild)
56+
from("src/main/frontend/dist")
57+
into("src/main/resources/react-static")
58+
}
59+
60+
// Hook into the Gradle build lifecycle
61+
tasks.named("processResources") {
62+
dependsOn(copyReactBuild)
63+
}

Diff for: lib/java/fullstack_demo/fly.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# fly.toml app configuration file generated for fullstack-demo-cold-breeze-8913 on 2024-11-29T18:58:58Z
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'fullstack-demo-cold-breeze-8913'
7+
primary_region = 'lax'
8+
9+
[http_service]
10+
internal_port = 8080
11+
force_https = true
12+
auto_stop_machines = 'stop'
13+
auto_start_machines = true
14+
min_machines_running = 0
15+
processes = ['app']
16+
17+
[[vm]]
18+
memory = '1gb'
19+
cpu_kind = 'shared'
20+
cpus = 1
42.6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)