gitlab cloudflare

deploy to cloudflare
gitlab cloudflare

GitLab MCP and Cloudflare Pages Deployment Setup

Needs for MacOS 26:

  • ✅ GitLab account
  • ✅ Cloudflare account
  • ✅ git
  • ✅ npm
  • ✅ go
  • ✅ node.js
  • ✅ Hugo (with a module)
  • ✅ Claude and extension to VSCode
  • ✅ Docker
  • ✅ free GitLab MCP server “zereight”
  • ✅ Cloudflare MCP - installed with Claude later

Free Gitlab MCP server project.

URL: https://github.com/zereight/gitlab-mcp?tab=readme-ov-file#readme

In your Gitlab click “Edit profile” -> avatar upper right corner

  • “Personal access tokens” on the left

  • Add new Token -> remeber/save the token somewehere

  • “Aplication” on the left

  • Add a new Application

  • Callback URL http://127.0.0.1:8888/callback

  • Scopes api

For Claude extension to VSCode

add the MCP server to .claude.json (in the working directory)

"mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "you_gitlab_token_here",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }

Start Gitlab MCP Server on Docker

docker run -i --rm \
  -e GITLAB_PERSONAL_ACCESS_TOKEN= you_gitlab_token_here \
  -e GITLAB_API_URL="https://gitlab.com/api/v4" \
  -e GITLAB_READ_ONLY_MODE=true \
  -e USE_GITLAB_WIKI=true \
  -e USE_MILESTONE=true \
  -e USE_PIPELINE=true \
  -e STREAMABLE_HTTP=true \
  -p 3333:3002 \
  iwakitakuma/gitlab-mcp

Testing GitLab MCP Server

User: mcp test for gitlab

Assistant: I’ll help you test the MCP (Model Context Protocol) integration for GitLab. Let me check the available MCP servers and then test the GitLab integration.

The GitLab MCP server is configured but failed to connect. Let me test the GitLab API connection with the configured credentials.

GitLab API Connection: ✅ Success

  • Authenticated as: LvizGit (el.curl)
  • Repository: LvizGit/LvizSpace
  • API Token: Valid and working

MCP Server Connection: ❌ Failed

  • Issue: npm cache contains root-owned files

Fix Required: Run this command in your terminal:

sudo chown -R 501:20 "/Users/elo/.npm"

User: fixed

Assistant: Great! Let me test the GitLab MCP server again now that the permissions are fixed.

GitLab MCP Test: SUCCESSFUL

MCP Server Status: Connected ✓

Project Information:

The GitLab MCP server is now fully operational!


Cloudflare MCP Servers

User: is there a cloudflare mcp server, i think so

Assistant: Yes! Cloudflare has 15 MCP servers available. Here are the popular options:

Available Cloudflare MCP Servers:

  • Browser Rendering - Fetch web pages, convert to markdown, take screenshots
  • Radar - Global Internet traffic insights, trends, URL scans
  • Workers Bindings - Build Workers with storage, AI, and compute primitives
  • Observability - Debug logs and analytics
  • Documentation - Get Cloudflare reference information
  • AI Gateway - Search logs and analyze prompts/responses
  • Container - Spin up sandbox development environments

These are remote MCP servers that use OAuth authentication.


Cloudflare Pages Deployment Setup

User: i am interested in gitlab to cloudflare page hosting

Assistant: Great! You want to deploy your GitLab repository to Cloudflare Pages. I can see you have a Hugo site currently deployed to GitLab Pages.

Steps:

  1. Go to Cloudflare Dashboard
  2. Navigate to Workers & Pages → Create application → Pages → Connect to Git
  3. Select “GitLab” and authorize Cloudflare
  4. Select your LvizGit/LvizSpace repository
  5. Configure Build Settings:
    • Build command: hugo --gc --minify
    • Build output directory: public
    • Root directory: /
  6. Environment variables:
    • HUGO_VERSION = 0.152.2
    • NODE_VERSION = 24.12.0
    • DART_SASS_VERSION = 1.96.0
    • TZ = Europe/Vienna

Option 2: GitLab CI/CD → Cloudflare Pages Deployment

This gives you more control and keeps your existing CI/CD pipeline.

User: option 1 prefer. it is deployed but not working correctly -> no errors in the build and deploy stages


Troubleshooting the Deployment

Assistant: Let me help troubleshoot your Cloudflare Pages deployment.

Your theme is a git submodule (Blowfish theme), which is the most common issue with Cloudflare Pages deployments.

Likely Issues:

Issue 1: Git Submodules Not Loaded ⚠️ (Most Common) Cloudflare Pages doesn’t clone git submodules by default. Fix by adding environment variable:

  • GIT_SUBMODULE_STRATEGY = recursive OR
  • CF_PAGES_FETCH_SUBMODULES = true

Issue 2: Wrong BaseURL Your current config has: baseURL = "https://pages.gitlab.io/LvizGit/LvizSpace" For Cloudflare Pages, you need to change this.

Issue 3: Hugo Version Mismatch Make sure you have HUGO_VERSION = 0.152.2

User: the hugo version is correct in cloudflare. the deployment URL is https://2fab0c19.lvizspace.pages.dev

Assistant: Found it! 🎯 The problem is the baseURL

