From e5676b8d4bd196ac0a955e2e2b25c4ede48d1828 Mon Sep 17 00:00:00 2001 From: e3ndr <33337309+e3ndr@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:28:07 -0600 Subject: [PATCH] Docker :eyes: --- .github/workflows/docker.yml | 37 ++++++++++++++++++++++++++++++++++++ Dockerfile | 13 +++++++++++++ compose.yaml | 10 ++++++++++ docker_launch.sh | 6 ++++++ 4 files changed, 66 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile create mode 100644 compose.yaml create mode 100644 docker_launch.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5e6332c --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,37 @@ +name: docker + +on: + push: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout code. + uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: "11" + distribution: "temurin" + cache: maven + + - name: Compile the code. + run: mvn clean package + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: Build & Push image + run: docker buildx build --platform=linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x --tag ghcr.io/casterlabs/dbohttp:latest --push . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7fafbf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM eclipse-temurin:11-jre-ubi9-minimal +WORKDIR /home/container + +LABEL org.opencontainers.image.source="https://github.com/casterlabs/dbohttp" + +# code +COPY ./target/dbohttp.jar /home/container +COPY ./docker_launch.sh /home/container +RUN chmod +x docker_launch.sh + +# entrypoint +CMD [ "./docker_launch.sh" ] +EXPOSE 8000/tcp \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..71d7912 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,10 @@ +services: + katana: + image: ghcr.io/casterlabs/dbohttp:latest + restart: always + environment: + JWT_SECRET: "abc123" + volumes: + - ./database.sqlite:/home/container/database.sqlite + ports: + - 9000:8000 # Change 9000 to your liking. diff --git a/docker_launch.sh b/docker_launch.sh new file mode 100644 index 0000000..bcc0989 --- /dev/null +++ b/docker_launch.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +rm /home/container/config.json +echo '{"database": {"file": "/home/container/database.sqlite","driver": "SQLITE","accessTimeoutSeconds": 30},"debug": false,"jwtSecret": "$JWT_SECRET","port": 8000,"heartbeatUrl": null,"heartbeatIntervalSeconds": 15,"ssl": null}' >> /home/container/config.json + +java -XX:+CrashOnOutOfMemoryError -jar dbohttp.jar