diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..5d407f808 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# ignore everything +* + +# allow only what we need +!commafeed-server/target/commafeed.jar +!commafeed-server/config.yml.example diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72f821bde..0553958fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,28 +1,49 @@ name: Java CI -on: [push] +on: [ push ] jobs: build: runs-on: ubuntu-latest strategy: matrix: - java: ["8", "11", "17"] + java: [ "8", "11", "17" ] steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Java uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: "temurin" cache: "maven" + - name: Build with Maven run: mvn --batch-mode --update-snapshots verify + - uses: actions/upload-artifact@v3 if: ${{ matrix.java == '8' }} with: name: commafeed.jar path: commafeed-server/target/commafeed.jar + + # Docker + - name: Login to Container Registry + if: ${{ github.ref_type == 'tag' && matrix.java == '8' }} + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker build and push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.ref_type == 'tag' && matrix.java == '8' }} + tags: | + ghcr.io/athou/commafeed:latest + ghcr.io/athou/commafeed:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..73873b0f0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM openjdk:17-alpine + +RUN mkdir -p /commafeed/data +VOLUME /commafeed/data + +ENV CF_SESSION_PATH=/commafeed/data/sessions + +COPY commafeed-server/target/commafeed.jar . +COPY commafeed-server/config.yml.example config.yml + +EXPOSE 8082 +CMD ["java", "-Djava.net.preferIPv4Stack=true", "-jar", "commafeed.jar", "server", "config.yml"] diff --git a/commafeed-server/config.yml.example b/commafeed-server/config.yml.example index 944f877d2..b2d73eb1d 100644 --- a/commafeed-server/config.yml.example +++ b/commafeed-server/config.yml.example @@ -87,7 +87,7 @@ app: database: driverClass: org.h2.Driver - url: jdbc:h2:/home/commafeed/db + url: jdbc:h2:/commafeed/data/db user: sa password: sa properties: