- Install Docker at your local machine.
- Clone repo and install
git clone git@github.com:Marioandres717/creation-mono.git
cd creation-mono
npm install
- Create
.env
file at the root directory (check .env.file.example for guidance)
# Database
# [protocol]://[user]:[password]@[host]:[port]/[database]
DATABASE_URL=mysql://root:asd123@localhost:3306/walletdb
TOKEN_DURATION=86400000
# Frontend
NX_GRAPHQL_URI=http://localhost:3000/graphql
-
Create
constants.ts
file inapps/backend/src/app/auth/constants.ts
export const jwtConstants = { secret: 'secretKey', };
-
Prepare the database
-
Turn db container on: Known Issues: Errors due to corrupted data:
(CAUTION): remove tmp folder.
This command removes the database data. This error may be due to the change from mysql to mariadb, so it is probably safe to run the following command because such an error is only triggered in the early stages of development.rm -rf tmp
docker-compose up db
-
Push initial schema to db and verify database
npx nx run shared-models:db-push ### Optional ### docker exec -it db /bin/sh mysql -u root -p # Enter database password show databases;
-
Generate prisma client
npx nx run shared-models:gen-client
-
-
Generate types based on Schema
npm run update-all
-
Build docker containers
cd creation-mono docker-compose build
-
Run Docker compose
docker-compose up
- Open
localhost:3000/graphql
and create a new user
mutation createUser {
insert_User(User: {
id: 0,
email: "test@tech.ca",
password: "test12",
username: "testuser",
active: 1
}
){
id,
email,
username,
active
}
}
- Log in using the new created user at
localhost:4200
A list of useful docker compose-commands
# containers status
docker-compose ps
# run application
docker-compose up
# shut down application
docker-compose down
# restart container
# docker-compose restart wallet
# you can get the name from docker-compose.yml file
docker-compose restart <compose container name>
# build application based on Dockerfile
docker-compose build
# build single container
docker-compose build <compose container name>
# running bash in container
# this command will run an isolated container
# changes here won't affect the container running
# with docker-compose up in case its available
docker-compose build <compose container> bash
# General docker commands
# docker image list
docker [image|container|volume] [list]
Useful steps to update the node_modules for a docker image to avoid rebuilding the entire project.
-
run
docker ps
and get wallet container id -
docker exec -it [container-id] bash npm install exit
-
Outside the container
# container that changes -> image to commit the changes docker commit [container-id] wallet:latest
-
run
docker-compose restart
-
SSL required: this needs to be done every time :(
add useSSL=1 to edit conection / advanced / others