Your site is being built with paths like /LvizGit/LvizSpace/img/salamander.png, but on Cloudflare Pages these resources don’t exist at those paths. They should be at /img/salamander.png instead.

The Fix:

Changed baseURL from https://pages.gitlab.io/LvizGit/LvizSpace to https://2fab0c19.lvizspace.pages.dev in config/_default/hugo.toml

Committed and pushed the changes to GitLab.

User: you are da king da supergenie :-) works

Assistant: Awesome! 🎉 Your Hugo site is now properly deployed on Cloudflare Pages!

What You’ve Got Now:

When You’re Ready for Your Custom Domain:

  1. In Cloudflare Pages dashboard, add lviz.com as a custom domain
  2. Update hugo.toml to use baseURL = "https://lviz.com"
  3. Push the change and you’ll be live on your domain

Setting Up Development Workflow

User: so for the future: should i make a branch let’s say develop and continue developing to this “develop” branch and then push it into main to trigger the deploy on cloudflare?

Assistant: Yes, that’s a great workflow! Here are a few options:

git checkout -b develop
# Make changes, test locally
git add . && git commit -m "your changes"
git push origin develop

# When ready to deploy:
git checkout main
git merge develop
git push origin main  # Triggers Cloudflare Pages deployment

Option 2: Feature Branches + Preview Deployments

Cloudflare Pages automatically creates preview deployments for every branch and merge request!

Each branch gets its own URL like feature-new-post.lvizspace.pages.dev to preview before merging.

Option 3: Direct to Main (Simple for Quick Updates)

Just push directly to main for small changes like blog posts.

User: well i have a free cloudflare account (for now) with a deploy limit of 500 per month so i have limited deployments. when you are talking about “Cloudflare Pages automatically creates preview deployments for every branch and merge request!” where does cloudflare create that?

Assistant: Great question about the deployment limits!

Where Preview Deployments Are Created:

  1. Cloudflare Pages Dashboard - Workers & Pages → lvizspace → View builds
  2. GitLab Merge Requests - Cloudflare adds a comment with the preview URL

Deployment Limits (Free Plan: 500/month)

What counts as a deployment:

  • ✅ Push to main = 1 deployment
  • ✅ Push to develop = 1 deployment
  • ✅ Push to feature-branch = 1 deployment

500 deployments = ~16 per day

Best Strategy for Your 500 Limit:

Option A: Develop Branch (Conservative)

# Work locally, test with hugo server
hugo server -D

# When satisfied, push to develop (1 deployment for preview)
git push origin develop

# Review, then merge to main (1 more deployment for production)

Cost: ~2 deployments per feature

Option B: Local Testing Only (Most Efficient)

# Test everything locally
hugo server -D

# Push directly to main when ready
git push origin main

Cost: 1 deployment per update

Option C: Disable Preview Deployments In Cloudflare Pages settings, disable automatic branch deployments and only deploy main.

My Recommendation: Test locally with hugo server, then push directly to main. Save preview deployments for major changes.

User: i think i will go with only deploy main only in cloudflare, develop locally with hugo of course and will push it to develop branch in gitlab for safety reasons.


Final Workflow Setup

Assistant: Perfect workflow! That’s smart and efficient.

1. Create Develop Branch

Created and pushed develop branch to GitLab ✅

2. Disable Preview Deployments in Cloudflare Pages

Go to: Workers & Pages → lvizspace → Settings → Builds & deployments

Configure:

  • Production branch: main
  • Enable automatic production branch deployments: ✅
  • Preview branch: None

User: in cloudflare branchcontrol - Production branch is main, checked Enable automatic production branch deployments, Preview branch is set to none

Assistant: Perfect! ✅ That’s exactly the right configuration.

Your Setup Summary:

Cloudflare Pages:

  • ✅ Production branch: main
  • ✅ Automatic production deployments: ON
  • ✅ Preview branches: None

GitLab Branches:

  • main - production (triggers Cloudflare deployment)
  • develop - your working branch (GitLab backup only, no deployment)

Your Workflow:

# Daily work
git checkout develop
hugo server -D           # Test locally at localhost:1313
git add . && git commit -m "changes"
git push origin develop  # ✅ Saves to GitLab, NO Cloudflare deployment

# Ready to publish
git checkout main
git merge develop
git push origin main     # ✅ Triggers Cloudflare deployment (1 deploy)
git checkout develop     # Back to work

Result: You’ll use way fewer than 500 deployments per month - probably just 10-20 for actual publishing!


Summary

What We Accomplished:

  1. ✅ Tested GitLab MCP server - Fixed npm permissions, now connected
  2. ✅ Fixed Cloudflare Pages deployment - Changed baseURL from GitLab Pages path to Cloudflare Pages URL
  3. ✅ Set up develop branch workflow:
    • develop branch for daily work + GitLab backup
    • main branch for production (only this triggers Cloudflare deployment)
    • Configured Cloudflare to only deploy main (saves your 500/month limit)
  4. ✅ Your site is live at https://2fab0c19.lvizspace.pages.dev with proper styling

Key Files Changed:

  • config/_default/hugo.toml - Updated baseURL

Your Workflow:

git checkout develop          # Work here
hugo server -D                # Test locally
git push origin develop       # Save to GitLab (no deploy)

# When ready to publish:
git checkout main
git merge develop
git push origin main          # Deploys to Cloudflare

Conversation saved on December 15, 2025