Skip to content

Instantly share code, notes, and snippets.

@daisuke-morita
daisuke-morita / mix.ex
Created Feb 6, 2016
mix.ex - バージョン番号の自動生成と Elixir Release Manager の導入
View mix.ex
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 Feb 6, 2016
Elixirプロジェクトの設定ファイル例
View config.exs
use Mix.Config
config :example_app,
key1: "value1",
key2: "value2"
import_config "#{Mix.env}.exs"
@daisuke-morita
daisuke-morita / cloud-boothook.sh
Created Feb 6, 2016
Cloud-init経由でConformの設定ファイルを配置
View cloud-boothook.sh
#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 Feb 6, 2016
Elixirのビルド・デプロイ
View circle.yml
machine:
timezone:
Asia/Tokyo
services:
- docker
node:
version: 5.1.0
dependencies:
cache_directories:
@daisuke-morita
daisuke-morita / Dockerfile
Created Feb 6, 2016
Elixirビルド用Dockerfile
View 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 Feb 7, 2016
Elixirのテスト実行
View test.sh
#!/bin/bash
export MIX_ENV="test"
mix do deps.get, deps.compile, compile, test
@daisuke-morita
daisuke-morita / get-prev-rel.sh
Created Feb 7, 2016
get-prev-rel.sh - 直前のバージョンを取得する
View 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 Feb 7, 2016
build-release.sh - リリースパッケージをビルドする
View 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 Feb 7, 2016
deploy-to-staging.sh - リリースパッケージをアプリケーションサーバーにホットデプロイする
View 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 Feb 7, 2016
デプロイ用の IAM User
View deploy-policies.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::example-app-packages/*"
]