https://github.com/jackdbd/pegthing
My implementation of the Peg Thing game in Clojure for the Brave and True
https://github.com/jackdbd/pegthing
clojure functional-programming
Last synced: 8 months ago
JSON representation
My implementation of the Peg Thing game in Clojure for the Brave and True
- Host: GitHub
- URL: https://github.com/jackdbd/pegthing
- Owner: jackdbd
- License: epl-2.0
- Created: 2020-04-03T14:36:44.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-02-03T21:15:48.000Z (almost 4 years ago)
- Last Synced: 2025-02-02T01:43:37.312Z (10 months ago)
- Topics: clojure, functional-programming
- Language: Clojure
- Homepage:
- Size: 197 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Peg Thing
[](https://travis-ci.org/jackdbd/pegthing)
A game developed for the Functional Programming chapter of [Clojure for the Brave and True](https://www.braveclojure.com/functional-programming/).
.


## Usage
This project uses the [Clojure tools CLI](https://clojure.org/reference/deps_and_cli) and [tools.build](https://clojure.org/guides/tools_build).
Play the game:
```sh
clj -X:play
```
## Build
In order to build the uberjar using [tools.build](https://clojure.org/guides/tools_build) you will need Clojure CLI 1.10.3.933 or higher. Download the latest version from [here](https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools).
```sh
curl -O https://download.clojure.org/install/linux-install-1.10.3.1075.sh
chmod +x linux-install-1.10.3.1075.sh
sudo ./linux-install-1.10.3.1075.sh
```
Running a tool with `-T` will create a classpath that does not include the project `:paths` and `:deps`. Using `-T:build` will use only the `:paths` and `:deps` from the `:build` alias.
Build the uberjar using tools.build:
```sh
clj -T:build uber
# or, equivalently
clj -X:uberjar
```
Then run the standalone uberjar:
```sh
java -jar target/pegthing.core-1.2.9-standalone.jar
```
## Tests
Run all tests with [kaocha](https://github.com/lambdaisland/kaocha):
```sh
bin/kaocha
# for a more verbose output, use this reporter
bin/kaocha --reporter kaocha.report/documentation
```
## Containerize the app
Create the container image using [pack](https://github.com/buildpacks/pack) and the [Paketo Tiny Builder](https://github.com/paketo-buildpacks/tiny-builder) (`BP` stands for Buildpack).
```sh
pack build pegthing:latest --builder paketobuildpacks/builder:tiny \
--env BP_JVM_TYPE=JRE \
--env BP_JVM_VERSION=11 \
--env BP_CLJ_TOOLS_BUILD_ARGUMENTS="-T:build uber"
```
Configuration with build-time environment variables:
- [Paketo BellSoft Liberica Buildpack](https://github.com/paketo-buildpacks/bellsoft-liberica#configuration)
- [Paketo Clojure Tools Buildpack](https://github.com/paketo-buildpacks/clojure-tools/blob/main/README.md#configuration)
Play the game inside a container:
```sh
docker run --rm --interactive --tty pegthing:latest
```
Inspect the generated container image with [dive](https://github.com/wagoodman/dive). For example you could try building the container image with `--env BP_JVM_TYPE=JDK` first, and `--env BP_JVM_TYPE=JRE` second. You will see that the container image containing the JRE is much smaller than the one containing the JDK.
```sh
dive pegthing:latest
```