container-based dynamic API assembling system. The architecture is not microservice. similar to modular monolithic. Image is like a modular synth(musical equipment), you can reassemble services, without stop the API server.
This program is mainly as a reverse proxy server. All services (containers) running in private network. Therefore, need to access to service through gateway.
-
Setting connect to your MySQL conf to /gateway/docker/.env
-
Create networks for public and private
docker network create --internal mossapi-nw-private
docker network create mossapi-nw-public
- Build image and create container.
docker build -t gateway <path to Dockerfile>
docker run --name gateway -p 9000:9000 --network mossapi-nw-private --network mossapi-nw-public -d gateway
- Develop REST API
- Port number must be 9000.
- You can use HTTP methods are "GET", "POST", "PUT", "DELETE".
- You can use URL param, getting url pattern is below.
http://service:9000/:param
-
Put execute file and dependencie files to root directory.
-
Make Contaier using admin from manager.
-
Access to your service
http://localhost:9000/<service>/
You can use an external MySQL database.
But if you want to use MySQL container, try this command.
docker build -t mysql <path to Dockerfile>
docker run --name mysql -p 3306:3306 -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=mossapi -v ./data:/var/lib/mysql -v ./conf:/etc/mysql/conf.d -d mysql
Management conteiner and database tables. You can simply make Dockerfile, docker container and database tables. I provide web-based UI admin.
On dvelopment.
go run . admin
On product.
./manager run . admin