- Node.js version 18 or greater
- PostgreSQL database
-
Create Public and Private Keys for Session Management:
- Generate a private key:
openssl genpkey -algorithm RSA -out jwtRS256.key -pkeyopt rsa_keygen_bits:4096
- Generate a public key:
openssl rsa -in jwtRS256.key -pubout -out jwtRS256.key.pub
- Generate a private key:
-
Initialize Environment Variables for Development:
- Use the
./env/development.env
file. - Set the
VARIAMOS_PRIVATE_KEY_PATH
in./env/development.env
:VARIAMOS_PRIVATE_KEY_PATH=./jwtRS256.key
- Set the
VARIAMOS_PUBLIC_KEY_PATH
in./env/development.env
:VARIAMOS_PUBLIC_KEY_PATH=./jwtRS256.key.pub
- Use the
-
Install Dependencies:
- Run the following command:
npm install
- Run the following command:
- To run the application locally, use:
npm run dev
-
Build the Docker Image:
- Ensure you are in the root folder and execute:
docker build -t variamos/admin-ms .
- Ensure you are in the root folder and execute:
-
Create a Network:
- Execute the following command to create a network called
variamos
:docker network create variamos
- Execute the following command to create a network called
-
Run the Docker Image:
-
Execute:
docker run -d --name variamos-ms-admin --network variamos -p 4000:4000 --env-file ./env/docker.env -v full-path-to-app-config-files/docker-config:/mnt/app-config variamos/admin-ms:latest
-
Explanation of the command:
-
-d
: Runs the container in detached mode, freeing the console after the container starts. -
--name variamos-ms-admin
: Names the containervariamos-ms-admin
. -
--network variamos
: Connects the container to thevariamos
network. -
-p 4000:4000
: Maps port4000
on the host machine to port4000
in the container. To use a different port, update thePORT=
entry in the./env/docker.env
file. If it does not exist, create./env/docker.env
from./env/development.env
. -
--env-file ./env/docker.env
: Loads environment variables from./env/docker.env
. -
-v full-path-to-app-config-files/docker-config:/mnt/app-config
: Maps thefull-path-to-app-config-files/docker-config
folder to/mnt/app-config
, replace it with your own folder, remember to use full path not relative. This is useful for providing private and public keys (jwtRS256.key
andjwtRS256.key.pub
). Create a copy of thejwtRS256.key
andjwtRS256.key.pub
keys in yourfull-path-to-app-config-files
folder and update./env/docker.env
:VARIAMOS_PRIVATE_KEY_PATH=/mnt/app-config/jwtRS256.key VARIAMOS_PUBLIC_KEY_PATH=/mnt/app-config/jwtRS256.key.pub
-
variamos/admin-ms:latest
: Specifies the Docker image to use, in this case, the latest image created with the namevariamos/admin-ms
using thedocker build
command.
-
-
If you are working locally with a PostgreSQL Docker container, you should update the database container network to use the variamos
network you created in the previous steps. Use the following command:
docker network connect variamos <container-name>
Replace <container-name>
with the name of your PostgreSQL container.