Skip to main content
This guide covers all installation methods for the Biblioteca Virtual Frontend, from local development to Docker deployment and CI/CD setup.

Prerequisites

For Local Development

Node.js 20+

Required for running Angular CLI and building the application

npm

Package manager (included with Node.js)

Git

Version control to clone the repository

Angular CLI

Optional but recommended for development

For Docker Deployment

  • Docker 20.10+ or higher
  • Docker Compose (optional, for orchestration)
With Docker, you don’t need Node.js or Angular CLI installed locally. Everything runs in containers.

Installation Methods

Local Development Setup

This method is ideal for active development work with hot reload and debugging tools.
1

Clone the repository

git clone https://github.com/AngheloMP10/biblioteca-virtual-frontend.git
cd biblioteca-virtual-frontend
2

Install dependencies

npm install
This installs all packages from package.json:Core Dependencies:
{
  "@angular/common": "^20.0.0",
  "@angular/compiler": "^20.0.0",
  "@angular/core": "^20.0.0",
  "@angular/forms": "^20.0.0",
  "@angular/platform-browser": "^20.0.0",
  "@angular/router": "^20.0.0",
  "rxjs": "~7.8.0",
  "tslib": "^2.3.0",
  "zone.js": "~0.15.0"
}
3

Configure environment

Set up your environment configuration in src/environments/environment.ts:
src/environments/environment.ts
export const environment = {
  production: false,
  apiUrl: 'http://localhost:8080', // Your backend API URL
};
For production builds, configure src/environments/environment.prod.ts:
src/environments/environment.prod.ts
export const environment = {
  production: true,
  apiUrl: 'https://your-api-domain.com',
};
4

Start development server

npm start
The application will be available at http://localhost:4200

Build Configurations

The project includes multiple build configurations defined in angular.json:

Development Build

npm run watch
Features:
  • Source maps enabled
  • No optimization
  • No license extraction
  • Fast rebuild times

Production Build

npm run build
Features:
  • Full optimization
  • Output hashing for cache busting
  • Bundle budgets:
    • Initial bundle: 500kB warning, 1MB error
    • Component styles: 4kB warning, 8kB error
Output location: dist/biblioteca-front/browser/

Netlify Build

npm run build:netlify
Features:
  • Uses environment.netlify.ts configuration
  • Output hashing enabled
  • Optimized for Netlify deployment
The Netlify build uses environment file replacement to inject production API URLs.

TypeScript Configuration

The project uses strict TypeScript configuration for type safety:
tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "isolatedModules": true,
    "experimentalDecorators": true,
    "target": "ES2022",
    "module": "preserve"
  },
  "angularCompilerOptions": {
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

CI/CD Setup

The project includes GitHub Actions workflow for automated Docker builds and deployment.

GitHub Actions Workflow

.github/workflows/docker-frontend.yml
name: Frontend CI/CD - Docker Hub

on:
  push:
    branches: ["main"]

jobs:
  build-and-push:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build Docker image
        run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/biblioteca-virtual-frontend:latest .

      - name: Push Docker image
        run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/biblioteca-virtual-frontend:latest

Setting up CI/CD

1

Add Docker Hub credentials

In your GitHub repository settings, add these secrets:
  • DOCKERHUB_USERNAME: Your Docker Hub username
  • DOCKERHUB_TOKEN: Your Docker Hub access token
2

Enable GitHub Actions

Ensure GitHub Actions is enabled in your repository settings
3

Push to main branch

Every push to the main branch will trigger:
  1. Docker image build
  2. Push to Docker Hub
  3. Image tagged as latest
You can monitor the build status in the “Actions” tab of your GitHub repository.

Project Structure

After installation, your project structure will look like this:
biblioteca-virtual-frontend/
├── src/
│   ├── app/
│   │   ├── auth/              # Authentication components
│   │   ├── core/              # Core services, guards, interceptors
│   │   │   ├── guards/        # Route guards (auth, admin, public)
│   │   │   ├── interceptors/  # HTTP interceptors
│   │   │   ├── models/        # TypeScript interfaces
│   │   │   └── services/      # API services
│   │   ├── features/          # Feature modules
│   │   │   ├── autores/       # Authors management
│   │   │   ├── catalogo/      # Book catalog
│   │   │   ├── generos/       # Genres management
│   │   │   ├── libros/        # Books management
│   │   │   └── prestamos/     # Loans management
│   │   ├── shared/            # Shared components
│   │   ├── app.config.ts      # Application configuration
│   │   ├── app.routes.ts      # Route definitions
│   │   └── app.ts             # Root component
│   ├── environments/          # Environment configurations
│   ├── assets/                # Static assets
│   ├── styles.css             # Global styles
│   └── main.ts                # Application entry point
├── angular.json               # Angular workspace configuration
├── package.json               # Dependencies and scripts
├── tsconfig.json              # TypeScript configuration
├── Dockerfile                 # Docker build instructions
├── nginx.conf                 # Nginx web server configuration
└── README.md                  # Project documentation

Next Steps

Quickstart Guide

Get up and running in 5 minutes

Configuration

Learn about environment variables and configuration options

Architecture

Understand the project architecture

Authentication

Connect to the backend API

Troubleshooting

Common causes:
  1. Insufficient memory: Increase Docker’s memory allocation
  2. Network issues: Check your internet connection
  3. Disk space: Ensure you have at least 2GB free
Solution:
# Clean Docker cache
docker system prune -a

# Rebuild with verbose output
docker build -t biblioteca-virtual-frontend . --no-cache
Solution:Don’t use sudo with npm. Instead, configure npm to use a different directory:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
If production builds fail due to bundle size:
Error: bundle initial exceeded maximum budget.
Solutions:
  1. Lazy load modules - Split large features into lazy-loaded routes
  2. Optimize imports - Import only what you need from libraries
  3. Increase budgets - Update limits in angular.json (not recommended)
angular.json
"budgets": [
  {
    "type": "initial",
    "maximumWarning": "500kB",
    "maximumError": "1MB"
  }
]
Symptoms:
Access to XMLHttpRequest has been blocked by CORS policy
Solutions:
  1. Configure CORS in your backend to allow http://localhost:4200
  2. Use a proxy configuration in angular.json
  3. Deploy frontend and backend on the same domain
Create proxy.conf.json:
{
  "/api": {
    "target": "http://localhost:8080",
    "secure": false,
    "changeOrigin": true
  }
}
Update package.json:
"start": "ng serve --proxy-config proxy.conf.json"

Additional Resources

Build docs developers (and LLMs) love