Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jperez77775/ProyectoDocker/llms.txt

Use this file to discover all available pages before exploring further.

ProyectoDocker is a containerized full-stack application built with a React frontend served by Nginx, a Node.js/Express backend, and a MySQL 8 database. This guide walks you through building your own Docker images, pushing them to Docker Hub, and bringing the entire stack up with a single docker compose command.
The source files use fullstack2026 as the Docker Hub username in all image tags and in docker-compose.yml. Replace every occurrence of fullstack2026 with your own Docker Hub username before running any of the commands below. This applies to the docker build and docker push commands, and to the image: fields in docker-compose.yml.

Deploy the stack

1

Log in to Docker Hub

Authenticate your terminal session with Docker Hub. This allows you to push images to your account.
docker login
Enter your Docker Hub username and password when prompted. A successful login prints Login Succeeded.
2

Clean up previous containers and volumes

Remove any running containers and their associated volumes to ensure MySQL starts with a clean state. Skipping this step can cause the database to fail if old volume data is incompatible with the current schema.
docker compose down -v
3

Build the backend image

Navigate to the backend/ directory and build the Node.js image. The --no-cache flag forces a clean build so no stale layer is reused.
docker build --no-cache -t docker.io/<your-dockerhub-username>/perez-backend:v1 .
The backend Dockerfile uses node:20-alpine, installs dependencies with npm install, and starts the server with node server.js on port 4000.
4

Build the frontend image

Navigate to the frontend/ directory and build the React image. The build uses a multi-stage Dockerfile: the first stage compiles the React app with npm run build, and the second stage copies the static output into an nginx:1.27-alpine image configured to serve on port 3000.
docker build --no-cache -t docker.io/<your-dockerhub-username>/perez-frontend:v1 .
5

Push images to Docker Hub

Upload both images to your Docker Hub account. This makes them available to docker compose on any machine.
docker push docker.io/<your-dockerhub-username>/perez-backend:v1
docker push docker.io/<your-dockerhub-username>/perez-frontend:v1
6

Deploy the full stack

Return to the project root and start all three services. The --pull always flag ensures Docker Compose downloads the latest versions of your images from Docker Hub rather than using any locally cached layers.
docker compose up -d --pull always
Docker Compose starts three containers: cv_database (MySQL 8), cv_backend (Node.js on port 4000), and cv_frontend (Nginx on port 3000). The backend waits for the database healthcheck to pass before it starts, so the startup order is automatic.

Verify the deployment

After running docker compose up, follow these steps to confirm that every service is healthy. 1. Wait for MySQL to initialize Give MySQL about 45 seconds to process the init.sql file and reach a healthy state. The docker-compose.yml healthcheck pings MySQL every 5 seconds and retries up to 10 times, so the backend will not start until the database is truly ready. 2. Check the backend logs
docker compose logs backend
Look for this success message in the output:
¡Conectado exitosamente a la base de datos MySQL!
If you see this message, the backend has connected to the database and the API is ready. 3. Test the API endpoint Open your browser and navigate to:
http://localhost:4000/cv
You should receive a JSON response containing the CV data served directly by the Express backend. 4. Open the frontend Open your browser and navigate to:
http://localhost:3000
You should see the React user interface. If the page loads but shows no data, wait a few more seconds for the backend to finish connecting and refresh the page.

Stopping the stack

To stop all containers without removing data:
docker compose down
To stop all containers and remove the MySQL volume (full reset):
docker compose down -v

Build docs developers (and LLMs) love