Gigalixrの登録
頑張って登録する。
GithubActionの準備
Githubのmasterリポジトリに登録したら、自動的にGigalixrにデプロイするよう設定する。
専用のプラグイン?が開発されているので、ありがたく使わせてもらう。
https://github.com/mhanberg/gigalixir-action
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
if: github.ref == 'refs/heads/master' # Only run this job if it is on the master branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: master # Checkout out master instead of the latest commit
fetch-depth: 0 # Checkout the whole branch
- uses: mhanberg/gigalixir-action@v0.3.0
with:
GIGALIXIR_USERNAME: ${{ secrets.GIGALIXIR_USERNAME }}
GIGALIXIR_PASSWORD: ${{ secrets.GIGALIXIR_PASSWORD }}
GIGALIXIR_APP: my-gigalixir-app # Feel free to also put this in your secrets
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
MIGRATIONS: false # defaults to true
環境変数の登録は、リポジトリのSettings->Secretsから行う。
go-transproxyの準備
(プロキシ環境下での作業を強いられている場合)
頑張って準備する。
サンプルの実行
ElixirとPhoenixとPostgresSQL入りのコンテナを作ったので、プルして、
docker pull bleach31/phoenix:1.5.5
docker run -p 4000:4000 -it bleach31/phoenix:1.5.5
PostgresSQLのサービス起動が必要なので、いろいろとオプションをつけて起動する。
docker run -p 4000:4000 --privileged -d bleach31/phoenix:1.5.5 /sbin/init
docker exec -it {コンテナ名} /bin/bash
systemctl start postgresql
cd /home/
新しくプロジェクトを作る場合。
mix phx.new hello
続きの場合はGit cloneなりをして、
cd hello/
mix deps.get
mix ecto.create
cd assets/
npm install
mix phx.server
localhost:4000でアクセス!
さらに、githubのmatsterブランチにpushすれば自動的にgigalixirにデプロイされて、外部公開されます。