This is just a simple API to support different operations for expenses tracking. The idea is that developers can create instances of this API and use it for calculus, registration, stats and projections.
- Create the
.env
file out of theenv.template
file.
cp .env.template ./.env
- Fill all values on
.env
file.
Note: The following variables on the .env
files have a
default value (to match docker-compose
service
name):
DB_SERVER=mongo
DB_TEST_SERVER=mongo
REDIS_SERVER=redis
If you happen not to use docker-compose
setup,
make sure to change this to match the correct db server ip
or domain
- Build the docker containers
For development environments
docker-compose up --build
or for production environments
docker-compose --file docker-compose.yml --file docker-compose.prod.yml up --build
- While the previous command is running, in another terminal, please run the db configuration script (Only run this once, no needed for future builds)
bash docker-config/bin/mongo/addUsers.sh
- Stop the
docker-compose
running instance and start them again with docker-compose up
Simply in development environemnt, run
docker-compose up
Provide permissions to the script
chmod +x bin/scripts/run-unit-tests-with-docker.sh
Enjoy
bin/scripts/run-unit-tests-with-docker.sh
All of the previous setup steps are required for the setup of the production environment.
Note: The reference for the nginx-certbot docker production configuration file comes from this guide and also from this repo (Which is made from the previously mentioned guide)
Copy the files for the Docker production configuration and the LetsEncrypt initialization script
cp docker-compose.prod.yml.template ./docker-compose.prod.yml; cp init-letsencrypt.sh.template ./init-letsencrypt.sh;
Note: There are some comments in the docker-compose.prod.yml
, we will be referring to the steps in that file as to which are the ones we have to uncomment at a given time in the setup.
In the init-letsencrypt.sh
file, make sure to:
- Replace the example.com and www.example.com by your domain names in the
domains
variable. - Add your
email
to the email variable. - If you are testing, set the
staging
variable to1
to avoid request limits to letsencrypt.
Create the folder structure for the nginx configuration file.
On the root of the project: mkdir nginx; mkdir nginx/conf.d
Add your nginx configuration file for the production environment and call it default.conf
.
Here is a suggestion of the nginx configuration file.
Note: Remember to change all appearances of the example.org
string in the file to your domain name.
Disclaimer: This is a suggested configuration file, please be aware that the file should addapt to your needs and security practices.
Please follow the instruction of the steps 1 and 2 of the docker-compose.prod.yml
docker-compose --file docker-compose.yml --file docker-compose.prod.yml up --build
Note that the project is broken, now stop it and run:
docker-compose down
Provide the init-letsencrypt.sh
file with execution permissions
chmod +x init-letsencrypt.sh
Run it
./init-letsencrypt.sh
Once it runs successfully for the first time, change the variable staging
of the init-letsencrypt.sh
file from 1
to 0
to emit the real certificate and run the scripty again;
./init-letsencrypt.sh
if this one ran successfully, you have generated the SSL certificates and you are ready to go.
Make sure to execute the steps 3 and 4 of the docker-compose.prod.yml
file.
docker-compose --file docker-compose.yml --file docker-compose.prod.yml up --build
- Create a script to always check if the db is fully configured and if not, run
bash docker-config/bin/mongo/addUsers.sh
(To set up the db user), if so, IGNORE it - Add to this README.md file how to run the project from the bash scripts that will start and stop docker-compose