From 8268bd96922429858a5dc2f15dacb3656324edb3 Mon Sep 17 00:00:00 2001 From: Alberto Moretti Date: Tue, 16 Jun 2026 14:39:53 +0200 Subject: [PATCH] chore: default to port 8000 --- Dockerfile | 6 +++--- Makefile | 6 +++--- README.md | 6 +++--- openapi.yaml | 2 +- src/bin/pokedex-cli.rs | 12 ++++++------ src/config.rs | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7823d29..552d302 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,11 +74,11 @@ COPY --from=builder /usr/local/bin/pokedex-api /usr/local/bin/pokedex-api ARG GIT_SHA=unknown ENV GIT_SHA=$GIT_SHA \ - BIND_ADDR=0.0.0.0:5000 + BIND_ADDR=0.0.0.0:8000 -EXPOSE 5000 +EXPOSE 8000 USER app HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD curl -fsS http://127.0.0.1:5000/health || exit 1 + CMD curl -fsS http://127.0.0.1:8000/health || exit 1 CMD ["pokedex-api"] diff --git a/Makefile b/Makefile index 34e135f..689bac4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CARGO ?= cargo DOCKER ?= docker IMAGE ?= pokedex-api TAG ?= local -BASE_URL ?= http://localhost:5000 +BASE_URL ?= http://localhost:8000 POKEMON ?= mewtwo PLATFORMS ?= linux/amd64,linux/arm64 GIT_SHA ?= $(shell git rev-parse HEAD 2>/dev/null || printf unknown) @@ -15,7 +15,7 @@ help: @printf 'Available targets:\n' @printf ' make run Run the API locally with cargo\n' @printf ' make docker-build Build the Docker image\n' - @printf ' make docker-run Run the Docker image on port 5000\n' + @printf ' make docker-run Run the Docker image on port 8000\n' @printf ' make cli-health Call /health through the CLI helper\n' @printf ' make cli-pokemon Call /pokemon/$${POKEMON} through the CLI helper\n' @printf ' make cli-translated Call /pokemon/translated/$${POKEMON} through the CLI helper\n' @@ -34,7 +34,7 @@ docker-build: $(DOCKER) build -t $(IMAGE) . docker-run: - $(DOCKER) run --rm -p 5000:5000 $(IMAGE) + $(DOCKER) run --rm -p 8000:8000 $(IMAGE) cli-health: $(CARGO) run --bin pokedex-cli -- health diff --git a/README.md b/README.md index 33e0a53..dd37271 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Then run the service: make run ``` -The API listens on `0.0.0.0:5000` by default. +The API listens on `0.0.0.0:8000` by default. ## CLI helper @@ -47,7 +47,7 @@ With the API running in another terminal, call it through the small helper binar make cli-health make cli-pokemon make cli-translated -make cli-pokemon POKEMON=pikachu BASE_URL=http://localhost:5000 +make cli-pokemon POKEMON=pikachu BASE_URL=http://localhost:8000 ``` ## Endpoints @@ -110,7 +110,7 @@ External contract tests are separated from the normal deterministic test suite. | Variable | Default | Description | | --------------------------- | ------------------------------------------- | -------------------------- | -| `BIND_ADDR` | `0.0.0.0:5000` | HTTP bind address | +| `BIND_ADDR` | `0.0.0.0:8000` | HTTP bind address | | `POKEAPI_BASE_URL` | `https://pokeapi.co/api/v2` | PokéAPI base URL | | `FUN_TRANSLATIONS_BASE_URL` | `https://api.funtranslations.mercxry.me/v1` | FunTranslations base URL | | `REQUEST_TIMEOUT_SECONDS` | `5` | Upstream HTTP timeout | diff --git a/openapi.yaml b/openapi.yaml index d06d54f..d289367 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4,7 +4,7 @@ info: version: 0.1.0 description: REST API for the TrueLayer Pokémon challenge. servers: - - url: http://localhost:5000 + - url: http://localhost:8000 paths: /health: get: diff --git a/src/bin/pokedex-cli.rs b/src/bin/pokedex-cli.rs index 2d087de..444eef1 100644 --- a/src/bin/pokedex-cli.rs +++ b/src/bin/pokedex-cli.rs @@ -4,7 +4,7 @@ use std::{env, process::ExitCode, time::Duration}; -const DEFAULT_BASE_URL: &str = "http://localhost:5000"; +const DEFAULT_BASE_URL: &str = "http://localhost:8000"; const REQUEST_TIMEOUT: Duration = Duration::from_secs(10); #[tokio::main] @@ -166,7 +166,7 @@ fn trim_base_url(base_url: &str) -> String { } const fn usage() -> &'static str { - "Usage:\n pokedex-cli [--base-url URL] health\n pokedex-cli [--base-url URL] metrics\n pokedex-cli [--base-url URL] pokemon \n pokedex-cli [--base-url URL] translated \n\nExamples:\n pokedex-cli pokemon mewtwo\n pokedex-cli translated mewtwo\n pokedex-cli --base-url http://localhost:5000 pokemon pikachu" + "Usage:\n pokedex-cli [--base-url URL] health\n pokedex-cli [--base-url URL] metrics\n pokedex-cli [--base-url URL] pokemon \n pokedex-cli [--base-url URL] translated \n\nExamples:\n pokedex-cli pokemon mewtwo\n pokedex-cli translated mewtwo\n pokedex-cli --base-url http://localhost:8000 pokemon pikachu" } #[derive(Debug, thiserror::Error)] @@ -204,23 +204,23 @@ mod tests { } } ); - assert_eq!(args.url(), "http://localhost:5000/pokemon/mewtwo"); + assert_eq!(args.url(), "http://localhost:8000/pokemon/mewtwo"); } #[test] fn parses_custom_base_url_and_translated_command() { let args = parse_args([ "--base-url", - "http://localhost:5000/", + "http://localhost:8000/", "translated", "mr-mime", ]) .expect("args should parse"); - assert_eq!(args.base_url, "http://localhost:5000"); + assert_eq!(args.base_url, "http://localhost:8000"); assert_eq!( args.url(), - "http://localhost:5000/pokemon/translated/mr-mime" + "http://localhost:8000/pokemon/translated/mr-mime" ); } diff --git a/src/config.rs b/src/config.rs index 544fbe1..3779413 100644 --- a/src/config.rs +++ b/src/config.rs @@ -66,7 +66,7 @@ fn env_or_string(name: &'static str, default: &str) -> String { } fn default_bind_addr() -> SocketAddr { - SocketAddr::from(([0, 0, 0, 0], 5000)) + SocketAddr::from(([0, 0, 0, 0], 8000)) } const fn validate_rate_limit(per_second: f64, burst: u32) -> Result<(), ConfigError> { @@ -101,7 +101,7 @@ mod tests { fn default_config_is_valid_for_local_development() { let config = AppConfig::default_local(); - assert_eq!(config.bind_addr.port(), 5000); + assert_eq!(config.bind_addr.port(), 8000); assert_eq!(config.pokeapi_base_url, "https://pokeapi.co/api/v2"); assert!((config.rate_limit_per_second - 20.0).abs() < f64::EPSILON); }