Skip to content

Instantly share code, notes, and snippets.

@yjuba
Created January 8, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjuba/b41164be90e8c879d0d4fedcfb30ab5a to your computer and use it in GitHub Desktop.
Save yjuba/b41164be90e8c879d0d4fedcfb30ab5a to your computer and use it in GitHub Desktop.
必要に応じて毎度書いているが、毎度手順を忘れるので、雛形代わりにリポジトリとして上げておく

自前のアプリケーションをdebパッケージにする

主旨

自前のアプリケーションを配布する際に、手元からscpしてconfigファイルを配置してというのを避けたいのが一番の理由。
Chef/Ansibleでやる手も無くはないが、そこまで大げさにしたくないというのもある。

参考にした記事でも、以下の様に書かれており、心底同意。

tar.gz を心を込めて scp するような運用から卒業して、スマートに apt-get install する世界を目指していきましょう!!

サンプル

https://github.com/yjuba/golang-package-sample

適当に書いたHello Worldとだけ返してくるHTTPサーバをパッケージング。
最近はサーバはsystemdで管理していることが多いので、systemdの設定ファイルも一緒に配るようになっている。

make depでdebパッケージが生成される。

殆ど中身はscripts/build_deb.shに書かれている。
作業用の一時ディレクトリを作成、必要なディレクトリを切ってファイルを配置、最後にfakeroot dpkg-deb --buildして完成の流れ。


本当はrpmもやりたかったけど、手元に無かったので一旦無し。
気が向いたらrpmも作成可能にする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment