You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

多仓库Docker应用Git仓库拆分可行性及方案咨询

Absolutely feasible—and since development hasn't started yet, this is the perfect time to split things up cleanly without any messy commit history to untangle. Let's break down how to do this smoothly, plus some workflow tips for your team afterward.

Feasibility Breakdown

This split makes total sense for your setup:

  • The PHP API and Angular web client are independent applications, so they deserve their own repositories for separate CI/CD, versioning, and team ownership.
  • The shared Docker configs (MySQL, Nginx, docker-compose.yml) can live in a central repository that both teams reference, keeping infrastructure consistent across environments.
Step-by-Step Split Plan

1. Create 3 Empty Git Repositories

First, spin up three blank repos on your Git host (GitHub, GitLab, etc.):

  • your-php-api-repo (for the api/ content)
  • your-angular-web-repo (for the web-client/ content)
  • your-shared-docker-repo (for docker/ and docker-compose.yml)

2. Extract the PHP API

Head into your original monorepo and pull out the API code into its own repo:

# Navigate to the API directory
cd api/
# Initialize a new Git repo here
git init
# Stage all files and make your first commit
git add .
git commit -m "Initial commit: PHP API base code"
# Link to your new remote repo and push
git remote add origin <your-php-api-repo-url>
git push -u origin main
# Go back to the monorepo root and delete the old api/ folder
cd ..
rm -rf api/

3. Extract the Angular Web Client

Repeat the same process for the web client:

# Navigate to the web client directory
cd web-client/
git init
git add .
git commit -m "Initial commit: Angular web client base"
git remote add origin <your-angular-web-repo-url>
git push -u origin main
# Clean up the monorepo
cd ..
rm -rf web-client/

4. Set Up the Shared Docker Repository

Now move the remaining Docker assets into their own central repo:

# Create a temporary folder to organize this
mkdir ../shared-docker-temp
# Move the docker/ folder and docker-compose.yml into it
mv docker/ docker-compose.yml ../shared-docker-temp/
# Navigate to the temp folder and initialize Git
cd ../shared-docker-temp/
git init
git add .
git commit -m "Initial commit: Shared Docker configs (MySQL, Nginx) and docker-compose"
# Link to the remote and push
git remote add origin <your-shared-docker-repo-url>
git push -u origin main

You can now delete your original monorepo (since there's no history to preserve) or repurpose it if needed.

Post-Split Workflow for Your Team

For Developers

To get a full working environment, each dev will:

  1. Clone the shared Docker repo first:
    git clone <your-shared-docker-repo-url> my-project-infra
    
  2. Inside that repo, create and clone the API/web client repos into the expected directories:
    cd my-project-infra
    git clone <your-php-api-repo-url> api
    git clone <your-angular-web-repo-url> web-client
    
  3. Run docker-compose up as usual—everything will work just like it did before, but now each app is in its own repo.

Independent Maintenance

  • The API team can work exclusively in their repo, pushing changes and pulling updates directly into the api/ folder in their local Docker setup.
  • The web team does the same for their Angular code.
  • Any changes to Docker infrastructure (like updating Nginx configs or MySQL versions) happen in the shared Docker repo, and everyone pulls those updates to stay consistent.
Optional: Use Git Submodules for a "Meta" Repo

If you want a single entry point to pull all components at once, create a meta-repo that uses Git submodules:

git init my-project-meta
cd my-project-meta
# Add each repo as a submodule
git submodule add <your-php-api-repo-url> api
git submodule add <your-angular-web-repo-url> web-client
git submodule add <your-shared-docker-repo-url> docker-config
# Copy the docker-compose.yml into the meta repo (or keep it in the docker-config submodule)
cp docker-config/docker-compose.yml .
# Commit the setup
git add .gitmodules api web-client docker-config docker-compose.yml
git commit -m "Initial meta repo with all project components"

Developers can clone this with git clone --recurse-submodules <meta-repo-url> to get everything in one go.


内容的提问来源于stack exchange,提问作者James Crinkley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:01:55