Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,28 @@
name: build

on: [ push ]

jobs:

server:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v1

- uses: actions/cache@v4
with:
path: ~/.cache/coursier/v1
key: ${{ runner.os }}-coursier-${{ hashFiles('**/build.sbt') }}

- name: Set up java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- name: Set up sbt
uses: sbt/setup-sbt@v1

- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sbt server/stage

- uses: actions/checkout@v3
- name: Compile
run: ./mill __.compile
- name: Build distributable
run: ./mill server.assembly
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push images
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/torrentdam/server:${{ github.sha }}, ghcr.io/torrentdam/server:latest
27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
name: release

on:
push:
tags:
- 'v*'

jobs:

release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v1

- name: Set up java
uses: actions/setup-java@v2.1.0
with:
distribution: adopt
java-version: 17
java-package: jre

- name: Publish
- uses: actions/checkout@v3
- name: Release
env:
SONATYPE_CREDS: ${{ secrets.SONATYPE_CREDS }}
PGP_SECRET_KEY: ${{ secrets.PGP_SECRET_KEY }}
MILL_SONATYPE_USERNAME: ${{ secrets.MILL_SONATYPE_USERNAME }}
MILL_SONATYPE_PASSWORD: ${{ secrets.MILL_SONATYPE_PASSWORD }}
MILL_PGP_SECRET_BASE64: ${{ secrets.MILL_PGP_SECRET_BASE64 }}
MILL_PGP_PASSPHRASE: ${{ secrets.MILL_PGP_PASSPHRASE }}
run: |
echo ${PGP_SECRET_KEY} | base64 --decode | gpg --import
export VERSION=${GITHUB_REF#*/v}
export VERSION=${GITHUB_REF#*/v}
echo Publishing $VERSION
sbt protocolJS/publishSigned
./mill mill.javalib.SonatypeCentralPublishModule/
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
target
out
.idea
.idea_modules
.metals
.bloop
.bsp
.vscode
node_modules
package-lock.json
logs
23 changes: 23 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Build/Test Commands

```bash
# Compile all modules
./mill __.compile

# Run the server
./mill server.run

# Build executable server JAR
./mill server.assembly

# Format code with Scalafmt
./mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources
```

## Project Structure

- **build.mill**: Mill build definition (primary)
- **protocol/**: Protocol message types shared with the web client
- **server/**: HTTP server entry point

Each module has `src/main/scala/`
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM eclipse-temurin:25-jre-noble

COPY ./server/target/universal/stage /opt/bittorrent-server

ENTRYPOINT ["/opt/bittorrent-server/bin/server", "-Dcats.effect.tracing.mode=none", "-J-XX:+UnlockExperimentalVMOptions", "-J-XX:+UseCompactObjectHeaders"]
COPY ./out/server/assembly.dest/out.jar /opt/torrentdam/server.jar
ENTRYPOINT ["java", \
"-Dcats.effect.tracing.mode=none", \
"-XX:+UnlockExperimentalVMOptions", \
"-XX:+UseCompactObjectHeaders", \
"-jar", \
"/opt/torrentdam/server.jar"]
85 changes: 85 additions & 0 deletions build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//| mill-version: 1.1.8
//| mill-jvm-version: temurin:21.0.6
import mill.*, scalalib.*, publish.*

object protocol extends CommonSettings {
def mvnDeps = Seq(
Deps.bittorrent.common,
Deps.upickle,
Deps.`scodec-bits`,
)
}

object server extends CommonSettings {
def moduleDeps = Seq(protocol)
def mvnDeps = Seq(
Deps.bittorrent.bittorrent,
Deps.bittorrent.dht,
Deps.`cats-effect`,
Deps.`fs2-io`,
Deps.http4s.core,
Deps.http4s.dsl,
Deps.http4s.server,
Deps.http4s.client,
Deps.`woof-core`,
Deps.`woof-slf4j`,
Deps.`cats-effect-cps`,
)
}

trait CommonSettings extends ScalaModule, PublishModule {
def scalaVersion = "3.8.3"
def scalacOptions = Seq(
"-source:future",
"-Xkind-projector:underscores",
)
def sources = Task.Sources(
moduleDir / "src" / "main" / "scala"
)
def resources = Task.Sources(
moduleDir / "src" / "main" / "resources"
)
def publishVersion = sys.env.getOrElse("VERSION", "SNAPSHOT")
def pomSettings = PomSettings(
description = "Bittorrent server protocol",
organization = "io.github.torrentdam.server",
url = "https://github.com/TorrentDam/server",
licenses = Seq(License.`Unlicense`),
versionControl = VersionControl.github("TorrentDam", "server"),
developers = Seq(
Developer("lavrov", "Vitaly Lavrov", "https://github.com/lavrov")
)
)
}

object Deps {
object Versions {
val bittorrent = "3.8.0"
val `cats-effect` = "3.6.0"
val fs2 = "3.12.2"
val `scodec-bits` = "1.2.4"
val upickle = "2.0.0"
val http4s = "1.0.0-M40"
val `cats-effect-cps` = "0.9.21"
val woof = "0.9.0"
}
object bittorrent {
private val org = "io.github.torrentdam.bittorrent"
val common = mvn"${org}::common::${Versions.bittorrent}"
val bittorrent = mvn"${org}::bittorrent::${Versions.bittorrent}"
val dht = mvn"${org}::dht::${Versions.bittorrent}"
}
val `cats-effect` = mvn"org.typelevel::cats-effect::${Versions.`cats-effect`}"
val `fs2-io` = mvn"co.fs2::fs2-io::${Versions.fs2}"
val `scodec-bits` = mvn"org.scodec::scodec-bits::${Versions.`scodec-bits`}"
val upickle = mvn"com.lihaoyi::upickle::${Versions.upickle}"
object http4s {
val core = mvn"org.http4s::http4s-core::${Versions.http4s}"
val dsl = mvn"org.http4s::http4s-dsl::${Versions.http4s}"
val server = mvn"org.http4s::http4s-ember-server::${Versions.http4s}"
val client = mvn"org.http4s::http4s-ember-client::${Versions.http4s}"
}
val `cats-effect-cps` = mvn"com.github.rssh::cps-async-connect-cats-effect::${Versions.`cats-effect-cps`}"
val `woof-core` = mvn"org.legogroup::woof-core::${Versions.woof}"
val `woof-slf4j` = mvn"org.legogroup::woof-slf4j::${Versions.woof}"
}
127 changes: 0 additions & 127 deletions build.sbt

This file was deleted.

Loading
Loading