chore: add Docker support for running the web host
This commit is contained in:
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
.gradle
|
||||||
|
.gradle-user
|
||||||
|
.idea
|
||||||
|
.kotlin
|
||||||
|
build
|
||||||
|
kls_database.db
|
||||||
|
scripts/.host-api-token
|
||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
ARG BUILD_IMAGE=gradle:9.0.0-jdk17
|
||||||
|
ARG RUNTIME_IMAGE=eclipse-temurin:17-jre
|
||||||
|
|
||||||
|
FROM ${BUILD_IMAGE} AS build
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
COPY gradlew gradlew
|
||||||
|
COPY gradle gradle
|
||||||
|
COPY build.gradle.kts settings.gradle.kts ./
|
||||||
|
COPY src src
|
||||||
|
|
||||||
|
RUN ./gradlew --no-daemon clean installDist
|
||||||
|
|
||||||
|
FROM ${RUNTIME_IMAGE}
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=build /workspace/build/install/kotlin-scripts-host /app/kotlin-scripts-host
|
||||||
|
RUN mkdir -p /app/scripts
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/kotlin-scripts-host/bin/kotlin-scripts-host"]
|
||||||
|
CMD ["--port=8080", "--scripts-dir=/app/scripts"]
|
||||||
20
README.md
20
README.md
@@ -119,3 +119,23 @@ Create/Edit/Delete behavior:
|
|||||||
Editor selection:
|
Editor selection:
|
||||||
- First uses `$EDITOR`
|
- First uses `$EDITOR`
|
||||||
- Fallback to first available of `nvim`, `vim`, `nano`
|
- Fallback to first available of `nvim`, `vim`, `nano`
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
Build image:
|
||||||
|
```bash
|
||||||
|
docker build -t slhaf-hub:latest .
|
||||||
|
```
|
||||||
|
|
||||||
|
Run container (mount local scripts directory):
|
||||||
|
```bash
|
||||||
|
docker run --rm -p 8080:8080 \
|
||||||
|
-v /tmp/kotlin-scripts/scripts:/app/scripts \
|
||||||
|
-e HOST_API_TOKEN=your-token \
|
||||||
|
slhaf-hub:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Then call APIs:
|
||||||
|
```bash
|
||||||
|
curl http://127.0.0.1:8080/health
|
||||||
|
curl -H "Authorization: Bearer your-token" http://127.0.0.1:8080/scripts
|
||||||
|
```
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set("work.slhaf.hub.CliHostKt")
|
mainClass.set("work.slhaf.hub.WebHostKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
val runCli by tasks.registering(JavaExec::class) {
|
val runCli by tasks.registering(JavaExec::class) {
|
||||||
|
|||||||
Reference in New Issue
Block a user