|
1 |
| -# GitHooks Docker Builder |
2 |
| - |
3 |
| -## TÜRKÇE |
4 |
| - |
5 |
| -Git Server'ı uzaktaki makinede kurmak için uzaktaki makinede aşağıdaki komutları çalıştırın. |
6 |
| -```sh |
7 |
| - $ git_server_scripts/stup.sh |
8 |
| -``` |
9 |
| -### GitHooks |
10 |
| -Githooks bizler için CI süreçlerini hızlandırmamızı ve otomatize etmemizi sağlayan bir yapıdır. |
11 |
| -Githook içerisinde sahip olduğu eventler sayesinde yapılması gereken işleri tetikler. |
12 |
| - |
13 |
| -Bu eventlere örnek verecek olursak. |
14 |
| -* post_recevie |
15 |
| -- pre_receive |
16 |
| -* pre_commit |
17 |
| - |
18 |
| -gibi onlarca event githooks tarafından bilinmektedir. |
19 |
| - |
20 |
| -* post_receive: |
21 |
| - |
22 |
| -```sh |
23 |
| -Bulunulan repoya herhangi bir push geldiğinde buraya subscribe |
24 |
| -edilmiş işlemler yaptırılır. |
25 |
| - |
26 |
| -``` |
27 |
| - |
28 |
| -* pre_commit : |
29 |
| - |
30 |
| -```sh |
31 |
| -Siz Commit atmadan önce developer tarafta çalıştırılan |
32 |
| -eventleri ekliyoruz.Mesela testlerimizi yazdık ve pre_commit |
33 |
| -eventlerimize testlerimizi çalıştırabilmesini sağlayabiliriz. |
34 |
| - |
35 |
| -``` |
36 |
| -Ben şuanlık projemizde kullanacağımız eventleri açıkladım. |
37 |
| - |
38 |
| -### Bu projemizde nerede kullandık? |
39 |
| - |
40 |
| -* Pre_Receive eventi bizim gelen pushları alıp docker imagelarını |
41 |
| -build ediyor ve kendi registrymize gönderiyor veya dockerhubda sizin kendi hesabınıza |
42 |
| -son imageı göndermektedir. |
43 |
| - |
44 |
| -### Kurulum |
45 |
| -```sh |
46 |
| - |
47 |
| - Devamı gelecek . |
48 |
| -``` |
49 |
| - |
50 |
| -# HOOKSLARI İNCELEME |
51 |
| - |
52 |
| - |
53 |
| -Pre Receive hooks is triggering some methods for us. |
54 |
| -This methods building docker images. |
55 |
| - |
56 |
| -Pre Receive bizim için kendi içerisindeki metodları tetikler.Bu metodlar docker imajlarını inşa ede. |
57 |
| - |
58 |
| -Eğer master branche bir push gelirse gereken bu tüm repoya ait docker ortamını ayaklandırır. |
59 |
| - |
60 |
| -```py |
61 |
| -### post-receive |
62 |
| -from builder import Builder |
63 |
| -dev = Builder() |
64 |
| -print dev.build_image() |
65 |
| - |
66 |
| -``` |
67 |
| - |
68 |
| -Builder Class/build_image metoduna bakalım |
69 |
| - |
70 |
| -Bu metod bizim imajımızı inşa eder ve sonuçları API'ye post eder. |
71 |
| -```py |
72 |
| - |
73 |
| -def build_image(self): |
74 |
| - |
75 |
| - try: |
76 |
| - image = self.client.images.build(path=self.get_docker_file_place()) |
77 |
| - |
78 |
| - try: |
79 |
| - r = requests.put('http://localhost:5000/{}'.format('project_1'), data={"status": "BUILT "}) |
80 |
| - return "POSTED" + str(r.status_code) |
81 |
| - |
82 |
| -``` |
83 |
| - |
84 |
| - |
85 |
| - |
86 |
| - |
87 |
| - |
88 |
| -# ENG |
89 |
| -For setup git server on your remote machine run this on your remote machine. |
90 |
| - |
91 |
| -Githooks is structure make our CI process fast.Githooks trigger the which process subscribe on it. |
92 |
| - |
93 |
| -Githooks triggering though of its own events it has. |
94 |
| - |
95 |
| -For example |
96 |
| -* post_recevie |
97 |
| -- pre_receive |
98 |
| -* pre_commit |
99 |
| - |
100 |
| -we have lots of githooks events. |
101 |
| - |
102 |
| -Explanation some events : |
103 |
| - |
104 |
| -* post_receive: |
105 |
| - |
106 |
| -This event to do jobs if repository got new push. |
107 |
| -* pre_commit : |
108 |
| - |
109 |
| - |
110 |
| -Pre Commit is usign on developer side.You can write your tests |
111 |
| -and work before commiting process.Commiting process trigger the |
112 |
| -pre-commit event. |
113 |
| - |
114 |
| -I explained the events above which events to use in this project |
115 |
| - |
116 |
| -Where used in this Project ? |
117 |
| - |
118 |
| -* If any commit pushed on your local git repository,post_receive |
119 |
| -event build the docker image and push where you want(DockerHub or your own DockerRegistry). |
120 |
| - |
121 |
| - |
122 |
| -### Installation |
123 |
| -```sh |
124 |
| - Coming soon . |
125 |
| -``` |
126 |
| - |
127 |
| - |
128 |
| - |
129 |
| - |
130 |
| -# DIVING TO THE HOOKS |
131 |
| - |
132 |
| - |
133 |
| -Pre Receive hooks is triggering methods for us inside own. |
134 |
| -This methods building docker images. |
135 |
| - |
136 |
| - |
137 |
| -If a push came to the master branch this hooks build docker images. |
138 |
| -Little code block : |
139 |
| -```py |
140 |
| -### post-receive |
141 |
| -from builder import Builder |
142 |
| -dev = Builder() |
143 |
| -print dev.build_image() |
144 |
| - |
145 |
| -``` |
146 |
| - |
147 |
| -And look to the Builder Class/build_image: |
148 |
| - |
149 |
| -This build the user docker environment and post the status to the api. |
150 |
| -```py |
151 |
| - |
152 |
| -def build_image(self): |
153 |
| - |
154 |
| - try: |
155 |
| - image = self.client.images.build(path=self.get_docker_file_place()) |
156 |
| - |
157 |
| - try: |
158 |
| - r = requests.put('http://localhost:5000/{}'.format('project_1'), data={"status": "BUILT "}) |
159 |
| - return "POSTED" + str(r.status_code) |
160 |
| - |
161 |
| -``` |
162 |
| - |
163 |
| - |
164 |
| - |
165 |
| - |
166 |
| - |
167 |
| - |
168 |
| - |
| 1 | +# Auto Ferruh |
| 2 | +## AutoMate Docker Registry with CI PipeLine |
0 commit comments