This tutorial is about how to run a Nuxt.js Postgress and PgAdmin in a project on Docker using bolt. Below's the video showing how to run this tutorial.
Table of Contents
Objectives
Project Structure
Initialising the project using Bolt
Adding all the services as Bolt service
Running the Project
Running the Project on Docker
Listing Bolt Services
Monitoring Service Logs
Stopping Your Project
Repo Link
Objectives
Here we have created a project where we have three folder named todo_nuxt, postgres and pgadmin which has a nuxt app with postgres 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
# Below's the directory structure of our project.
todo_nuxt/
╰─➤ services/
╰─➤ pgadmin/...
╰─➤ postgres/...
╰─➤ todo_nuxt/...
╰─➤ .boltignore
╰─➤ .env
╰─➤ .env.tpl
╰─➤ bolt.yaml
Initialising the project using Bolt
At first we have initialised the project by running bolt init command to create bolt.yaml file.
$ cd todo_nuxt
$ bolt init
It has created a bolt.yaml file in our project's root directory.
envfile: .env.tpl
project_id:'1690172229386'
project_name: todo_nuxt
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 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:'1690172229386'
project_name: todo_nuxt
services:
pgadmin:
path: ./services/pgadmin
todonuxt:
path: ./services/todo_nuxt
postgres:
path: ./services/postgres
ingress:null
Each services has their own bolt.service.yaml file, here we have configured it as per our requirement.
Also we have configured run.dockerfile and build.dockerfile for todonuxt, pgadmin and postgres to run them in docker.
Running the Project
Now, let's run our services using Bolt.
# The following command will run the service as per the configuration in bolt.yaml file
Inorder to run the todonuxt service in docker when you run bolt up command you need to change the default_service_runner in bolt.service.yaml file to docker.
# This is how bolt.service.yaml file should look like if you want to run the service in docker
container_name: todonuxt
stateless:true
default_service_runner: docker
depends_on:
- postgres
service_discovery_offset:
-3000
supported_service_runners:
- local
- docker
service_runners:
local:
envfile: .env
build: npm install && npm run dev ----port ${ASSIGNED_PORT}
ports:
- ${ASSIGNED_PORT}:${ASSIGNED_PORT}
docker:
envfile: .env
build: ./run.Dockerfile
ports:
- ${ASSIGNED_PORT}:3000
Now if you run bolt up command it will run the service in docker.
Also we have added depends_on key in bolt.service.yaml so that postgres service will go up first.
Listing Bolt Services
You can also see the list of services in your bolt project and their statuses using the service:list command.