Skip to main content

SMSWithoutBorders.com

The official SMSWithoutBorders website.

Here is the interface through which users can manage their accounts and save their credentials

What you'll learn
  • How to setup the website
  • How to test and deploy the website with Apache and docker

The most recent version of this guide can be found in the websites github reposistory

The frontend integrates with these services. you may need to set them up depending on what section you are working on.

Setup Guide

Please follow the instructions below to setup this project

Requirements

Install dependencies

yarn install

Configure environment variables

Create development and production .env configuration files with defaults

make config

SMSWithoutBorders global config variables can also be passed in to override the default config

SWOB_BE_HOST=http://localhost:9000 SWOB_RECAPTCHA_ENABLE=true SWOB_RECAPTCHA_SITE_KEY=skfhk123 <command>

Where command could be any one defined under scripts in package.json or Makefile target e.g yarn start, make build

.env.development.local is used in development environments and .env.production.local is used when creating production builds.

This project was bootstrapped with Create React App, which specifies variable naming conventions

Below are the defaults. a reference is also kept in env.example

VariableDescriptionDefault valueOverride
PORTdevelopment port18000PORT
GENERATE_SOURCEMAPGenerate or ignore sourcemapsfalseN/A
REACT_APP_API_URLBackend API URLhttp://localhost:9000SWOB_BE_HOST
REACT_APP_API_VERSIONBackend API versionv2SWOB_BE_VERSION
REACT_APP_GATEWAY_SERVERGateway server API URLhttp://localhost:15000SWOB_GS_HOST
REACT_APP_GATEWAY_SERVER_VERSIONGateway server versionv2SWOB_GS_VERSION
REACT_APP_RECAPTCHA_ENABLEEnable or disable recaptcha, make sure this setting is also toggled on the APIfalseSWOB_RECAPTCHA_ENABLE
REACT_APP_RECAPTCHA_SITE_KEYreCAPTCHAv2 site key obtained from googleN/ASWOB_RECAPTCHA_SITE_KEY
REACT_APP_RECAPTCHA_API_URLAPI script src from reCaptchav2 setup documentationhttps://www.google.com/recaptcha/api.jsN/A
REACT_APP_TUTORIAL_URLLink to the getting started tutorialhttps://smswithoutborders.github.io/docs/tutorials/getting-startedN/A
REACT_APP_GATEWAY_TUTORIAL_URLLink to gateway client setup tutorialhttps://github.com/smswithoutborders/SMSWithoutBorders-Gateway-Client/blob/alpha_stable/src/README.mdN/A
REACT_APP_PRIVACY_POLICY_URLLink to hosted privacy policy markdown file(s)https://raw.githubusercontent.com/smswithoutborders/smswithoutborders.com/dev/docs/privacy-policyN/A
HTTPSEnable or disable httpsfalseSWOB_SSL_ENABLE
SSL_CRT_FILELocation of SSL CRT fileN/ASWOB_SSL_CRT_FILE
SSL_KEY_FILELocation of SSL Key fileN/ASWOB_SSL_KEY_FILE

Start development server

yarn start

Note configs are checked and regenerated each time yarn start is run. .env.development will not be overriten if it already exists but .env.production will.

Open http://localhost:18000 to view it in the browser.

The page will reload if you make edits.

You will also see any lint errors in the console.

Create a production build

For docker, see docker section below.

Create an optimized production build that can be hosted on servers. This step uses the variables in .env.production.local

yarn build or make build

Check the build folder for deployable files once complete.

Deployment

Standard deployment with apache

For a Linux/Ubuntu server running apache2 web server, follow these steps to deploy the site

  • Enable rewrite module
sudo a2enmod rewrite
  • Open apache configuration file at /etc/apache2/apache2.conf
  • Change the AllowOverride permission from none to all
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
  • Copy contents of build folder to server root normally located at /var/www/html. Ensure the .htaccess file is copied over. The .htaccess file is quite important as specified here
sudo cp -r build/. /var/www/html
  • restart apache2
sudo systemctl restart apache2

Docker

The SWOB docker image is designed to run in a production environment therefore, SSL keys are required

Start by building the docker image. There is a make script you can run. Also, SWOB env overrides can be passed directly to this command. See configuring env variables above.

SWOB_SSL_ENABLE=true SWOB_SSL_CRT_FILE=/path/to/server.crt SWOB_SSL_KEY_FILE=/path/to/server.key make image

You can also pass other SWOB env variable to be used instead of the defaults.

SWOB_RECAPTCHA_ENABLE=true SWOB_RECAPTCHA_SITE_KEY=somekeyhere make image

A full list of all env variables can be found under configure env variables section above

Once build completes, a swob-fe:latest image is created. The image exposes ports 80 and 443 which can be mapped as required

You can test the image by running make container and visit http://localhost:18000and https://localhost:18001 in the browser or deploying with your own docker config options