✨ This workspace has been generated by Nx, a Smart, fast and extensible build system. ✨
Clone the .env.example file and create an .env file to update as needed. **Do not check your .env file into source control!. The .gitignore file, however, already ensures no files beginning with ".env" can get checked in other than the .env.example file.
The database used in this project uses Vercel's Postress database service. An example of how to set this up can be found at How to Build a Fullstack App with Next.js, Prisma, and Vercel Postres. This appication hits an existing database endpoint on Vercel's database servers.
The command
vercel env pull .env
sync's the project's .env with the environment variables used on that Vercel project account.
The schema.prisma file defines the schema to build the database. To do this, run
pnpm exec prisma db push
To add data to the database tables created, you can do this via Prisma's Studio interface. Run the command
pnpm exec prisma studio
In Prisma Studio, populate the tables with data.
If you ever need to update you Prisma schema (schema.prisma), you'll also need to ensure your Prisma Client (libs/vhg/src/lib/prisma.tsx) accounts for this change. To do that, run
pnpm exec prisma generate
This project is configured as a Vercel project deployment. Pushing changes up on any branch other than master or main will display a under the Deployements section of Vercel's site as a preview environment.
To start the development server run pnpm exec nx serve vhg
. Open your browser and navigate to http://localhost:3000/.
NOTE: If you prefer to make updates to the app, you can give a new version tag to image by updating it in /apps/vhg/project.json, building the project again and run the Docker image again, as shown earlier.
If you prefer to run Docker Desktop, be sure to install and run Docker Desktop.
After the Docker Desktop's engine is running, start the app in a Docker container locally in production mode, run
pnpm i
pnpm exec prisma generate
pnpm exec nx container vhg
docker run --env-file ./.env -p 3000:3000 -t beldenschroeder/vhg:1.0
Open your browser and navigate to http://localhost:3000/.
If you prefer to run Podman Desktop, be sure to install and run Podman Desktop.
Update apps/vhg/project.json's targets.container.options.engine
to have the value, podman
.
After the Podman Desktop's engine is running, start the app in a Docker container locally in production mode, run
pnpm i
pnpm exec prisma generate
pnpm exec nx container vhg
podman run --env-file ./.env -p 3000:3000 -t beldenschroeder/vhg:1.0
Open your browser and navigate to http://localhost:3000/.
Before you can deploy the app using GitHub Actions, you'll need to build part of the AWS cloud infrastructure on which its hosted. The entire infrustructuion is segmented into three layers and each is built from its own repo.
The first two layers need to be built first. After this, you'll want to build and merge this vhg project into the main branch. Doing so will kick off a GitHub Action that publishes the app's container into AWS ECR. Execute these builds from each repo in the fllowing order by following their README instructions:
Follow the deployment instructions in the README.md for the vhg-infra repo.
Follow the deployment instructions in the README.md for the vhg-infra-platform repo.
At the root of this project directory, run
pnpm i
pnpm exec prisma generate
pnpm exec nx build vhg
First check on the AWS account that will host this app if a container for the app already exists. You can determine this by going to the AWS Console and searching for "ECR". Make sure there isn't a container with the same tag as the one you're about to push up. If there is, simply remove it from the AWS Console.
After this check, temporarily remove the postinstall
script from this project's root package.json to prevent the Dockerfile.prod from attempting to run it when this _package.json_file gets cloned into the container's environment and executed remotely. It's only meant to be run locally.
TODO: Remove the postinstall
script later when replacing PostgreSQL with MongoDB.
Create a PR from your branch to the main branch and merge it. This will kick off a GitHub Action to publish the app container to ECR.
Follow the deployment instructions in the README.md for the vhg-infra-app repo.
The app should now be hosted on http://vhgapp.beldenschroeder.me.