Skip to content

swinecommerceph/swinecart-web

Repository files navigation

SwineCart

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).

Utilizes the following core technologies:

  • Laravel v5.3
  • Ratchet
  • ZeroMQ / needs php-zmq extension
  • VueJS v2
  • jQuery v2.1
  • Materialize CSS v0.99
  • Elasticsearch v5.4
  • Chikka SMS API

Configured Laradock environment can be found at:

Installation

If errors regarding privilege access occur, prepend the command with sudo

Installing Docker and docker-compose

Before proceeding to installing Docker and docker-compose. Make sure Git is installed in the operating system.

Setting-up Docker environment
  1. Make Projects directory inside the home directory.
  cd ~ && mkdir Projects && cd Projects
  1. 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
  1. 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
  1. Make sure that the applications > volumes line in docker-compose.yml is configured to be
  - ${APPLICATION}/swinecart/:/var/www/swinecart
  1. 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
  1. 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]
  1. 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 be 172.18.0.3 when we put it in the application's configuration.
Configuring and Installing Application's library dependencies

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.

  1. Run the following command to install PHP library dependencies
  composer install
  1. 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
  1. Now that application configuration is set, we have to generate the application's key for encryption processes
  php artisan key:generate
  1. Migrate tables to database engine
  php artisan migrate
  • If you want to include dummy data then run the following:
  php artisan migrate --seed
  1. We need to install Javascript library dependencies as well
  npm install
  1. Lastly, check if public/images, public/videos, and public/announcements symbolic links are not broken for display of images and videos.

  2. Bash terminal in worksace container can now be terminated by running exit command.

Running/Stopping Docker containers

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published