The restaurant management application as described in Code that fits in your head, but with my personal biases, including being written in Clojure.
- Clone the repo
git clone git@github.com:HughPowell/restaurant.git
- Start your REPL
- Use the rich comment block in the
restaurant
namespace to start the service.
Ideally all the following linters and code formatters should be integrated into your development environment for the fastest possible feedback. If that isn't the case then you can run them from the command line.
3 linters are used to check the code of this project clj-kondo,
eastwood
and splint (the successor to kibit). For maximum speed it is assumed the
clj-kondo
pre-built binary
is installed on the system and accessible to your user.
clj-kondo --lint deps.edn src dev infra
eastwood
and splint
don't have pre-built binaries and are therefore run using aliases
clojure -M:dev:test:linters -m eastwood.lint
clojure -M:dev:test:linters -m noahtheduke.splint
To lint the infrastructure replace the dev
and test
aliases with the build
or upgade
.
The code formatter of choice is cljfmt. This also comes with a pre-built binary which is expected to be installed on the system and accessible to your user.
cljfmt check deps.edn src dev infra
To build the application as an uberjar run
clojure -X:build uber
To run the uberjar
java -jar target/restaurant.jar
To run the uberjar with the OpenTelemetry agent
sudo wget -O /usr/local/lib/opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
java \
-Djdk.tracePinnedThreads=full \
-javaagent:/usr/local/lib/opentelemetry-javaagent.jar \
-Dotel.resource.attributes=service.name=restaurant-dev \
-jar \
target/restaurant.jar
To build the application in a docker container run
docker build --file infra/Dockerfile --network host --tag restaurant:dev .
To run the container
docker run --publish 3000:3000 restaurant:dev