-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from upmaru/insterra/packs/14/1708403952
Deployment configuration base-elixir-phoenix for polar
- Loading branch information
Showing
3 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: 'Deployment' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
- develop | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Setup Pakman | ||
uses: upmaru/pakman@v8 | ||
with: | ||
alpine: v3.19 | ||
|
||
- name: Bootstrap Configuration | ||
run: | | ||
pakman bootstrap | ||
shell: alpine.sh {0} | ||
env: | ||
ABUILD_PRIVATE_KEY: ${{secrets.ABUILD_PRIVATE_KEY}} | ||
ABUILD_PUBLIC_KEY: ${{secrets.ABUILD_PUBLIC_KEY}} | ||
|
||
- name: 'Build Package' | ||
run: | | ||
cd "$GITHUB_WORKSPACE"/.apk/"$GITHUB_REPOSITORY" || exit | ||
abuild snapshot | ||
abuild -r | ||
shell: alpine.sh {0} | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ runner.arch }} | ||
path: /home/runner/packages | ||
|
||
deploy: | ||
name: Deploy | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
path: /home/runner/artifacts | ||
|
||
- name: Setup Pakman | ||
uses: upmaru/pakman@v8 | ||
with: | ||
alpine: v3.19 | ||
|
||
- name: Merge Artifact | ||
run: | | ||
cp -R /home/runner/artifacts/X64/. /home/runner/packages/ | ||
sudo zip -r /home/runner/packages.zip "$HOME"/packages | ||
shell: alpine.sh {0} | ||
|
||
- name: Push | ||
run: pakman push | ||
shell: alpine.sh {0} | ||
env: | ||
WORKFLOW_REF: ${{ github.ref }} | ||
WORKFLOW_SHA: ${{ github.sha }} | ||
INSTELLAR_ENDPOINT: https://opsmaru.com | ||
INSTELLAR_PACKAGE_TOKEN: ${{secrets.INSTELLAR_PACKAGE_TOKEN}} | ||
INSTELLAR_AUTH_TOKEN: ${{secrets.INSTELLAR_AUTH_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
dependencies: | ||
build: | ||
- elixir | ||
- npm | ||
runtime: | ||
- bash | ||
- curl | ||
- s6 | ||
- jq | ||
- ca-certificates | ||
- polar-openrc | ||
trace: true | ||
|
||
stack: alpine/3.19 | ||
|
||
build: | ||
command: | | ||
export MIX_ENV=prod | ||
mix local.hex --force | ||
mix local.rebar --force | ||
mix do deps.get --only prod | ||
# npm --prefix ./assets install ./assets | ||
# Comment out mix assets.deploy for non phoenix apps | ||
mix assets.deploy | ||
mix release | ||
destination: | ||
- _build/prod/rel/polar/* | ||
|
||
run: | ||
commands: | ||
- binary: polar | ||
call: eval 'Polar.Release.migrate' | ||
name: migrate | ||
- binary: polar | ||
call: remote | ||
name: console | ||
- binary: tail | ||
call: -f -n 100 /var/log/polar/current | ||
name: logs | ||
path: /usr/bin | ||
name: polar | ||
services: | ||
- binary: polar | ||
name: web | ||
start: | ||
call: start | ||
|
||
hook: | ||
post-deinstall: | | ||
rc-service polar stop | ||
rc-update del polar | ||
post-install: | | ||
rc-update add polar | ||
rc-service polar migrate | ||
post-upgrade: | | ||
rc-service polar migrate | ||
rc-service polar start | ||
pre-upgrade: | | ||
rc-service polar stop | ||
kits: | ||
- description: Web service | ||
main: true | ||
name: web | ||
ports: | ||
- main: true | ||
name: web | ||
target: 4000 | ||
variables: | ||
- default_value: 'true' | ||
key: PHX_SERVER | ||
- driver: generic/secret | ||
driver_options: | ||
length: 128 | ||
key: SECRET_KEY_BASE | ||
- default_value: ecto:/// | ||
driver: database/postgresql | ||
key: DATABASE | ||
- driver: bucket/aws-s3 | ||
key: AWS_S3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule Polar.Release do | ||
@app :polar | ||
|
||
def migrate do | ||
load_app() | ||
|
||
for repo <- repos() do | ||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) | ||
end | ||
end | ||
|
||
def rollback(repo, version) do | ||
load_app() | ||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version)) | ||
end | ||
|
||
defp repos do | ||
Application.fetch_env!(@app, :ecto_repos) | ||
end | ||
|
||
defp load_app do | ||
Application.load(@app) | ||
end | ||
end |