drjk87189 2016-08-09 08:34
浏览 39

麻烦创建一个简单的部署应用程序

I created a deployment application for my PHP applications, in fact this is a simple PHP page managing 3 environments (dev, rc, prod).
This page gets the informations about the last commit and about each environments, allowing developer to change the version of an environments using tags.
I saw several application (e.g. github, packagist...) using tags for versions but i am getting some trouble with it.
Previously, i was using SVN and it was very easy and fast to do it, so i am getting frustated by Git and maybe you could help me.
I am using gitlab and github for several projects.

First, be careful that only one git remote request can be very slow (1 to 6 seconds)

Get informations about last commit
To get these informations, i have to fetch the dev environment then i am doing git --no-pager show --name-status --format="__TOKEN__%n%H%n%T%n%P%n%d%n%an%n%ae%n%aD%n%cn%n%ce%n%cD"
I am using a random __TOKEN__ to parse the result, git can add more information before it but i dont care.
So the result could be:

___DATA-57a988c31bbf2___
b4041b95c0221fe211ea74110a421842f625f2c8
2287ccb797fc886055a5f4afc56aa90d7dcf4a4e
d1c618e0f50783efff209ba6c0752d55f14bd241
(HEAD, v0.1.7.2, origin/master, origin/HEAD, master)
Loenix
myemail@domain.com
Mon, 8 Aug 2016 15:09:44 +0200
Loenix
myemail@domain.com
Mon, 8 Aug 2016 15:09:44 +0200

This is working but i have to fetch it each time.

I am getting informations about environments in the same way.

List versions (tags)
Now, I need to list all version with name and date, so i am doing git for-each-ref --sort=taggerdate --format "%(tag)|%(taggerdate)" refs/tags | sort -V
I am getting as results:

v0.1.5|Mon Jun 6 22:14:18 2016 +0200
v0.1.6|Mon Jun 6 22:47:02 2016 +0200
v0.1.7.1|Mon Aug 8 13:55:59 2016 +0200
v0.1.7.2|Mon Aug 8 15:10:02 2016 +0200
v0.1.7|Mon Aug 8 13:36:12 2016 +0200

This is not sorting well.

Change version of an environment
I currently find 2 solutions:

  1. git checkout v0.1.7.2 This update current version to new one. The problem is when i am using composer, composer.lock is changed locally and git return an error.
  2. git reset --hard v0.1.7.2 This replaces all things in folder...

I could fix the composer.lock error by ignoring it.

I am getting some trouble to manipulate versions because an environment could be branched on master or on a tag and i am not able to efficiently identify the tag (version) of an environment.

I am caching tags but by this way, my page takes 5-10 seconds to load...

Can you help me to fix the troubles ? Have you some advices ? Do you think I should do it by another way ? I could also use a simple existing deployment application but i didn't find any good one.

PS: All commands are runned using system() PHP function on a debian/ubuntu OS.

  • 写回答

1条回答 默认 最新

  • duanhuanbo5225 2016-08-09 13:00
    关注

    Loenix, I think in your case the best way is to use a dedicated software, eg. buddy.works. You can create a separate deployment environment for each server (they call it pipelines in Buddy) + the app itself is lightweight and very simple to use (you just click stuff out).

    Manual deployment with system() is hard and may be prone to errors

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器