Skip to content

Commit

Permalink
Merge pull request #111 from betarixm/fix/packaging
Browse files Browse the repository at this point in the history
Package JARs with shell scripts
  • Loading branch information
betarixm committed Dec 11, 2023
2 parents ddbc5be + 2d77e11 commit f071b32
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 47 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: master
path: master/target/scala-2.13/master.jar
path: build/master
- uses: actions/upload-artifact@v3
with:
name: worker
path: worker/target/scala-2.13/worker.jar
path: build/worker
- name: Release development build
if: github.ref == 'refs/heads/develop'
uses: marvinpinto/action-automatic-releases@latest
Expand All @@ -61,8 +61,8 @@ jobs:
prerelease: true
title: "Development Build"
files: |
master/target/scala-2.13/master.jar
worker/target/scala-2.13/worker.jar
build/master
build/worker
- name: Release production build
if: github.ref == 'refs/heads/main'
uses: marvinpinto/action-automatic-releases@latest
Expand All @@ -71,5 +71,5 @@ jobs:
automatic_release_tag: "latest"
title: "Production Build"
files: |
master/target/scala-2.13/master.jar
worker/target/scala-2.13/worker.jar
build/master
build/worker
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# Icon must end with two \r
Icon


# Thumbnails
._*

Expand Down Expand Up @@ -109,4 +108,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/macos,scala,sbt,intellij,visualstudiocode,windows
# End of https://www.toptal.com/developers/gitignore/api/macos,scala,sbt,intellij,visualstudiocode,windows

build/*
!build/.gitkeep
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@
To build the project, follow these instructions:

1. Clone the repository.
1. Run `sbt clean`.
1. Run `sbt assembly`.

### Run

To launch a master node and worker nodes, follow these steps:

1. Build the project using the instructions above.
1. Run [`master` script](bin/master) with parameters.
- For example, execute `./master <NUMBER_OF_WORKERS>` from the [`bin`](bin) directory.
1. Run [`worker` script](bin/worker) with parameters.
- For example, `./worker <MASTER_HOST>:<MASTER_PORT> -I <INPUT_DIRECTORY> <INPUT_DIRECTORY> <...> -O <OUTPUT_DIRECTORY>` from the [`bin`](bin) directory.
1. Ensure that `master` and `worker` executables are present in the [`build`](build) directory.
1. Run [`master`](build/master) with parameters.
- For example, `./master <NUMBER_OF_WORKERS>`.
1. Run [`worker`](build/worker) with parameters.
- For example, `./worker <MASTER_HOST>:<MASTER_PORT> -I <INPUT_DIRECTORY> <INPUT_DIRECTORY> <...> -O <OUTPUT_DIRECTORY>`.

It is possible to run jar files downloaded from releases page instead of building the project.
Note that built executables consist of shell scripts and JAR files, and thus require systems that support running shell scripts and have Java installed.

## Development

Expand Down
14 changes: 0 additions & 14 deletions bin/master

This file was deleted.

14 changes: 0 additions & 14 deletions bin/worker

This file was deleted.

10 changes: 8 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sbtassembly.AssemblyPlugin.defaultShellScript

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "2.13.12"
Expand All @@ -14,6 +16,10 @@ ThisBuild / assembly / assemblyMergeStrategy := {
case x => (assembly / assemblyMergeStrategy).value(x)
}

ThisBuild / assemblyPrependShellScript := Some(
defaultShellScript
)

lazy val commonSettings = Seq(
name := "cs434-project",
idePackagePrefix := Some("kr.ac.postech.paranode"),
Expand Down Expand Up @@ -61,7 +67,7 @@ lazy val master = (project in file("master"))
.settings(
commonSettings,
idePackagePrefix := Some("kr.ac.postech.paranode.master"),
assembly / assemblyJarName := "master.jar"
assembly / assemblyOutputPath := file("build/master")
)
.dependsOn(core)
.dependsOn(rpc)
Expand All @@ -70,7 +76,7 @@ lazy val worker = (project in file("worker"))
.settings(
commonSettings,
idePackagePrefix := Some("kr.ac.postech.paranode.worker"),
assembly / assemblyJarName := "worker.jar"
assembly / assemblyOutputPath := file("build/worker")
)
.dependsOn(core)
.dependsOn(rpc)
Expand Down
Empty file added build/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions docker/master/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ ENV NUMBER_OF_WORKERS=${NUMBER_OF_WORKERS}

WORKDIR /app

COPY --from=builder /app/master/target/scala-2.13/master.jar .
COPY --from=builder /app/build/master .

ENTRYPOINT java -jar master.jar ${NUMBER_OF_WORKERS}
ENTRYPOINT ./master ${NUMBER_OF_WORKERS}
4 changes: 2 additions & 2 deletions docker/worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ COPY docker/worker/data/${WORKER_ID} /data

WORKDIR /app

COPY --from=builder /app/worker/target/scala-2.13/worker.jar .
COPY --from=builder /app/build/worker .

ENTRYPOINT java -jar worker.jar ${MASTER_HOST}:${MASTER_PORT} -I /data/0 /data/1 -O /output/
ENTRYPOINT ./worker ${MASTER_HOST}:${MASTER_PORT} -I /data/0 /data/1 -O /output/

0 comments on commit f071b32

Please sign in to comment.