Git:部署到OpenShift

Git:部署到OpenShift,git,deployment,openshift,Git,Deployment,Openshift,我在Bitbucket的Git存储库中有PHP/Laravel/JS项目 该项目应该通过基于Git的部署系统部署到OpenShift。他们为你的应用程序创建回购协议。你可以git克隆它。当您需要部署时,只需git push,OpenShift完成其余工作: 停止应用程序(web服务器) 将项目文件和配置(例如nginx.conf)写入正确的位置 执行自定义部署后操作(对于Laravel,这些操作至少是:composer update和php artisan migrate) 重新启动应用程序

我在Bitbucket的Git存储库中有PHP/Laravel/JS项目

该项目应该通过基于Git的部署系统部署到OpenShift。他们为你的应用程序创建回购协议。你可以
git克隆它。当您需要部署时,只需
git push
,OpenShift完成其余工作:

  • 停止应用程序(web服务器)
  • 将项目文件和配置(例如nginx.conf)写入正确的位置
  • 执行自定义部署后操作(对于Laravel,这些操作至少是:
    composer update
    php artisan migrate
  • 重新启动应用程序
很酷,但是:

  • *.php、nginx.conf、自定义部署后脚本等应同时推送到OpenShift和Bitbucket
  • 缩小的*.js、*.css——仅限OpenShift
  • 原始*.js、*.scss——仅限比特桶
  • gulpfile.js、Vagrant的config和其他开发人员——Bitbucket
  • Laravel的缓存,IDE配置——既不是OpenShift,也不是Bitbucket

最好的方法是什么?两个.git openshift和.git bitbucket(来源不同),而不是一个.git?那你呢,吉特?不使用OpenShift的部署系统?我应该使用哪种工具?或者,对于Bitbucket使用Hg而不是Git?

如果您希望在两个不同的存储库中使用不同的内容,那么我建议您实际创建两个独立的Git存储库。然后,您可以拥有一个自定义构建脚本,它将编译/缩小的文件放入一个单独的文件夹/repo中

另一种选择是在当前bitbucket回购上设置一个孤立的
,并将生产代码提交给该分支

git checkout --orphan production
# You can delete all your files, they're still safe on master branch
git rm -rf .
# Ignore the stuff you don't want on openshift
git add .gitignore
# You need to make an initial commit
git commit -m "Initial production commit"
在openshift上设置您的

# 1. Set the deployment branch with the rhc command line tool
$ rhc app-configure <app> --deployment-branch production
# Every time you push to openshift, push your production branch instead of master
$ git push openshift production

谢谢你的回复。但我恐怕我(愚蠢的)思维方式与你(正确的)完全不同。您所说的“并将您的生产代码提交给该分支”是什么意思?好吧,现在我有了一个没有历史记录的生产分支,并且只提交了一个文件.gitignore。我有另一个.gitignore的主分支,代码准备部署
git在推出git原始产品之前,我应该做什么?@user3368115检查我的编辑,我已经添加了一个可能的工作流程,正如我在原始问题中所写,我有4种文件:BB、OS,两者都没有。您的示例工作流解决了“OS”类文件的问题,但不是“两者都”的问题。好的,
git checkout production
不会从工作树OS文件中删除(自动生成),所以我可以添加提交推送文件。但是,
git checkout production
还将这两个文件(*.php)恢复为它们已经部署的生产版本。我想部署它们的主版本。您可以始终
git stash
,然后签出到生产,然后
git stash pop
。这应该可以吗?但正如我所说,我个人会有两种不同的回购协议
# Start from master branch
git checkout master
# Run your compilation scripts (whatever generates your production files)
./my-build-script.sh
# Then switch over to production branch
$ git checkout production
# Your changed files are still here, check it with git status, then add them
$ git add my-production-files/*
$ git commit -m "Add new built feature"
$ git push openshift production