A modular e-commerce application. Consists of e-commerce-api, e-commerce-react and e-commerce-mongo.
See the website live here.
Clone e-commerce-common, e-commerce-mongo, e-commerce-api, e-commerce-react, e-commerce-app and e-commerce-signup into a common root directory. Perform all further instructions inside that directory.
From each of the subfolders - e-commerce-common
, e-commerce-mongo
, e-commerce-api
, e-commerce-front-end
, e-commerce-app
, e-commerce-signup
- run npm install
.
Then, run the initialization commands from within e-commerce-common
:
cd e-commerce-common
# create data directory and a keyfile for the database
./init.sh
From within e-commerce-common
, run the following.
Run this command and wait a few moments to make sure the script has connected to the database and initialized it (you should see mongosh
logs from the init
container in the stdout). Then you can interrupt (CTRL+c
).
docker compose -f init-db.docker-compose.yml up --build
First, temporarily remove the "type": "module"
declaration from e-commerce-common/package.json
and e-commerce-mongo/package.json
[1
].
Then, from within e-commerce-common
, run the following and wait a few moments until the scripts are executed (you should see logs from the node
container):
docker compose -f init-app.docker-compose.yml up --build
Then, add the "type": "module"
declaration back in.
From within e-commerce-common
, run the following and wait a few moments until the server starts (you should see logs from the node
container):
docker compose -f run.docker-compose.yml up --build
run docker ps
, find container with IMAGE of "fi-common_node" and copy it's ID (e.g., e28354082f09)
then docker inspect
that container and find NetworkSettings.Networks.fi-common_default.IPAddress
this is taken from here
migrate-mongo
, which is run ininit-app.sh
, doesn't work with es6 modules.
From e-commerce-common
directory, run:
docker compose -f backup.docker-compose.yml run --build backup bash
Inside the running container, run:
cd /app/e-commerce-common && ./backup-db.sh
This will produce a database dump in ../backup/db/
Assuming you have a database and app user set up, i.e., you have run 1
and 2
from Run.
Run:
docker compose -f backup.docker-compose.yml run backup bash
Inside the running container, run:
cd /app/e-commerce-common && ./backup-db-restore.sh <path to backup file inside container's volume>
E.g.,./backup-db-restore.sh /app/backup/db/[email protected]_2024-05-15.gz
From e-commerce-common
, run:
./backup-files.sh
This will produce a directory with a .tar.gz
file inside in backups/uploads/
In e-commerce-app
, extract the .tar.gz
file.
First, temporarily remove the "type": "module"
declaration from e-commerce-common/package.json
and e-commerce-mongo/package.json
[1
].
- from
e-commerce-common
, run:
docker compose -f run.docker-compose.yml run node bash
- inside the running container, run:
/app/e-commerce-common/node_modules/.bin/migrate-mongo up -f /app/e-commerce-common/migrate-mongo-config.js
or, for down:
/app/e-commerce-common/node_modules/.bin/migrate-mongo down -f /app/e-commerce-common/migrate-mongo-config.js
The instructions are taken from [1
].
In e-commerce-app
:
mkdir cert && cd cert
- generate a private key:
openssl genrsa -out key.pem
- generate a Certificate Signing Request (CSR):
openssl req -new -key key.pem -out csr.pem
- generate the SSL certificate:
openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out cert.pem
Create templates for scaling uploaded images.
suffix
will be appended to the scaled image file name and will be used to store the file name in the database.
width
, height
and options
are sharp
's resize
method arguments.