recipes-manager
Backend service to manage recipes.
Recipes-manager supports managing recipes via API while persisting them in a database.
How to Use?
Deployment
We briefly describe two deployment options. First, a Kubernetes-based deployment, including the deployment of all other cooking-related tools. Secondly, a stand-alone deployment:
-
See https://github.com/ottenwbe/recipes-manager-deployment for how to run the whole suite of micro-services on a Kubernetes cluster, including the frontend and a database.
-
To run recipes-manager as standalone service (either amd64 or arm64):
-
Prepare a configuration file (see next section).
-
Start a database
docker run -d --name=db-recipes-manager -p 27018:27017 mongo:6
-
Run the container
docker run -p 8080:8080 --name=backend-recipes-manager -v <local-config>:/etc/recipes-manager/recipes-manager-config.yml ottenwbe/recipes-manager:v0.3.0
-
Check if everything is running:
curl localhost:8080/api/v1/recipes
-
Details about the API can then be checked in a browser:
localhost:8080/swagger/swagger_index.html
File-based Configuration
Configuration files are expected at ~/.recipes-manager/recipes-manager-config.yml
or /etc/recipes-manager/recipes-manager-config.yml
.
# Mandatory Configuration
recipeDB:
host: <db host>
# Optional Configuration
html:
address: <server listens on this address>
cors:
origin: <Access-Control-Allow-Origin>
drive: # To fetch recipes from Goolge Drive
connection:
secret:
file: <location of secret>
recipes:
folder: <folder name in drive>
ingredients: <name of ingredients section in the drive files>
instructions: <name of the instructions section in the drive files>
keycloak:
address: <address of keycloak sever>
clientSecret: <client secret>
clientID: <client id>
host: <host name>
enabled: <enable or disable keycloak feature>
log:
level: <log level>
source:
host: <source host, i.e., aka host of ui>
Configuration with Environment Variables
By prepending all variables (see file-based configuration) with GO_COOK_
the configuration can be set in the environment.
Development
Dependencies
Building recipes-manager
A Makefile supports the build process. This includes building a development and release version of the recipes-manager service. Furthermore, it includes building docker images to easily deploy the recipes-manager service.
Build Snapshot
make snapshot
Builds a fully functioning binary named recipes-manager-snapshot
. In contrast to the release version, there is still debugging informaiton included.
Build Release Version
make release
Builds a fully functioning binary named recipes-manager
.
Docker builds
make docker
Docker Tips and Tricks
-
If necessary, stop all container; i.e., if they hang
docker stop $(docker ps -a -q)
-
Remove all container and their volumes
docker rm -v $(docker ps -a -q)
API Documentation
Generate the Documentation
The Swagger API documentation is based on gin-swagger:
swag init --exclude vendor
Disclaimer
I created this project for the purpose of educating myself and personal use.
If you are interested in the outcome, feel free to contribute; this work is published under the MIT license.
Notice
The base MAKEFILE is adapted from: https://github.com/vincentbernat/hellogopher