Software | Required | Notes |
---|---|---|
Github for Windows | Yes | Required to download and upload source code |
Docker | Yes | Prerequisite: Enable virtualization technology on your CPU and install WSL 2 (Step 4 and 5) |
Composer | Yes | Requires Composer 2.x |
Node.js | Yes | Requires version 17.0.x |
PHP | Yes | Requires version 7.4.x VC15 x64 Non Thread Safe. Place in C:\php and add C:\php to PATH for your user |
Visual Studio Code | No (Optional) | For writing code. Install extension ESlint |
To work on the code, you first have to clone it and branch it. You are not allowed to commit directly to main
or dev
branches as these are protected.
- Open
cmd
orPowerShell
in the parent directory of where you want the source code (e.g: C:\Github) - Run
git clone https://github.com/Kvaksrud/CoolBot-Backend.git
and it will create a sub-folder calledCoolBot-Backend
.
Open cmd.exe
and run the following commands:
mkdir C:\ftp
robocopy /MIR C:\Github\CoolBot-Backend\storage\ftp-demo-data C:\ftp
You can run the robocopy command again if you want to reset the FTP server contents.
Open cmd.exe
and run the following to create the supporting docker containers for the backend:
docker run --name "dev-mariadb-10.6.4" -p 127.0.0.1:3306:3306 -e MARIADB_ROOT_PASSWORD=passw0rd -d mariadb:10.6.4
docker run --name "dev-phpmyadmin-latest" -d --link "dev-mariadb-10.6.4:db" -p 127.0.0.1:8081:80 phpmyadmin:latest
docker run --name "dev-mock-ftp-server" -d -p 127.0.0.1:21:21 -p 127.0.0.1:21000-21010:21000-21010 -e USERS="ftpuser|passw0rd|/data" -e ADDRESS=127.0.0.1 -v C:/ftp:/data delfer/alpine-ftp-server
When the Docker containers are running, you can open PhpMyAdmin at http://localhost:8081
and login with username root
and password passw0rd
to administer the database.
For now, we run initialization scripts to do the generic work:
docker run --rm --link "dev-mariadb-10.6.4:mariadb" -e DATABASE_PASS=passw0rd docker.io/panubo/mariadb-toolbox:1.6.0 create-user-db coolbot_backend passw0rd
The backend is built on the Laravel 8 PHP Framework.
To prepare the backend for runtime follow these instructions:
- Open
cmd
orPowerShell
in the directory where you cloned the backend source code - Run
copy .env.example .env
- Open
.env
in yourVisial Studio Code
or your favourite text editor and fill inn all appropriate values (if any changes are needed) and save - Run
composer install
- Run
npm install
- Run
cmd /c "set NODE_OPTIONS=--openssl-legacy-provider && cmd /c ^"npm run dev^""
(this step needs to be re-run every time you change node or javascript components compiled by npm) - Run
php artisan key:generate --force
- Run
php artisan migrate:fresh
(this can also be run to clean your database of any records, like a "fresh start") - Run
php artisan storage:link
to set up storage links for web - Run
docker exec -i dev-mariadb-10.6.4 mysql -ucoolbot_backend -ppassw0rd coolbot_backend < C:/github/CoolBot-Backend/storage/db_seed_development.sql'
to seed demo data. - Run
php artisan serve
(This step makes a web-site available on http://localhost:8000)
All usernames and password for development are stored as JSON in Azure Key Vault named TCGC-KV-Development.