Skip to content

Instantly share code, notes, and snippets.

View daisuke-morita's full-sized avatar

Daisuke Morita daisuke-morita

View GitHub Profile
@daisuke-morita
daisuke-morita / mix.ex
Created February 6, 2016 08:22
mix.ex - バージョン番号の自動生成と Elixir Release Manager の導入
defmodule ExampleApp.Mixfile do
use Mix.Project
def project do
[
app: :example_app,
version: version(),
elixir: "~> 1.2.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
@daisuke-morita
daisuke-morita / config.exs
Created February 6, 2016 13:15
Elixirプロジェクトの設定ファイル例
use Mix.Config
config :example_app,
key1: "value1",
key2: "value2"
import_config "#{Mix.env}.exs"
@daisuke-morita
daisuke-morita / cloud-boothook.sh
Created February 6, 2016 14:06
Cloud-init経由でConformの設定ファイルを配置
#cloud-boothook
#!/bin/sh
# Application config
cat <<EOF > /opt/example_app/app.conf
logger.level = info
Endpoint.url.host = "example.com"
Endpoint.url.port = 443
@daisuke-morita
daisuke-morita / circle.yml
Created February 6, 2016 16:38
Elixirのビルド・デプロイ
machine:
timezone:
Asia/Tokyo
services:
- docker
node:
version: 5.1.0
dependencies:
cache_directories:
@daisuke-morita
daisuke-morita / Dockerfile
Created February 6, 2016 16:50
Elixirビルド用Dockerfile
FROM ubuntu:trusty
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -q
RUN apt-get -y install language-pack-ja openssl libssl-dev ncurses-dev curl git
RUN update-locale LANG=ja_JP.UTF-8
# SSH
RUN mkdir -p /root/.ssh
@daisuke-morita
daisuke-morita / test.sh
Created February 7, 2016 02:11
Elixirのテスト実行
#!/bin/bash
export MIX_ENV="test"
mix do deps.get, deps.compile, compile, test
@daisuke-morita
daisuke-morita / get-prev-rel.sh
Created February 7, 2016 02:48
get-prev-rel.sh - 直前のバージョンを取得する
#!/bin/bash
export APP="example_app"
aws s3 cp s3://example-app-packages/latest.tar.gz /tmp/${APP}.tar.gz
mkdir -p rel/${APP} && rm -rf rel/${APP}/*
tar zxvf /tmp/${APP}.tar.gz -C rel/${APP}
@daisuke-morita
daisuke-morita / build-release.sh
Created February 7, 2016 03:07
build-release.sh - リリースパッケージをビルドする
#!/bin/bash
set -ex
mix do deps.get, deps.compile, compile
node -v
npm install
export MIX_ENV="prod"
@daisuke-morita
daisuke-morita / deploy-to-staging.sh
Created February 7, 2016 03:56
deploy-to-staging.sh - リリースパッケージをアプリケーションサーバーにホットデプロイする
#!/bin/bash
set -ex
export AWS_DEFAULT_REGION="ap-northeast-1"
SGID="sg-xxxxxxxx"
MYIP="`dig +short myip.opendns.com @resolver1.opendns.com`"
cd $(dirname $(readlink -f $0))
@daisuke-morita
daisuke-morita / deploy-policies.json
Created February 7, 2016 04:12
デプロイ用の IAM User
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::example-app-packages/*"
]