Back to Explore
Cloud Deployment Project

Deploying Next.js Portfolio with Docker on AWS EC2

I deployed my personal portfolio using a production-ready cloud architecture with high-level containerization and security.

Project Overview

This project focuses on transforming a frontend application into a production-ready system in a cloud environment. The application runs inside a Docker container on an AWS EC2 Ubuntu instance.Nginx is configured as a reverse proxy to route traffic from the domain to the application.HTTPS is enabled using Let's Encrypt to secure data communication.

Deployment Architecture

User
Domain (Hostinger DNS)
HTTPS (Let's Encrypt SSL)
Nginx Reverse Proxy
Docker Container
Next.js Application
AWS EC2 Server (Ubuntu)

Technologies Used

Next.js 15
React 19
Docker
AWS EC2
Nginx
Let's Encrypt
Ubuntu Linux
GitHub

Key Learning Points

Containerization

Wrapping the Next.js application with Docker for consistency across various environments.

AWS Configuration

Managing EC2 instances, Security Groups, and Elastic IP for public access.

Nginx Proxy

Setting up routing from port 80/443 to the internal application on port 3000.

Domain Management

Connecting a custom domain via Hostinger DNS to the AWS server.

SSL Security

Automatic HTTPS implementation using Certbot and Let's Encrypt.

SSH Automation

Managing deployment and server maintenance remotely via terminal.

DevOps & Cloud Skills

AWSIntermediate
DockerAdvanced
NginxAdvanced
Linux ServerAdvanced
GitHub ActionsIntermediate
Next.jsAdvanced

Implementation Details

1

Multi-stage Dockerfile

Optimizing the Docker image by separating build and runtime stages for minimal image size.

Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY . .
RUN npm install && npm run build

FROM node:20-alpine AS runner
WORKDIR /app
COPY --from=builder /app/.next/standalone ./
CMD ["node", "server.js"]
2

Nginx Configuration

Routing HTTPS traffic to the application running inside the container.

nginx.conf
server {
    server_name titiswahyudi.space;
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
    }
    listen 443 ssl;
    # SSL config by Certbot
}
Ready for the next level?

Need a more detailed report?