{"id":22878577,"url":"https://github.com/scblur869/car-api","last_synced_at":"2026-04-17T10:06:02.689Z","repository":{"id":149838900,"uuid":"613027169","full_name":"scblur869/car-api","owner":"scblur869","description":"springboot api for testing with 1000 mock vehicle data","archived":false,"fork":false,"pushed_at":"2023-03-27T13:18:37.000Z","size":35890,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T20:39:36.649Z","etag":null,"topics":["api-rest","containerization","docker-image","java","springboot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scblur869.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-12T17:20:37.000Z","updated_at":"2023-03-15T18:30:53.000Z","dependencies_parsed_at":"2023-06-04T19:15:42.164Z","dependency_job_id":null,"html_url":"https://github.com/scblur869/car-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scblur869%2Fcar-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scblur869%2Fcar-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scblur869%2Fcar-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scblur869%2Fcar-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scblur869","download_url":"https://codeload.github.com/scblur869/car-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246482234,"owners_count":20784658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","containerization","docker-image","java","springboot"],"created_at":"2024-12-13T16:29:50.654Z","updated_at":"2025-10-24T17:34:59.744Z","avatar_url":"https://github.com/scblur869.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Car API based on spring-boot\n  * uses h2 to store 1000 records of vehicle data\n  * mock vehicle data is included /src/main/resources/cars.json\n  * getting the pre-built docker image (docker hub)\n  ```console\n   docker pull springfieldm14/car-api\n   ```\n### endpoints\n```java\n @GetMapping(\"/cars/list\")\n @GetMapping(\"/cars/by-year/{year}\")\n @GetMapping(\"/cars/by-model/{model}\")\n @PostMapping(path = \"/new-car\", consumes = MediaType.APPLICATION_JSON_VALUE, produces = \"application/json\")\n ```\n\nJSON post raw body for /new-car\n ```json\n{\n\"vin\": \"32345234444\",\n\"make\": \"honda\",\n\"model\": \"pilot\",\n\"color\": \"silver\",\n\"year\": \"2019\"\n}\n ```\n## Building and Running the API as a container\n\n## example single and two-stage build of the container\n### clone this repo\n```console\n  git clone https://github.com/scblur869/car-api.git\n  ```\n## build the container locally using docker:\n### (single stage) --single build, larger image size\n  - would not do in a deployment. only for local developer builds\n  - just meant to show the lazy dev way :-)\n```console\n  cd car-api\n  docker build -f Dockerfile.dev --tag dev-api . --no-cache\n  ```\n### view the image in docker\n```console\ndocker images\n\nREPOSITORY     TAG       IMAGE ID       CREATED         SIZE\ndev-api      latest    31bc0fec47fb    2 days ago       268MB\n  ```\n\n### (two stage) --smaller and more lean image size, enough to run the app only\n### notice the image size difference as compared to the single stage above\n - this should be the method for deployment (dev,test,prod)\n```console\ndocker build -f Dockerfile --tag myapi . --no-cache\ndocker images\n\nREPOSITORY     TAG       IMAGE ID       CREATED         SIZE\nmyapi        latest    4424f99b0240    2 days ago        144MB\n  ```\n\n### run the container as an interactive pseudo-TTY to validate image startup\n- meant more for testing or interactive stdin session\n```console\n  docker run -it -p 8080:8080 --name car-api myapi:latest\n  ```\n### runs the container detatched and removes it when it terminates\n- detached works well for normal deployments\n```console\n(base) ➜  car-api git:(main) ✗ docker run -d --rm --name car-api myapi:latest           \n835f18b2996189e1e626eba916ca51883d4f9948823e2ec5532a87af89631f59\n ```\n\n### viewing the container running status\n```console\n\n(base) ➜  car-api git:(main) ✗ docker ps\nCONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS        PORTS      NAMES\n835f18b29961   myapi     \"sh -c 'java ${JAVA_…\"   2 seconds ago   Up 1 second   8080/tcp   car-api\n(base) ➜  car-api git:(main) ✗ \n  ```\n\n\n### view the container stdout logs\n```bash\ndocker logs car-api\n\n  .   ____          _            __ _ _\n /\\\\ / ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\n \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\n  '  |____| .__|_| |_|_| |_\\__, | / / / /\n =========|_|==============|___/=/_/_/_/\n :: Spring Boot ::        (v2.2.3.RELEASE)\n\n2023-03-15 15:44:38.026  INFO 1 --- [           main] com....\n...\n...\n...\ncars loaded!\n  ```\n\n\n### to test the running container\nhttp://localhost:8080/cars/list\n\n### stopping the container\n```console\ndocker stop car-api\n  ```\n\n\n## push to a registry and deploy to EKS / kubernetes\n### deploy to AWS ECR (you must provide your AWS account id and repo name for the ecr endpoint!)\n * docker login to aws ecr via:\n ```console\n  aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com\n  ```\n### tag and push to ecr\n```console\n  docker tag myapi:latest aws_account_id.dkr.ecr.region.amazonaws.com/myapi:latest\n  docker push aws_account_id.dkr.ecr.region.amazonaws.com/myapi:latest\n  ```\n\n### Kubernetes deployment requirements to deploy\n- need to have access to kubernetes and kubectl\n- need to update the deployment.yaml with a valid docker image path (ECR endpoint in previous step)\n- need to have an ingress controller installed on EKS / Kubernetes (NGINX, HAPROXY, TRAEFIK, AWS) **see INGRESS.md**\n- need to add an A ALIAS record (route53) that matches your ingress resource host  and the A record / dns name of the load balancer (nlb /alb) **See INGRESS.md**\n\n example install\n ```console\n kubectl create namespace car\n ```\n ```console\n kubectl -n car apply -f deployment.yaml\n ```\n ```console\n kubectl -n car apply -f service.yaml\n ```\n ```console\n kubectl -n car apply -f ingress.yaml\n ```\n### the last line assumes you have a dedicated nginx-ingress controller listening for an ingress resource\n\n\n## good reference on docker run\nhttps://docs.docker.com/engine/reference/run/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscblur869%2Fcar-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscblur869%2Fcar-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscblur869%2Fcar-api/lists"}