Sistema de Gestión ships with a multi-stage Dockerfile that compiles the React application using Node 20 and then serves the static output with Nginx Alpine. The result is a small production image with no Node.js runtime — only the compiled HTML, CSS, and JavaScript files and a minimal web server.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSebax85/frontend-prueba-fullstack/llms.txt
Use this file to discover all available pages before exploring further.
How the Dockerfile works
The build uses two stages to keep the final image lean.build: Uses the official node:20 image. It installs npm dependencies, copies the source, and runs npm run build to produce an optimised production bundle in /app/build.
Stage 2 — serve: Uses nginx:alpine, a minimal image under 10 MB. It copies only the compiled /app/build directory from the previous stage into Nginx’s default HTML root. Node.js is not present in this final image.
Nginx listens on port 80 inside the container. The docker run command maps that to port 3000 on your host.
Steps
Confirm prerequisites
You need Docker installed and running on your machine. Verify with:You also need the backend API running and reachable from inside the container. The default
.env value http://host.docker.internal:8080 works on Docker Desktop (macOS and Windows) because host.docker.internal resolves to the host machine’s loopback address from within a container.Set the API URL before building
Edit If you are deploying to a server where the backend has its own hostname or IP address, replace the value accordingly. Alternatively, pass the variable as a build argument (see the note below the steps).
.env in the project root to point to your backend:Build the Docker image
From the project root (where the Docker executes both stages in sequence. The first time this runs, it downloads the
Dockerfile lives), run:node:20 and nginx:alpine base images, which may take a few minutes. Subsequent builds reuse cached layers.Run the container
Start a container from the image and bind port 3000 on your host to port 80 inside the container:The
-p 3000:80 flag follows the format host_port:container_port. Nginx inside the container listens on 80; you access the app on 3000.Passing the API URL at build time
If you prefer not to rely on a.env file, you can pass REACT_APP_API_URL as a Docker build argument. Adjust the Dockerfile to accept it:
docker build:
Quick reference
| Command | Purpose |
|---|---|
docker build -t frontend . | Build the image and tag it as frontend |
docker run -p 3000:80 frontend | Run the container, host port 3000 → container port 80 |
docker run -d -p 3000:80 frontend | Run in detached (background) mode |
docker ps | List running containers |
docker stop <container_id> | Stop a running container |