Back to articles
Technology Insight

Building a Private Hugging Face Space Mirror on Vietnamese VPS: A Step-by-Step Guide Using Gitea LFS and Ollama

June 4, 2026

Introduction

In the rapidly evolving landscape of artificial intelligence, leveraging open-source models from repositories like Hugging Face has become a standard practice for enterprises worldwide. However, for businesses operating within Vietnam, relying solely on international cloud infrastructure introduces significant challenges. International bandwidth fluctuations, undersea cable disruptions, and stringent local data sovereignty regulations can severely impact the reliability and compliance of AI-driven applications.

To mitigate these risks, forward-thinking organizations are turning to localized infrastructure. This comprehensive guide will demonstrate how to build a Private Hugging Face Space Mirror on a Vietnamese Virtual Private Server (VPS). By combining the lightweight repository management of Gitea, the large file handling capabilities of Git LFS, and the localized inference power of Ollama, you can create a highly resilient, low-latency AI environment tailored for business needs.

Why Build a Private Hugging Face Mirror in Vietnam?

Deploying a localized mirror is not merely an exercise in infrastructure replication; it is a strategic business decision. Here are the primary advantages for Vietnamese enterprises:

  • Bandwidth Optimization: Downloading multi-gigabyte Large Language Models (LLMs) across international links is slow and costly. A local VPS utilizes domestic bandwidth (domestic peering), drastically reducing deployment and update times.
  • Data Privacy and Sovereignty: Localizing your models ensures that sensitive prompts, fine-tuning datasets, and proprietary configurations remain within the geographic borders of Vietnam, aligning with local compliance standards.
  • High Availability: When international fiber-optic cables experience downtime, your local mirror ensures that internal development teams and production applications continue to function without interruption.
---

Architectural Overview

The solution relies on three core components working in harmony on your Vietnamese VPS:

  1. Gitea: A fast, easy-to-use, and self-hosted Git service that serves as the central repository for your mirrored Hugging Face Spaces code.
  2. Git LFS (Large File Storage): An extension for Git that replaces large files—such as model weights (.safetensors, .bin)—with text pointers inside Git, while storing the file contents on your VPS file system or local object storage.
  3. Ollama: A robust framework designed to run LLMs locally, providing a clean API endpoint for your applications to consume the mirrored models efficiently.
---

Step 1: Preparing Your Vietnamese VPS Environment

Before initiating the installation, ensure your VPS meets the resource requirements for hosting and running AI models. We recommend a VPS provider with data centers in Hanoi or Ho Chi Minh City, offering at least 4 vCPUs, 16GB of RAM, and sufficient NVMe SSD storage to accommodate large model files.

Update your system packages and install the necessary dependencies, including Docker, which will streamline the deployment of our services:

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git git-lfs docker.io docker-compose

Once installed, initialize Git LFS on the system level to ensure all subsequent Git operations can handle large file pointers correctly:

git lfs install

---

Step 2: Deploying and Configuring Gitea with LFS Support

Gitea will act as our private alternative to Hugging Face's repository hosting. Using Docker Compose allows us to spin up Gitea along with its required database seamlessly.

Creating the Docker Compose Configuration

Create a dedicated directory and define the docker-compose.yml file:

version: "3"
services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__repository__ENABLE_LFS=true
      - GITEA__lfs__STORAGE_TYPE=local
      - GITEA__lfs__PATH=/data/git/lfs
    restart: always
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:22"

Run docker-compose up -d to start the service. Access the web interface via http://your-vps-ip:3000 to complete the initial setup wizard. Crucial step: Ensure that the LFS option remains enabled during the configuration phase.

---

Step 3: Cloning and Mirroring Hugging Face Spaces

With Gitea running, you can now mirror a Hugging Face Space repository. For this example, we will mirror a standard space utilizing an open-source model.

Cloning from Hugging Face

Clone the target Hugging Face repository using the full LFS configurations to ensure all model weights are pulled locally:

git clone --mirror [https://huggingface.co/spaces/username/space-name.git](https://huggingface.co/spaces/username/space-name.git)

If the repository utilizes large files, verify that Git LFS downloaded the actual weights rather than just the pointer files by inspecting the size of the repository folder. Next, create a new blank repository within your private Gitea instance and push the mirrored contents:

cd space-name.git
git push --mirror http://your-vps-ip:3000/your-organization/space-name.git

---

Step 4: Setting Up Ollama for Localized Inference

While Gitea handles the repository and model weight management, Ollama serves as the computational engine that runs the models efficiently on your VPS hardware.

Installation and Configuration

Install Ollama using the official automated script:

curl -fsSL [https://ollama.com/install.sh](https://ollama.com/install.sh) | sh

By default, Ollama binds to 127.0.0.1. To allow your mirrored applications or other internal services to access the inference engine, modify the systemd service to listen on all network interfaces. Edit the service file using sudo systemctl edit ollama.service and add the following environment variable:

[Service]
Environment="OLLAMA_HOST=0.0.0.0"

Save the file, reload the systemd daemon, and restart Ollama:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Importing Mirrored Models into Ollama

Navigate to your mirrored repository directory where the GGUF or Safetensors files are located. Create a configuration file named Modelfile to instruct Ollama how to build and optimize the model:

FROM ./path_to_mirrored_model/model.gguf
PARAMETER temperature 0.7
SYSTEM """You are a professional assistant operating on a highly secure, private enterprise network."""

Compile and run the model locally using the command line:

ollama create private-model -f Modelfile
ollama run private-model

---

Step 5: Connecting the Mirrored Space to Ollama

The final phase involves adapting the source code of the Hugging Face Space (often built using Gradio or Streamlit) to connect to your local Ollama API instead of the default Hugging Face or OpenAI endpoints.

Modify the application's configuration file (e.g., app.py) to redirect API calls locally:

import openai

# Configure the client to route requests to your local Ollama instance
client = openai.OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama" # Ollama does not require a structural key, but a placeholder is needed
)

response = client.chat.completions.create(
    model="private-model",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

Once the code adjustments are complete, commit the changes to your private Gitea repository. You can now execute the space locally using Docker or directly on the host machine, insulated from external internet constraints.

---

Conclusion

By self-hosting a private Hugging Face Space mirror using Gitea LFS and Ollama on a Vietnamese VPS, you unlock unmatched performance, complete data autonomy, and immunity to international connectivity disruptions. This infrastructure pattern provides a production-ready, highly secure foundation upon which your organization can confidently build and scale its proprietary AI solutions.

Building a Private Hugging Face Space Mirror on Vietnamese VPS: A Step-by-Step Guide Using Gitea LFS and Ollama | DPTCloud