Back to homepage

Dockerizing and Deploying a React App

01 Jun 2025

A compact workflow to build, push, and run your frontend image with Docker Hub.

1. Create Dockerfile

FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

2. Build image

docker build -t sabberrahman/frontend_dashboard:latest .

3. Push image

docker push sabberrahman/frontend_dashboard:latest

4. Pull and run

docker pull sabberrahman/frontend_dashboard:latest
docker run -p 80:80 sabberrahman/frontend_dashboard:latest