You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This project is aNext.js-based image gallery that fetches images from anAWS API Gateway endpoint and displays them in an attractive frontend. The application is containerized usingDocker, stored inAmazon ECR, and deployed toAWS ECS for scalable hosting.
Features
Fetches images from an API Gateway URL
Displays images in a responsive gallery
Deployed on AWS ECS using a containerized Next.js app
Uses Amazon ECR for container storage
Architecture
Frontend: Next.js application
Backend: AWS API Gateway serves image URLs
Containerization: Dockerized Next.js app stored in Amazon ECR
Hosting: ECS Fargate for scalable and serverless deployment
Prerequisites
Before deploying, ensure you have:
AWS Account
AWS CLI installed and configured
Docker installed
A Next.js project ready to be containerized
API Gateway endpoint for fetching images
Deployment Steps
1. Containerizing the Next.js App
# Build the Next.js projectnpm run build# Create a Docker imagedocker build -t nextjs-image-gallery.# Authenticate Docker with ECRaws ecr get-login-password --region<your-region>| docker login --username AWS --password-stdin<aws_account_id>.dkr.ecr.<your-region>.amazonaws.com# Tag the Docker imagedocker tag nextjs-image-gallery:latest<aws_account_id>.dkr.ecr.<your-region>.amazonaws.com/nextjs-image-gallery:latest# Push to ECRdocker push<aws_account_id>.dkr.ecr.<your-region>.amazonaws.com/nextjs-image-gallery:latest
2. Deploying to ECS via AWS Console
Go toECS Console →Create a Cluster → SelectFargate.
Create aTask Definition with:
Task Role:ecsTaskExecutionRole (with ECR access)
Container Image:ECR image URL
Port Mapping:3000:3000
Create anECS Service under your cluster:
Set Task Definition
Desired tasks:1 (or more for scaling)
Configure Load Balancer if needed
Deploy the service and test the application.
Configuration
API Gateway URL: UpdateNEXT_PUBLIC_API_URL in.env.local.