Deployment
Relevant source files
The following files were used as context for generating this wiki page:
The medical-calculators project is a web application built with Next.js, TypeScript, and Tailwind CSS. As a standard Next.js application, it can be deployed on various platforms that support Node.js environments. The deployment process involves setting up the local environment, creating a production build, and deploying to a hosting service.
This document outlines the procedures for local development, production builds, and deployment to platforms like Vercel, Netlify, and Docker. It also covers post-deployment checks and recommended monitoring practices.
Sources: README.md:3-11, DEPLOYMENT.md:3-5, PROJECT_SUMMARY.md:5-9
Build and Run Process
The application's lifecycle is managed through npm scripts defined in package.json. These scripts handle development, building, and starting the production server.
Sources: package.json:5-9, DEPLOYMENT.md:5-23
NPM Scripts
The primary scripts for building and running the application are listed below.
| Script | Command | Description |
|---|---|---|
dev | next dev --turbopack | Starts the development server with Turbopack for faster local development. The app is accessible at http://localhost:3000. |
build | next build | Creates an optimized production build of the application in the .next directory. |
start | next start | Starts the production server using the build created by npm run build. |
lint | next lint | Runs ESLint to check for code quality and style issues. |
Sources: package.json:5-9, DEPLOYMENT.md:13-16, DEPLOYMENT.md:19-23
Build & Deployment Flow
The general workflow from development to deployment is illustrated in the diagram below. It starts with local development, proceeds to creating a production build, and finishes with deploying to a hosting platform.
This diagram shows the overall process from cloning the repository to deploying the application on different platforms.
Sources: DEPLOYMENT.md:5-52, package.json:5-9
Deployment Platforms
The application is configured for deployment on several modern hosting platforms.
Sources: DEPLOYMENT.md:25-52
Vercel
Vercel is the recommended platform for deploying Next.js applications. It automatically detects the project type and configures the build settings.
- Connect the GitHub repository to a Vercel project.
- Vercel will automatically detect it as a Next.js project.
- The default settings for build command (
npm run build) and output directory should work correctly. - If needed, add any environment variables in the Vercel project settings.
- Pushing changes to the connected Git branch will trigger an automatic deployment.
Sources: DEPLOYMENT.md:25-37, DEPLOYMENT.md:78-83
The following diagram illustrates the automated deployment pipeline with Vercel.
This sequence diagram shows the automated deployment process on Vercel triggered by a git push.
Sources: DEPLOYMENT.md:25-37, DEPLOYMENT.md:78-83
Netlify
Deployment to Netlify is also straightforward with the following configuration:
- Build command:
npm run build - Publish directory:
.next
Sources: DEPLOYMENT.md:41-44
Docker
The application can be containerized using Docker for deployment in any environment that supports it.
Dockerfile
A Dockerfile is provided to build a production-ready image.
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
Sources: DEPLOYMENT.md:48-57
Docker Build & Run Process
The Docker image is built and run using the standard Docker CLI commands.
- Build the image:
docker build -t medical-calculators . - Run the container:
docker run -p 3000:3000 medical-calculators
This process is visualized below.
This flowchart outlines the steps to build and run the application as a Docker container.
Sources: DEPLOYMENT.md:46-61
Post-Deployment Verification
After deployment, it is crucial to verify the application's functionality, responsiveness, and performance.
Health Checks
- Main Functionality:
- The main page loads correctly.
- Navigation between different calculators works as expected.
- Calculators, such as the potassium correction and antibiotic prophylaxis calculators, are functional.
- Responsiveness:
- The layout is correct on mobile, tablet, and desktop devices.
- Performance:
- Page load times are acceptable.
- Calculators respond quickly to user input.
Sources: DEPLOYMENTmd:63-76
Monitoring
For production environments, setting up monitoring is recommended:
- Error Logging: Integrate a service like Sentry to log JavaScript errors.
- Analytics: Use tools like Google Analytics to track calculator usage.
- Performance Monitoring: Utilize services like Vercel Analytics or monitor Core Web Vitals.
Sources: DEPLOYMENT.md:85-97
Updates
To update the application, follow these steps:
- Make code changes locally.
- Test locally using
npm run dev. - Ensure the production build is successful with
npm run build. - Commit and push the changes to the Git repository.
- The deployment platform (e.g., Vercel) will automatically deploy the updates.
Sources: DEPLOYMENT.md:99-106, CONTRIBUTING.md:65-68