<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by DylanHuang on Medium]]></title>
        <description><![CDATA[Stories by DylanHuang on Medium]]></description>
        <link>https://medium.com/@j75689?source=rss-1c968f625fa1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9Tw9NVbeJbIaq35g6Zzv1g.jpeg</url>
            <title>Stories by DylanHuang on Medium</title>
            <link>https://medium.com/@j75689?source=rss-1c968f625fa1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:23:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@j75689/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Go Plugin & goloader 動態加載使用範例]]></title>
            <link>https://medium.com/@j75689/go-plugin-goloader-%E5%8B%95%E6%85%8B%E5%8A%A0%E8%BC%89%E4%BD%BF%E7%94%A8%E7%AF%84%E4%BE%8B-e50a88b4db76?source=rss-1c968f625fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e50a88b4db76</guid>
            <dc:creator><![CDATA[DylanHuang]]></dc:creator>
            <pubDate>Sat, 08 Feb 2020 12:43:22 GMT</pubDate>
            <atom:updated>2020-02-08T12:43:22.150Z</atom:updated>
            <content:encoded><![CDATA[<p>最近需要開發新的模組，為了因應之後各種不同的需求，可能會需要在新增不同的function，因此想說在golan上是否有辦法實作跟 <a href="https://github.com/Kong/kong">kong</a> 一樣可以透過加載plugin的方式來擴充功能呢？<br>透過google尋找各種解方後找到了 <a href="https://golang.org/pkg/plugin/">plugin</a> 及 <a href="https://github.com/dearplain/goloader">goloader</a> 這兩個方式，以下就來介紹一下吧！</p><h3>Plugin</h3><p>go <a href="https://golang.org/pkg/plugin/">plugin</a>是在go 1.8+ 推出的功能，可以透過單獨編譯成.so檔案，再透過主程式加載後呼叫。<br>目前僅支援linux及mac os（實際使用go 1.11.4可以用），不支援windows，且不同平台需要重新編譯對應的.so檔案。</p><p>範例（<a href="https://github.com/j75689/go-example/tree/master/go-plugin">code</a>）</p><h3>Goloader</h3><p><a href="https://github.com/dearplain/goloader">goloader</a>是由<a href="https://github.com/dearplain">dearplain</a>撰寫的一套動態執行go語言的package，與plugin不同它比較像是透過連結的方式，因此如果單獨要執行的code中有import 其他library，在主程式中也需要import才能正確執行。<br>但好處就是可以支援linux,windows,mac os，且不同平台不需要重新編譯單獨檔案。</p><p>範例（<a href="https://github.com/j75689/go-example/tree/master/goloader">code</a>）</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e50a88b4db76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用Drone 自動部署 GAE 服務]]></title>
            <link>https://medium.com/@j75689/%E4%BD%BF%E7%94%A8drone-%E8%87%AA%E5%8B%95%E9%83%A8%E7%BD%B2-gae-%E6%9C%8D%E5%8B%99-e480a5077572?source=rss-1c968f625fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e480a5077572</guid>
            <category><![CDATA[google-app-engine]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[drone-ci]]></category>
            <dc:creator><![CDATA[DylanHuang]]></dc:creator>
            <pubDate>Mon, 11 Jun 2018 14:53:30 GMT</pubDate>
            <atom:updated>2018-06-11T15:04:14.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*XiFx190mY39diP2LmvGa7Q.png" /></figure><p>最近想要做一個自己的Demo網站，在諸多選擇下決定把它放在Goole Cloud AppEngine</p><p>之前已經有架設好Drone Server，當然要用它來自動部署一下囉～</p><h3>Step.1 建立CI專用的服務帳戶</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*-d2IZ77Y7IBTv8CbB6WZ9w.png" /><figcaption>到gcp管理頁面-&gt;IAM與管理員-&gt;服務帳戶</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*oOp3sCbepoQD-3eBQAJDsA.png" /><figcaption>選擇建立服務帳戶</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*BTS5gb6swv9cJcmrF4acGw.png" /><figcaption>輸入服務的名稱-&gt;角色選擇project-編輯者（也可以選擇只開GAE的服務部分）-&gt;最後建立私鑰類型選擇JSON</figcaption></figure><blockquote>選擇儲存之後便會自動把產生的Json金鑰檔案存下來，這需要用來做gcp的認證</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*9sXZCT8RZ3dwasFE6WEL7Q.png" /><figcaption>然後到API的控管頁面</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*HpfB_ldddfmN4nNzCBP_Gw.png" /><figcaption>搜尋找到GAE Admin API將它Enable</figcaption></figure><h3>Step.2 配置.drone.yml</h3><p>第一件事就是把剛剛down下來的json金鑰加進drone的secret裡面，這樣CI才能在gcloud驗證通過，使用以下指令（需先安裝<a href="http://docs.drone.io/cli-installation/">drone-cli</a>)</p><pre>drone secret add \<br> -repository ${your_repo_name} \<br> -image nytimes/drone-gae \<br> -name gae_credentials \<br> -value @{your_json_key}.json</pre><blockquote>這邊使用CLI是因為可以將secret綁定image，避免金鑰被其他地方使用<br>可以參考 <a href="https://blog.wu-boy.com/2017/11/drone-secret-security/">Drone Secret 安全性管理</a></blockquote><p>在來就是配置.drone.yml，可以參考下面<br>所幸已經有大大開發出<a href="https://github.com/NYTimes/drone-gae">drone-gae</a>的plugin給drone<br>所以就可以直接拿來使用囉</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0b0991683a0041a58fba223455f07ff/href">https://medium.com/media/b0b0991683a0041a58fba223455f07ff/href</a></iframe><blockquote>在測試的時候多次deploy都失敗...好像是因為plugin的gcloud sdk版本太舊的關係？一直無法正常deploy，因此我只好自己重新打包了一個<a href="https://hub.docker.com/u/dylanhuang/">dylanhuang</a>/<a href="https://hub.docker.com/r/dylanhuang/drone-gae/">drone-gae</a>使用官方的gcloud-sdk image作基底（但就不支援appcfg的方法）</blockquote><blockquote>大家可以嘗試看看囉</blockquote><h3>Step.3 配置app.yaml</h3><p>當然也可以不要用app.yaml，反正透過grone-gae可以設定app_file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29a183ebc5ae22c1d76240eb0f47778f/href">https://medium.com/media/29a183ebc5ae22c1d76240eb0f47778f/href</a></iframe><blockquote>測試多次後發現用stantard 的方式帶vendor目錄編譯會出現失敗…<br>因此改用docker的部署方式（Flex)<br>缺點就是deploy速度差很多..</blockquote><h3>Step.4 測試</h3><p>都完成後就可以push到git上，看看CI是否有正常deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*OvcHreb1ispqNysi04V2WQ.png" /><figcaption>Successful.</figcaption></figure><p>看到drone的綠色訊息表示成功囉！<br>至少筆者是成功了拉XD，剩下的就是各位自行去嘗試囉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e480a5077572" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drone 0.8 安裝筆記]]></title>
            <link>https://medium.com/@j75689/drone-0-8-%E5%AE%89%E8%A3%9D%E7%AD%86%E8%A8%98-2eea3def5d6e?source=rss-1c968f625fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2eea3def5d6e</guid>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[DylanHuang]]></dc:creator>
            <pubDate>Sun, 15 Apr 2018 10:13:16 GMT</pubDate>
            <atom:updated>2018-04-15T10:18:37.707Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-uHbmGuxbbRYfTkj3rv_g.png" /></figure><p><a href="https://github.com/drone/drone">Drone</a> 是基於 Dorker 容器的 CI/CD 工具，用golang寫成<br>基本上下載Docker image就可以安裝完成</p><h3><strong>安裝</strong></h3><p>基本上安裝步驟在<a href="http://docs.drone.io/installation/">官方文件</a>都有，寫好docker-compose.yml檔後 docker-compose up就可以部署完成</p><blockquote>記得先<a href="https://docs.docker.com/compose/">安裝dcker-compose工具</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*Fn_q6UPCeVmeFezxW_SVXg.png" /></figure><p>Drone有支援好幾種程式碼庫的連結使用方式都可以在官方文件中找到<br>在這邊我要連結的是我自己的gitea server docker-compose.yml 內容如下</p><blockquote>架設gitea的部分可以參考<a href="https://medium.com/@huangwen/%E4%BD%BF%E7%94%A8gitea%E6%9E%B6%E8%A8%AD%E8%87%AA%E5%B7%B1%E7%9A%84git%E4%BC%BA%E6%9C%8D%E5%99%A8-d216a5bb6694"><strong>這篇</strong></a></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06c3edf613782c58af1b17e389b8a6c5/href">https://medium.com/media/06c3edf613782c58af1b17e389b8a6c5/href</a></iframe><pre>- DRONE_GITEA=true<br>- DRONE_GITEA_URL=${your_gitea_url}</pre><p>增加這兩行在 drone server 的environment中便可以連結gitea server</p><blockquote>可以注意的是drone 在0.8版把servier 跟agent 拆成兩個部分<br>所以port會一次佔兩個 8000 port是給server的 9000 port 則是給agent</blockquote><pre>docker-compose -f docker-compose.yml up -d</pre><p>接著執行docker-compose 指令就可以啟動Drone囉～</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*Ansp1zyf9rKA2gk1AFwDFw.png" /></figure><p>看到這兩行表示啟動完成 我們在下 docker ps 確定一下是不是正常啟動</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WkoK32B5ztmI1oXFFQ7HZw.png" /></figure><p>看來大功告成～ 接著去<a href="http://localhost:10081/">http://localhost:10081</a> 就可以看到登入頁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*EyrLXndHrHLYrg1pJW4AoA.png" /></figure><p>由於gitea還沒有支援oauth2的部分，所以在這裡要用gitea 帳密做登入</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HE3z1LWIQcJxes7PJBf9GQ.png" /></figure><p>登入之後就會看到你自己的gitea帳號中有那些Repository，如果沒有的話可以把右上角的地方點開按下Synchronize就會開始同步你的gitea帳號</p><p>基本上安裝的部分就這樣完成囉～</p><h3>Caddy</h3><p>由於Drone開在10081 port上 我想要把它映射到自己的domain上<br>官方文件其實也有<a href="http://docs.drone.io/setup-with-caddy/">教學</a>可以參考</p><p>首先安裝Caddy 可以參考<a href="https://blog.caesarchi.com/2017/04/06/nginx_caddy_cloudflare/"><strong>這篇</strong></a><br>接著只要配置 Caddyfile</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb69e7fc36c6a31bf5e4aac19c1dd9d4/href">https://medium.com/media/eb69e7fc36c6a31bf5e4aac19c1dd9d4/href</a></iframe><p>然後重啟Caddy服務 service caddy restart 就完成囉</p><p>最後這邊講一下安裝Drone時遇到的一個小問題<br>因為我把gitea跟drone開在同一台機器上，所以設定gitea_url的時候設成</p><pre>- DRONE_GITEA_URL=http://127.0.0.1:10080</pre><p>結果發現Drone起來之後卻沒辦法用gitea的帳號Login，到Docker查看log發現Drone再呼叫gitea api的時候出現connection refused</p><p>最後看到 <a href="https://stackoverflow.com/questions/46619110/cant-run-drone-ci-with-my-local-gitea-server-getting-error-while-authenitcatin?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa">這篇</a> 原來這樣設定的話會變成 呼叫docker 內部的網路，所以才呼叫不到我的gitea server</p><p>因此把gitea的url位置改成外部呼叫的網址或ip，或者是把gitea 跟drone server container 建立link 再設置gitea的內部ip就可以正常運作囉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2eea3def5d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用Gitea架設自己的Git伺服器]]></title>
            <link>https://medium.com/@j75689/%E4%BD%BF%E7%94%A8gitea%E6%9E%B6%E8%A8%AD%E8%87%AA%E5%B7%B1%E7%9A%84git%E4%BC%BA%E6%9C%8D%E5%99%A8-d216a5bb6694?source=rss-1c968f625fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d216a5bb6694</guid>
            <category><![CDATA[gitea]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[DylanHuang]]></dc:creator>
            <pubDate>Sat, 14 Apr 2018 04:48:46 GMT</pubDate>
            <atom:updated>2018-04-14T05:33:50.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*MrvpNrDV-kc_NaNDLIbjLQ.png" /></figure><h3>簡介</h3><p><a href="https://gitea.io/zh-tw/">Gitea</a> 是一套<strong><em>輕量級程式碼託管</em> </strong>服務，採用Go語言寫成的因此可以可以部署到各種平台上( Windows, macOS, Linux, ARM …等)<br>主要是標榜 <strong>易安裝</strong>、<strong>跨平台</strong>、<strong>輕量級</strong>、<strong>開源化 </strong>四個特點。</p><h3>安裝</h3><p>Gitea提供多種安裝方式 docker, package, binary, source 等，本篇採用docker的安裝方式</p><p>首先必須具備docker的環境，這個部分相信Google一下都不難<br>Gitea其實都會把最新的docker image放到docker hub上<br>因此只要將他pull到docker中就可以直接啟動</p><pre>docker pull gitea/gitea:latest</pre><p>接著需要建一個gitea的資料夾掛進docker</p><pre>mkdir -p /var/lib/gitea</pre><p>然後就可以直接啟動</p><pre>docker run -d --name=gitea -p 10022:22 -p 80:3000 -v /var/lib/gitea:/data gitea/gitea:latest</pre><p>訪問 <a href="http://localhost/">http://localhost</a> ，進行初始化設定</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWujk-QX0nZouRWK8izjfQ.png" /></figure><p>設置好了之後就可以開始使用拉～</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*StA4x86hSRLDLfQDM4vDCA.png" /></figure><p>基本上該有的功能都有，剩下的就慢慢探索吧！</p><p>初始化設定的部分之後也可以在剛剛掛載的gitea資料夾 var/lib/gitea/gitea/conf/app.ini 中做設置，再重啟就可以囉～</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d216a5bb6694" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>