This project was generated by Flatlogic Platform.
-
Frontend: React.js
-
Design: Transparent
-
Backend: NodeJS
-
Database: PostgreSQL
yarn install
MacOS:
brew install postgres
> if you don’t have ‘brew‘ please install it (https://brew.sh) and repeat step `brew install postgres`.
Ubuntu:
sudo apt update
sudo apt install postgresql postgresql-contrib
Before run and test connection, make sure you have created a database as described in the above configuration. You can use the psql
command to create a user and database.
psql postgres --u postgres
Next, type this command for creating a new user with password then give access for creating the database.
postgres-# CREATE ROLE admin WITH LOGIN PASSWORD 'admin_pass';
postgres-# ALTER ROLE admin CREATEDB;
Quit psql
then log in again using the new user that previously created.
postgres-# \q
psql postgres -U admin
Type this command to creating a new database.
postgres=> CREATE DATABASE development;
Then give that new user privileges to the new database then quit the psql
.
postgres=> GRANT ALL PRIVILEGES ON DATABASE development TO admin;
postgres=> \q
yarn db:create
yarn start
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](#running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
See the section about [deployment](#deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
The project contains the docker folder and the Dockerfile
.
The Dockerfile
is used to Deploy the project to Google Cloud.
The docker folder contains a couple of helper scripts:
docker-compose.yml
(all our services: web, backend, db are described here)start-backend.sh
(starts nodejs app)wait-for-it.sh
(imported from https://github.com/vishnubob/wait-for-it)
-
Install docker compose (https://docs.docker.com/compose/install/)
-
Move to
docker
folder. All next steps should be done from this folder.cd docker
-
Make executables from
wait-for-it.sh
andstart-backend.sh
:chmod +x start-backend.sh && chmod +x wait-for-it.sh
-
Download dependend projects for services.
-
Review the docker-compose.yml file. Make sure that all services have Dockerfiles. Only db service doesn't require a Dockerfile.
-
Make sure you have needed ports (see them in
ports
) available on your local machine. -
Start services:
7.1. With an empty database
rm -rf data && docker-compose up
7.2. With a stored (from previus runs) database data
docker-compose up
-
Check http://localhost:3000
-
Stop services:
9.1. Just press
Ctr+C
-
connection refused
There could be many reasons, but the most common are:
-
The port is not open on the destination machine.
-
The port is open on the destination machine, but its backlog of pending connections is full.
-
A firewall between the client and server is blocking access (also check local firewalls).
After checking for firewalls and that the port is open, use telnet to connect to the IP/port to test connectivity. This removes any potential issues from your application.
MacOS:
If you suspect that your SSH service might be down, you can run this command to find out:
sudo service ssh status
If the command line returns a status of down, then you’ve likely found the reason behind your connectivity error.
Ubuntu:
Sometimes a connection refused error can also indicate that there is an IP address conflict on your network. You can search for possible IP conflicts by running:
arp-scan -I eth0 -l | grep <ipaddress>
arp-scan -I eth0 -l | grep <ipaddress>
and
arping <ipaddress>
-
yarn db:create
creates database with the assembled tables (on MacOS with Postgres database)The workaround - put the next commands to your Postgres database terminal:
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
Afterwards, continue to start your project in the backend directory by running:
yarn start