Sparkbooks is a Laravel API powered backend and a NextJS powered frontend and built using Docker
once you've pullded down the repo, you'll see the project is broken down into two directories; sparkbooks-server and frontend. To get started, following the commands below:
- cd into project directory
- run
npm install - run
npm bootstrap:install- this will install all the dependencies for the both directories - if this is your first installation - jump to the the First Installation section before running the next step
- run
npm run up- this will spin up the docker container and the nextjs server
- after you've followed the steps above, cd into
sparkbooks-serverand create a.envfile. The project will ship with a.env.examplefile. You'll need to update this information. Someone on the team will have a.envfile you can copy - from
sparkbooks-serverrunsail artisan migratewhich will create all the database tables (make sure you have env variable for the database) - in the
sparkbooks-serverdirectory, also runsail artisan db:seed --class=DevSeederthis will seed the database with users, workspaces, permission, and roles. - You will also need GCP service account credentials created in order to utilize the parser fully
If you're using a database GUI (which I recommend) you can connect to the docker container by adding the following information:
- database name:
sparkbooks - user name:
sail - password:
password
- if you have trouble spinning up the docker container, cd into
sparkbooks-serverand runsail build --no-cache(Sail is just a Laravel wrapper for Docker) - make sure all the composer and npm packages are installed
The infrastructure directory contains a helm chart to deploy the application (deployed via github actions) and the relevant terraform needed to provision the infrastructure to deploy this project.
The terraform directory holds 2 directories.
0-main- The main infrastructure for this project.1-workloads- Deploys the workloads onto the GKE cluster.
Make sure you have the gcloud cli installed and you are authenticated with access to the sparkbooks-app project.
gcloud auth login
gcloud auth application-default loginIn the directory you need to update run terraform init and terraform apply.
The production database is a Cloud SQL Postgres instance that is deployed inside the private VPC. The easiest way to access the database is to port-forward it from the GKE cluster.
gcloud container clusters get-credentials sparkbooks-cluster --zone us-south1-a --project sparkbooks-app
# Get Username
kubectl -n sparkbooks get secret sparkbook-env -o jsonpath="{.data.DB_USERNAME}" | base64 -d
# Get Password
kubectl -n sparkbooks get secret sparkbook-env -o jsonpath="{.data.DB_PASSWORD}" | base64 -d
# Forward DB to your localhost on port 54321
kubectl port-forward deployment/sparkbooks-server -n sparkbooks 54321:5432