Skip to content

Commit

Permalink
Replace htmx JAR with CDN link
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Sep 18, 2024
1 parent 9e7faed commit 0a160b8
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 98 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ out/
local.properties
lambda.properties
/app/src/main/generated/
*.env
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ modules and features:
- `http4k-core` <-- main HTTP library
- `http4k-config` <-- for 12-factor configuration via environmental properties
- `http4k-connect-amazon-s3` <-- replaces the Java AWS SDK with a lightweight http4k client
- `http4k-htmx` <-- for HTMX support
- `http4k-template-rocker` <-- for templating
- `http4k-multipart` <-- multipart form uploads
- `http4k-testing-hamkrest` <-- for test assertions
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
dependencies {
api("org.http4k:http4k-core")
api("org.http4k:http4k-config")
api("org.http4k:http4k-htmx")
api("org.http4k:http4k-multipart")
api("org.http4k:http4k-template-rocker")
api("org.http4k:http4k-connect-amazon-s3")
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/kotlin/http4kbox/Http4kBox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import org.http4k.core.Method.POST
import org.http4k.core.then
import org.http4k.filter.ServerFilters.CatchAll
import org.http4k.routing.bind
import org.http4k.routing.htmxWebjars
import org.http4k.routing.routes

fun Http4kBox(env: Environment, http: HttpHandler): HttpHandler {
val fs = FileStorage(env, http)
return CatchAll().then(
routes(
htmxWebjars(),
"/{id}" bind routes(GET to Get(fs), DELETE to Delete(fs)),
"/" bind routes(GET to Index(fs), POST to Upload(fs))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"
integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn"
crossorigin="anonymous"></script>
<script src="/htmx.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/htmx/2.0.2/htmx.min.js" integrity="sha512-iRA+DJgDLUKPk+pqGpAM3+wSDeO5iKQkYXGtIv4+EA8oJWN1mewMJD7kWC9hHCyUTdey9bQypAhx6PASWShjOw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<style>
body {
padding-top: 100px;
Expand Down
18 changes: 0 additions & 18 deletions native/Dockerfile

This file was deleted.

6 changes: 2 additions & 4 deletions native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Requires:

Steps to get this running:
1. You will need an S3 bucket created with write access.
1. Run `build.sh` - this builds the app JAR in gradle and then builds a Docker image containing the native binary.
1. Run `build.sh` - this builds the native image
1. Make a copy of `http4kbox.env.example` named `http4kbox.env` and complete the required values.
1. Run `run.sh` - this runs 2 containers:
1. A http->https proxy - this is required because GraalVM currently does not support https.
2. The app, which will run by default at [http://localhost:10000].
1. Run `run.sh`
26 changes: 19 additions & 7 deletions native/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.graalvm.buildtools.gradle.tasks.BuildNativeImageTask

plugins {
id("org.graalvm.buildtools.native") version "0.9.28"
Expand All @@ -20,14 +21,25 @@ graalvmNative {
imageName.set("http4kbox")
mainClass.set("http4kbox.NativeServerKt")
useFatJar.set(true)
buildArgs.add("-H:ResourceConfigurationFiles=/${project.projectDir}/src/main/resources/native/resource-config.json")
buildArgs.add("--enable-http")
buildArgs.add("--enable-url-protocols=https")
}
}
}

tasks.named<ShadowJar>("shadowJar") {
archiveBaseName.set(project.name)
archiveClassifier.set(null as String?)
archiveVersion.set(null as String?)
mergeServiceFiles()
}
tasks {
named<ShadowJar>("shadowJar") {
archiveBaseName.set("all")
archiveClassifier.set(null as String?)
archiveVersion.set(null as String?)
mergeServiceFiles()
}

named("generateResourcesConfigFile") {
dependsOn(named("shadowJar"))
}

named<BuildNativeImageTask>("nativeCompile") {
classpathJar.set(File("./build/libs/all.jar"))
}
}
4 changes: 1 addition & 3 deletions native/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

set -e

../gradlew shadowJar

docker build -t daviddenton/http4kbox-native -t daviddenton/http4kbox .
../gradlew :native:shadowJar :native:nativeCompile
21 changes: 0 additions & 21 deletions native/docker-compose.yml

This file was deleted.

1 change: 0 additions & 1 deletion native/foo.sh

This file was deleted.

10 changes: 0 additions & 10 deletions native/http4kbox.env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# set these environmental variables to run http4kbox, and then rename this file to http4kbox.env

# HTTP_PORT
HTTP_PORT=10000

# GraalVm does not currently support https, so we need to use a http-https proxy to switch protocol
PROXY_HOST=proxy

# just the bucket name - not the entire URL
AWS_BUCKET=myGreatBucket

# AWS
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=12345
AWS_SECRET_ACCESS_KEY=67890
18 changes: 0 additions & 18 deletions native/nginx.conf

This file was deleted.

6 changes: 0 additions & 6 deletions native/proxy.Dockerfile

This file was deleted.

6 changes: 1 addition & 5 deletions native/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

set -e

export $(cat http4kbox.env | xargs)

echo "http4kbox will run at: http://localhost:${HTTP_PORT}"
docker-compose build
docker-compose up
export $(cat ./http4kbox.env | xargs) && ./build/native/nativeCompile/http4kbox

0 comments on commit 0a160b8

Please sign in to comment.