-
Author: Hoàng Tùng (same as TrHgTung)
-
Tài liệu tiếng Việt: tại đây
- Ensure Laragon (or other MySQL DBMS) is running.
- Database
socialprojectshould exist - if not, create one (Migration scripts have already been applied to this shit).
-
Open Laragon > Start MySQL service > create a database, name:
socialprojectand save it -
Open Command Prompt > re-check once again if you're stil at the root directory of the source code > type init-project-for-the-first-time.ps1 and hit Entẻ.
-
Wait for these shit building (backend, migrating, frontend, bla bla..)
-
Back to the Command Prompt > re-check once again if you're stil at the root directory of the source code > type dev-start.ps1 and hit Entẻ.
-
The API will be available at
https://localhost:5001. -
Open your browser and navigate to
http://localhost:3000. Because the front-end is on it. -
Test yourself!
If your operation system can't run the ps1 script file? Nah, just use Windows and try again!
-
Prepare a VPS, a domain name and money for purchasing these shit
-
Suggested VPS cònfiguration: 2GB of RAM, >20GB of storage, running Ubuntu or other Linux distro OS
-
Setup your VPS, add you domain to VPS IP address
-
Start VPS, or use SSH to connect from your PC > login > sudo su > apt update > apt install docker (use ChatGPT for more instructions about setting up Git, Docker, Docker Image, ..)
-
Git clonethe source code for the first time orgit pullthe source code for updating >cdto the source > and then5.1. Add
docker-compose.ymlfile to root directory, and config it by yourself (nano docker-compose.yml> Add scripts (Check the docker-compose.example.yml) > Ctrl X to save > Yes > Enter to overwrite file).REMEMBER: enviroment variables in docker-compose.yml file will work on VPS, not on your PC. On your PC, you can use
dev-start.ps1script file instead (it will use appsettings.Development.json and .env files)5.2. Add new wwwroot folder on backend source:
cd backend>mkdir wwwroot> hit Enter5.3. Add appsettings.Development.json file on backend source:
cd backend>touch appsettings.Development.json>nano appsettings.Development.json> Add all necessary environment variables (Check the appsettings.Development.example.json) > Ctrl X to save file > Yes > Enter to overwrite5.4. Add .env file for frontend source:
cd frontend>touch .env>nano .env> Add all necessary environment variables (Check the .env.example) > Ctrl X to save file > Yes > Enter to overwrite5.5. Back to root directory of the source (
cd ..) > Rundocker compose up -d --buildfor building all the images -
Check on your domain or pinging your VPS's IP Address
Or just create a GitHub Actions workflow (.github/workflows/deploy.yml) Example file
My Final Example of Production: The Blog Social - If you get a 404 or 502 status after clicking this, may be it's down due to my poverty.