數(shù)據(jù)庫(kù)安裝
拉取postgresql數(shù)據(jù)庫(kù)鏡像且運(yùn)行容器
[root@localhost ~]# docker pull postgres:9.4
[root@localhost data]# docker run --name gogs_pg -v /data/gogs/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -p 5432:5432 -d postgres:9.4
2a748fb74403a6cdb6d9bc3db44659a75daedb3e1771d6df0d359130f0041cb0
拉取gogs鏡像并啟動(dòng)容器
1: 拉取鏡像
[root@localhost ~]# docker search gogs
不要搞錯(cuò)鏡像名稱協(xié)成 [root@localhost ~]# docker pull gogs
[root@localhost ~]# docker pull gogs/gogs
2:查看鏡像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 7d64f4d8e205 21 minutes ago 41.1MB
flaskmimi v1 684f5068c203 33 minutes ago 930MB
<none> <none> 89ff27e65c45 38 minutes ago 89.9MB
gogs/gogs latest e74419abc2b9 3 days ago 96.1MB
dockerflask latest 476011fc293b 5 days ago 924MB
flask_web_stj latest 1410b6bc6d9d 2 weeks ago 913MB
newmynginx latest cd903b9a327f 2 weeks ago 146MB
python 3.6-alpine 876b6a885b74 2 weeks ago 40.2MB
python 3.6 1297140c6dd2 2 weeks ago 874MB
python 3.7-alpine 6b73b71fd64e 2 weeks ago 41.1MB
tomcat latest 891fcd9c5b3a 5 weeks ago 647MB
nginx latest f35646e83998 5 weeks ago 133MB
redis 4.0.14 191c4017dcdd 6 months ago 89.3MB
postgres 9.4 ed5a45034282 9 months ago 251MB
hell02 latest bf756fb1ae65 10 months ago 13.3kB
centos centos7.1.1503 e1430271e2f9 20 months ago 212MB
python 3.6.5-alpine 5be6d36f77ee 2 years ago 89.9MB
ubuntu 15.10 9b9cb95443b5 4 years ago 137MB
[root@localhost ~]#
3: 啟動(dòng)容器并掛載數(shù)據(jù)到外部
docker run --name=gogs -p 10022:22 -p 10080:3000 -v /data/gogs/data:/data gogs/gogs
后臺(tái)啟動(dòng)
docker run --name=gogs -p 10022:22 -p 10080:3000 -v /data/gogs/data:/data -d gogs/gogs
4: 重新的啟動(dòng)后臺(tái)啟動(dòng)容器
[root@localhost ~]# docker start gogs
gogs
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
19e9c50af663 gogs/gogs "/app/gogs/docker/st…" About a minute ago Up 6 seconds 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->3000/tcp gogs
f16826df749b 7d64f4d8e205 "/bin/sh -c 'apk add…" 30 minutes ago Up 30 minutes mystifying_hopper
[root@localhost ~]#
配置對(duì)應(yīng)的數(shù)據(jù)
(1)查看當(dāng)前運(yùn)行的容器
[root@localhost data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1a046e8e2783 gogs/gogs "/app/gogs/docker/st…" 10 seconds ago Up 9 seconds 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->3000/tcp gogs
2a748fb74403 postgres:9.4 "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:5432->5432/tcp gogs_pg
[root@localhost data]# ^C
[root@localhost data]#
(2)通過瀏覽器訪問地址配置運(yùn)行信息
http://192.168.219.130:10080/install
(3)數(shù)據(jù)庫(kù)配置運(yùn)行信息

修正數(shù)據(jù)庫(kù)主機(jī)

再修正



使用工具先新建數(shù)據(jù)庫(kù)

再繼續(xù)安裝
(4)應(yīng)用基本信息配置

(5)其他信息配置

(6)立即安裝(注意需要先新建數(shù)據(jù)庫(kù)名稱,再執(zhí)行立即安裝)

PS:密碼設(shè)置為
zyx308711822賬號(hào):
zyx308711822620PW
使用操作篇
(1)新建組織

錯(cuò)誤提示



(2) 團(tuán)隊(duì)操作

(3) 新建倉(cāng)庫(kù)

(4) http方式獲取倉(cāng)庫(kù)

從命令行創(chuàng)建一個(gè)新的倉(cāng)庫(kù)
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://192.168.219.130:10080/mycode/test.git
git push -u origin master
從命令行推送已經(jīng)創(chuàng)建的倉(cāng)庫(kù)
git remote add origin http://192.168.219.130:10080/mycode/test.git
git push -u origin master
(5) windows下git服務(wù)端安裝和下載安裝git客戶端用戶本地進(jìn)行相關(guān)的倉(cāng)庫(kù)的操作
服務(wù)端git
下載地址:https://git-scm.com/downloads
tortoisegit
下載地址:
https://tortoisegit.org/download/
Sourcetree
下載地址:https://www.sourcetreeapp.com/
使用介紹:https://www.cnblogs.com/tian-xie/p/6264104.html
或者直接使用騰訊管家安裝
git安裝:(參考:https://blog.csdn.net/qq_41868500/article/details/85778784)
1.雙擊安裝程序“Gitxxxxx.exe”:

2.點(diǎn)擊“Next”,顯示如下:

3.點(diǎn)擊“Next”,顯示如下

選擇說明:
說明:
(1)圖標(biāo)組件(Addition icons) : 選擇是否創(chuàng)建桌面快捷方式。
(2)桌面瀏覽(Windows Explorer integration) : 瀏覽源碼的方法,使用bash 或者 使用Git GUI工具。
(3)關(guān)聯(lián)配置文件 : 是否關(guān)聯(lián) git 配置文件, 該配置文件主要顯示文本編輯器的樣式。
(4)關(guān)聯(lián)shell腳本文件 : 是否關(guān)聯(lián)Bash命令行執(zhí)行的腳本文件。
(5)使用TrueType編碼 : 在命令行中是否使用TruthType編碼, 該編碼是微軟和蘋果公司制定的通用編碼。

4.點(diǎn)擊“Next”,顯示如下

5.點(diǎn)擊“Next”,顯示截圖如下:

設(shè)置環(huán)境變量
選擇使用什么樣的命令行工具,一般情況下我們默認(rèn)使用Git Bash即可:
(1)Git自帶:使用Git自帶的Git Bash命令行工具。
(2)系統(tǒng)自帶CMD:使用Windows系統(tǒng)的命令行工具。
(3)二者都有:上面二者同時(shí)配置,但是注意,這樣會(huì)將windows中的find.exe 和 sort.exe工具覆蓋,如果不懂這些盡量不要選擇。
6.選擇之后,點(diǎn)擊“Next”,顯示截圖如下:

7.選擇之后,繼續(xù)點(diǎn)擊“Next”,顯示如下:

選擇提交的時(shí)候換行格式
(1)檢查出windows格式轉(zhuǎn)換為unix格式:將windows格式的換行轉(zhuǎn)為unix格式的換行再進(jìn)行提交。
(2)檢查出原來格式轉(zhuǎn)為unix格式:不管什么格式的,一律轉(zhuǎn)為unix格式的換行再進(jìn)行提交。
(3)不進(jìn)行格式轉(zhuǎn)換 : 不進(jìn)行轉(zhuǎn)換,檢查出什么,就提交什么。
8.選擇之后,點(diǎn)擊“Next”,顯示截圖如下:

9.選擇之后,點(diǎn)擊“Next”,顯示截圖如下:




10.安裝完成之后,顯示截圖如下: 、

客戶端安裝:
參考:https://blog.csdn.net/qq_39505065/article/details/89404148?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control









查看右鍵菜單信息:

(6) 然后進(jìn)行命令的操作
參考:http://www.itdecent.cn/p/86c385682ac8
在windos下某個(gè)目錄下創(chuàng)建一個(gè)文件夾

進(jìn)入到mycode里面進(jìn)行g(shù)it初始化


從命令行創(chuàng)建一個(gè)新的倉(cāng)庫(kù)
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://192.168.219.130:10080/mycode/test.git
git push -u origin master

輸入錯(cuò)誤的密碼和用戶之后的解決方案
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode (master)
$ git push -u origin master
libpng warning: iCCP: cHRM chunk does not match sRGB
fatal: Authentication failed for 'http://192.168.219.130:10080/mycode/test.git/'
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode (master)
$ git remote add origin http://192.168.219.130:10080/mycode/test.git
fatal: remote origin already exists.

mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode (master)
$ git push -u origin master
libpng warning: iCCP: cHRM chunk does not match sRGB
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 205 bytes | 205.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.219.130:10080/mycode/test.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode (master)
查看提交的日志:

查看倉(cāng)庫(kù)情況


從命令行推送已經(jīng)創(chuàng)建的倉(cāng)庫(kù)
git remote add origin http://192.168.219.130:10080/mycode/test.git
git push -u origin master
(7) 通過HTTP方式獲取倉(cāng)庫(kù)



使用命令操作提交最新的操作:
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ touch xiaozhong.text
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ nano xiaozhong.text
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ git
git.exe git-lfs.exe
git-askyesno.exe git-receive-pack.exe
git-credential-helper-selector.exe git-upload-archive.exe
gitdll.dll git-upload-pack.exe
gitdll32.dll GitWCRev.exe
git-flow GitWCRevCOM.exe
gitk
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ git add .
warning: LF will be replaced by CRLF in xiaozhong.text.
The file will have its original line endings in your working directory
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ git commit -m '新的一次的提交測(cè)試'
[master 4cbd634] 鏂扮殑涓€嬈$殑鎻愪氦嫻嬭瘯
1 file changed, 1 insertion(+)
create mode 100644 xiaozhong.text
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 316 bytes | 316.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.219.130:10080/mycode/test.git
495c450..4cbd634 master -> master
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/mycode2/test (master)
$
查看最新的倉(cāng)庫(kù)情況:

(7) 通過SSH獲取倉(cāng)庫(kù)(有問題暫未解決)
首先檢查本地.shh下是否存在公鑰信息
- 第一步: 進(jìn)入到我們的服務(wù)器上面進(jìn)行,在當(dāng)前根目錄下可以執(zhí)行執(zhí)行完ssh-keygen之后
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:9nAaAXX/81fFMSRRcCyfhPHsXC4gsC/n94UFi2vYqec root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| ..o . =O* |
| . + . o=+o|
| o . o =o=|
| o . +o*o|
| S + . =o+|
| . X o o *.|
| . + * . +|
| +.. ..|
| .oE . |
+----[SHA256]-----+
[root@localhost ~]# ^C
[root@localhost ~]#

執(zhí)行完ssh-keygen之后
執(zhí)行完ssh-keygen之后會(huì)在,用戶目錄下的.ssh文件下,生成一個(gè)id_rsa文件和id_rsa.pub文件。
id_rsa文件是私鑰,要保存好,放在本地,私鑰可以生產(chǎn)公鑰,反之不行。
id_rsa.pub文件是公鑰,可以用于發(fā)送到其他服務(wù)器,或者git上。
- 第二步: 查看我們的文件是公鑰且復(fù)制id_rsa.pub公鑰內(nèi)容
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGuBF8GDFfosUtcyc90RTfKtk0uyqHpsVBiHjTxS/0YjgOY4+ouaZ2szwWHmLvk68cyWgRC2xsy4A/Y7BuUXcz0FjWGaNjIg1ajSBqhL7xSg6cstQ/+buGFg4XntyY87ouSEstqdb4gjDf/BC8Ef71G53EKQJ2oUWAXr1sdC/eVEWSR9sExZBzYY6KKVJCIceS81wMxQResxqna03Oh5pQQZChWHniK+Pxmzs4Q7P7OMr4h0L0Jct6xZU383TyRuf9T/tpMn4QA47chTw+7/rhK7xG51eNpdb8F0qQErpdpIPuj5w9MgtmqLCe8JMsDmC0w1DMMsiinL4IBUptR0VN root@localhost.localdomain
[root@localhost ~]#


- 第三步: 復(fù)制ssh連接倉(cāng)庫(kù)需要的參數(shù)

指定的目錄下:

mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/sshmycode
$ git clone ssh://git@192.168.219.130:10022/mycode/test.git
Cloning into 'test'...
The authenticity of host '[192.168.219.130]:10022 ([192.168.219.130]:10022)' can't be established.
ECDSA key fingerprint is SHA256:dGdauklR4xJocchH0fU6Im93ODe7JN2OcOJzEnc6BM4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '[192.168.219.130]:10022' (ECDSA) to the list of known hosts.
git@192.168.219.130: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
mayn@DESKTOP-16CKEN1 MINGW64 /d/code/gitpro/sshmycode
$
提示異常:
Warning: Permanently added '[192.168.219.130]:10022' (ECDSA) to the list of known hosts.
git@192.168.219.130: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
提示異常2:

Gogs 設(shè)置Git鉤子實(shí)現(xiàn)項(xiàng)目自動(dòng)部署測(cè)試

pre-receive:接收前
update:接收時(shí)
post-receive接收后 (如果push代碼后實(shí)現(xiàn)更新部署可執(zhí)行這個(gè)會(huì)用到post-receive)
編輯測(cè)試更新后 執(zhí)行某個(gè)腳本,在我們的某個(gè)文件創(chuàng)建一個(gè)目錄
PS:因?yàn)槲覀兊氖褂昧藬?shù)據(jù)卷的,所以一般是需要給與外置的GOGS的數(shù)據(jù)卷的賦予一定的權(quán)限
編寫腳本信息:
#!/bin/bash
mkdir -p /data/ceshigogspull

PULL前:查看本地的目錄文件情況:
[root@localhost .ssh]# cd /data/
[root@localhost data]# ls
backup composetest dockerflask html web_statistics wwwroot2
bak dockerceshilink gogs jiao www
ceshi dockerflask houtaiquandian.tar QQpro wwwroot
[root@localhost data]#

PULL后:查看本地的目錄文件情況:

查看內(nèi)容


說沒我們的鉤子已經(jīng)能夠執(zhí)行了!!!