This tutorial is about how to run a Molecular Postgres PgAdmin on Docker and Next on our local using Bolt. Molecular is used for the backend, and Next is for the frontend. For the database, we have used Postgres, and for the management of Postgres, we have used PgAdmin. Below is the video showing how to run this tutorial.
Table of Contents
Objectives
Project Structure
Initialising the project using Bolt
Adding all services as a Bolt Service
Adding Ingress
Running the Project
Services that are running on Docker
Services that are running on Local
Listing Bolt Services
Monitoring Service Logs
Stopping Your Project
Repo Link
Objectives
Here we have created a project where we have four folder named frontend, backend, postgres and pgadmin which has a next app with postgres, backend and pgadmin as services.
Our Main objectives are:
Run this project using bolt in local machine.
Run this project using bolt in docker.
Project Structure
The project structure of our app is as follows:
# Below's the directory structure of our project.
next-moleculerjs-postgres-pgadmin/
╰─➤ services/
╰─➤ backend
╰─➤ frontend
╰─➤ pgadmin
╰─➤ postgres
╰─➤ .env
╰─➤ .env.tpl
╰─➤ .bolt.nginx.conf
╰─➤ bolt.yaml
╰─➤ Readme.md
Initialising the project using Bolt
At first we have initialised the project by running bolt init command to create bolt.yaml file.
$ cd next-moleculerjs-postgres-pgadmin
$ bolt init
It has created a bolt.yaml file in our project's root directory.
envfile: .env.tpl
project_id:"1690971331922"
project_name: next-moleculerjs-postgres-pgadmin
services:null
ingress:null
Adding all the services as Bolt Service
Now in order to add each and every services we have executed the following commands:
$ bolt service:add backend services/backend
Creating app in backend
Scanning source code
Detected NodeJS app
Installed backend servicein backend
Verifying metadata for other services..
Metadata verified
$ bolt service:add frontend services/frontend
Creating app in frontend
Scanning source code
Detected NextJS app
Installed backend servicein backend
Verifying metadata for other services..
Metadata verified
$ bolt service:add postgres services/postgres
Creating app in postgres
Scanning source code
Detected Postgres app
Installed postgres servicein postgres
Verifying metadata for other services..
Metadata verified
$ bolt service:add pgadmin services/pgadmin
Creating app in pgadmin
Scanning source code
Detected pgadmin app
Installed pgadmin servicein pgadmin
Verifying metadata for other services..
Metadata verified
Bolt service:add command runs and automatically detects the type of service you are using and creates a bolt.service.yaml template init & includes the same into your bolt.yaml file.
# This is how bolt.yaml file looks after executing the above commands
envfile: .env.tpl
project_id:"1690971331922"
project_name: next-moleculerjs-postgres-pgadmin
services:
postgres:
path: ./services/postgres
pgadmin:
path: ./services/pgadmin
backend:
path: ./services/backend
frontend:
path: ./services/frontend
ingress:null
Each services has their own bolt.service.yaml file, here we have configured it as per our requirement.
We have configured run.dockerfile and build.dockerfile for PGAdmin, Postgres and Backend to run them in Docker. And
frontend to run on Local.
Adding Ingress
We have added ingress configuration for our project inside bolt.yaml file to access our services from outside.
# This is how bolt.yaml file looks finally after adding ingress configuration
# The following command will run the service as per the configuration in bolt.yaml file
$ bolt up
Now this command will first run the services as per their configurations inside bolt.service.yaml for each each serivce. After
that, bolt will create a nginx configuration file named as bolt.nginx.conf in your project's root directory and run the Nginx
server on your host machine's Docker.
Services that are running on docker
Below's our bolt.service.yaml files for all three services configured to run on docker for your reference.
# This is bolt.service.yaml file for PGAdmin
container_name: pgadmin
stateless:true
default_service_runner: docker
service_discovery_offset:
-8080
supported_service_runners:
- local
- docker
service_runners:
local:
envfile: .env
build: npm run install --workspaces --if-present && npm run dev