A monorepo for vercel-like frontend deployment application
This Turborepo includes the following packages/apps:
apps/api: an Express/Node backend to spin aws ecs containers and other core logicapps/api-proxy: an Express/Node backend reverse proxy to map to s3 urlapps/api-build: - setup docker image, build project and upload to S3apps/web: a React.js frontendpackages/common: package for sharing code used in multiple appspackages/ui: a stub React component library used inwebpackages/eslint-config:eslintconfigurations (includeseslint-config-nextandeslint-config-prettier)packages/typescript-config:tsconfig.jsons used throughout the monorepo
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
- Clone the repository on your local machine -
git clone https://github.com/jogeshwar01/vercel.git
- Setup AWS account and create a user with access to S3, ECS, ECR
- Create a new repository in ECR and use the
push commandsto push local build docker image to ECR. Setup a Task and a Cluster for this image in ECS. - Setup a Redis Instance. (public url preferred - to be used in aws). Can use aiven.io for a free instance. Check detailed setup guide for AWS here - https://github.com/jogeshwar01/vercel-base
- Set environment variables according to .env.example in the following apps -
apps/web
apps/api
apps/api-build - set the env variables in AWS ECR
- Start the docker containers locally -
docker compose up -d
- Ports -
Local:Docker
- 5000:9000 - S3 Reverse Proxy
- 5001:9001 - API Server
- 5002:9002 - Socket Log Server
- 5003:5173 - React app
- To ensure external accessibility, it is crucial to ensure that the Vite server is correctly bound to 0.0.0.0 rather than localhost or 127.0.0.1 within the container. This binding ensures that the server listens on all network interfaces, facilitating access from outside the container, including from the host machine. Adjustment to the Vite configuration to explicitly set the host to 0.0.0.0 can be accomplished by modifying the vite.config.ts file or by appending the --host flag to the vite. Command -
vite --host
- Run
yarn initandtsc --init - Add internal package to dependencies like
"common": "*" - Change
rootDirto./srcandoutDirto./dist - Update
moduleResolutionandmoduleintsconfig.jsontonodenextandNodeNextrespectively - need to update code to usetypescript-configin all apps/packages