Skip to content

Latest commit

 

History

History

catalog-mysql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

catalog-mysql

This module implements JPA backend for the Product Catalog Service, using MySQL as a backend database.

Building the Service

See main documentation page for instructions.

Running the Service

This implementation is slightly more complex to run, because it requires a MySQL instance to use as a data store.

First you will need to create a Docker network that will be used by both MySQL and the service containers, if you haven't done that already:

$ docker network create sockshop 

Then you can run MySQL container, but you need to assign it to the sockshop network created above, and give it a name that the service container expects (catalog-db in this case). You will also need to pass a number of environment variables to tell MySQL which database and user to create:

$ docker run --rm --name catalog-db --network sockshop \
      -e MYSQL_ALLOW_EMPTY_PASSWORD=true \
      -e MYSQL_DATABASE=catalog \
      -e MYSQL_USER=catalog \
      -e MYSQL_PASSWORD=pass \
      mysql:8.0.20

Note: The --rm flag above ensures that the container is removed automatically after it is stopped. This allows you to re-run the command above without having to remove the catalog-db container manually between runs.

Finally, you can start the service container in the same network:

$ docker run --network sockshop -p 7001:7001 ghcr.io/helidon-sockshop/catalog-mysql

Once the container is up and running, you should be able to access service API by navigating to http://localhost:7001/catalogue/.

As a basic test, you should be able to perform an HTTP GET against /catalogue/size endpoint:

$ curl http://localhost:7001/catalogue/size

which should return JSON response

{
  "size": 9
}

License

The Universal Permissive License (UPL), Version 1.0