SwineCart is an E-Commerce System for Breeder Swine and Boar Semen in the Philippines. It is currently under development in the Institute of Computer Science - University of the Philippines Los Banos (ICS-UPLB). This project is a collaborative effort of the ICS-UPLB, Philippine Council for Agriculture, Aquatic and Natural Resources Research and Development (PCAARRD), and the Bureau of Animal Industry(BAI) as the secretariat of Accredited Swine Breeders Association of the Philippines (ASBAP).
- Laravel v5.3
- Ratchet
- ZeroMQ / needs php-zmq extension
- VueJS v2
- jQuery v2.1
- Materialize CSS v0.99
- Elasticsearch v5.4
- Chikka SMS API
If errors regarding privilege access occur, prepend the command with sudo
Before proceeding to installing Docker and docker-compose. Make sure Git is installed in the operating system.
- Make Projects directory inside the home directory.
cd ~ && mkdir Projects && cd Projects
- Inside the Projects directory, clone the swinecommerceph
and configured laradock repositories. Note that we are renaming swinecommerceph to swinecart.
git clone https://github.com/swinecommerceph/swinecommerceph.git swinecart
git clone https://github.com/swinecommerceph/laradock.git laradock
- Copy env-example to .env then edit the .env file. For production environment, username and passwords of MySQL and phpMyAdmin should be changed to more secure values. Also, the Certbot configuration should be changed for SSL/TLS certificate issuance. The following variables should at least be configured:
WORKSPACE_INSTALL_NODE=true
WORKSPACE_INSTALL_ZMQ=true
WORKSPACE_TIMEZONE=true
PHP_FPM_INSTALL_ZMQ=true
- Make sure that the applications > volumes line in docker-compose.yml is configured to be
- ${APPLICATION}/swinecart/:/var/www/swinecart
- Now, move to nginx/sites directory. Rename swinecart.conf.example to swinecart.conf. For production environment, uncomment the lines that are in comment to integrate HTTPS protocol for secure client-server communication. More so, server_name should be rewritten from swinecart.cf to www.swinecart.cf if the reweriting of URL is enabled. The file should look like the ff:
...
# For rewriting URL
server {
listen 80;
server_name swinecart.cf;
return 301 $scheme://www.swinecart.cf$request_uri;
}
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
ssl on;
ssl_certificate /var/certs/cert.pem;
ssl_certificate_key /var/certs/privkey.pem;
# Prevents 502 Bad Gateway error
large_client_header_buffers 8 32k;
server_name www.swinecart.cf;
root /var/www/swinecart/public;
index index.php index.html index.htm;
...
- For development environment, make sure to rename swinecart.cf to other domain names (e.g. swinecart.test). The following should also be appended to /etc/hosts file:
127.0.0.1 swinecart.test
- Move back to laradock root directory and run the following command. Note that those with brackets are optional.
docker-compose up -d nginx mysql elasticsearch [phpmyadmin] [certbot]
- Run the following command and search for the IPv4 address of laradock_workspace_1. The address will be used for the communication of our websocket servers and ZMQ messaging library. Take note of the address since it will be used for the application's configuration.
docker network inspect laradock_default
- Disregard subnet mask of the IPv4 address. For example,
172.18.0.3/16
should just be172.18.0.3
when we put it in the application's configuration.
Before running all the succeeding commands, we have to first enter the workspace container thus run
docker-compose exec --user=laradock workspace bash
. When inside the workspace container move to swinecart directory.
- Run the following command to install PHP library dependencies
composer install
- Copy .env.example file to .env file then edit variables inside .env configuration file. Variables should be changed according to desired configuration. The following variables should at least be changed:
DB_HOST=mysql
# IPv4 address here from the network inspection of Docker on laradock_default workspace container
ZMQ_HOST=172.18.0.3
- Now that application configuration is set, we have to generate the application's key for encryption processes
php artisan key:generate
- Migrate tables to database engine
php artisan migrate
- If you want to include dummy data then run the following:
php artisan migrate --seed
- We need to install Javascript library dependencies as well
npm install
-
Lastly, check if public/images, public/videos, and public/announcements symbolic links are not broken for display of images and videos.
-
Bash terminal in worksace container can now be terminated by running
exit
command.
Be sure to be in laradock working directory
To start the system, just run:
docker-compose up -d nginx mysql elasticsearch [phpmyadmin] [certbot]
To stop the system, just run:
docker-compose down