diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..0b6f4ab --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,19 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v4 + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + release-type: rust diff --git a/Dockerfile b/Dockerfile index 8674acd..b4180cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY front /app/front/ COPY .sqlx /app/.sqlx RUN cargo build --release -FROM ubuntu:24.04 +FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/release/millennium_falcon . ENTRYPOINT [ "./millennium_falcon" ] diff --git a/Readme.md b/Readme.md index cf81fde..c26dfaf 100644 --- a/Readme.md +++ b/Readme.md @@ -1,10 +1,24 @@ # Tell me the odds + + +- [Tell me the odds](#tell-me-the-odds) + - [Architecture](#architecture) + - [Domain model](#domain-model) + - [Domain services](#domain-services) + - [Application services](#application-services) + - [Infrastructure service](#infrastructure-service) + - [Technology stack](#technology-stack) + - [CI](#ci) + - [Test](#test) + - [TODO](#todo) + + Solution of the [developer-test](https://github.com/lioncowlionant/developer-test). With a recent version of rust (tested with 1.75.0), you can build the project with `cargo build --release`. Then you can run the cli with `./target/release/give-me-the-odds examples/millennium-falcon.json examples/example2/empire.json` and the webserver with `./target/release/millennium_falcon examples/millennium-falcon.json`. -Note that when starting, the webserver will create a folder `logs` containing a file `millennium.log.{date}` with the log of the server. stdio will be pretty silent if everything goes well. The server will be listening on `127.0.0.1:8000`. +Note that when starting, the webserver will create a folder `logs` containing a file `millennium.log.{date}` with the log of the server. stdio will be pretty silent if everything goes well. The server will be listening on `0.0.0.0:8000`. It is also possible to start the server with docker by running `docker build -t millennium-falcon .` then `docker run -it --rm -v ./logs:/app/logs -v ./examples:/app/examples -p 0.0.0.0:8000:8000 millennium-falcon examples/millennium-falcon.json` @@ -14,12 +28,12 @@ and the cli by running `docker build -t give-me-the-odds -f cli.Dockerfile .` th The code follows the onion architecture. More specifically, the code is divided into 4 sections: -- Domain model +- Domain models - Domain services - Application services - Infrastructure services -### Domain model +### Domain models Contains the definitions of `PlanetId`, `GalaxyRoutes`, `PlanetCatalog` and `BountyHunterPlanning`. @@ -31,7 +45,7 @@ Contains the public definition of `compute_probability_of_success`, and some pri Contains the definition of `MillenniumFalconData` and `EmpireData` matching the json formats specified in the requirements of the app, and `Route` matching the database data format (but without db-related types or field) and some code to bridge the data. -### Infrastructure service +### Infrastructure services Contains code to connect and read from the DB, process the CLI input and defining the webserver endpoints. @@ -45,7 +59,7 @@ This code was written in Rust 1.75.0. Notables dependencies are : - Tokio for the async engine - Tracing for the tracing (logging with span) -### CI +## CI 2 GitHub workflows are defined. @@ -65,14 +79,5 @@ Unit-tests are defined directly inside the code. Look for the `mod test`. Integr ## TODO -- bulding the docker image -- pushing to dockerhub with a dev tag - release-please - release protocol -- front -- Instrumented -- observability -- test: - - full black-box tests for the endpoints - - some scenario tests for the example provided in the documentation - - unit-test inside the code diff --git a/cli.Dockerfile b/cli.Dockerfile index 8f7bf4c..229229e 100644 --- a/cli.Dockerfile +++ b/cli.Dockerfile @@ -7,7 +7,7 @@ COPY front /app/front/ COPY .sqlx /app/.sqlx RUN cargo build --release -FROM ubuntu:24.04 +FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/release/give-me-the-odds . ENTRYPOINT [ "./give-me-the-odds" ]