This module for the Backstage scaffolder includes an action to create a new Phoenix project using the mix phx_new
command.
The environment needs to have Docker installed, since the scaffolding of the Phoenix project is run inside an elixir-alpine Docker container.
From your Backstage root directory:
cd packages/backend
yarn add git+https://github.com/fabuloso/scaffolder-backend-module-phoenix
Configure the action in packages/backend/src/plugins/scaffolder.ts
file (you can check the docs to see all options):
import { createPhoenixProjectAction } from 'scaffolder-backend-module-phoenix';
...
const actions = [
...,
createPhoenixProjectAction(containerRunner)
];
return await createRouter({
containerRunner,
logger,
config,
database,
catalogClient,
reader,
actions,
});
After that you can use the action elixir:create-phoenix-project
as a step in your template:
steps:
- id: create-project
name: A new Phoenix App
action: elixir:create-phoenix-project
input:
projectName: ${{parameters.name}}
generatorOptions:
baseModule: ${{parameters.baseModule}}
dashboard: ${{parameters.dashboard}}
database: ${{parameters.database}}
ecto: ${{parameters.ecto}}
gettext: ${{parameters.gettext}}
html: ${{parameters.html}}
live: ${{parameters.live}}
mailer: ${{parameters.mailer}}
umbrella: ${{parameters.umbrella}}
You can specify the following parameters for the elixir:create-phoenix-project
action:
projectName
: name of the projectgeneratorOptions
: options passed to the Phoenix generator for the project scaffoldingbaseModule
: the name of the base module in the generated skeletondashboard
: if false, do not include Phoenix.LiveDashboarddatabase
: the database adapter for ectoecto
: generate ecto filesgettext
: if false, do not generate text fileshtml
: generate HTML fileslive
: if false, comment out LiveView socket setup in assets/js/app.js and also on the endpoint (the latter also requiresdashboard
as false)mailer
: if false, do not generate any swoosh mailer fileumbrella
: generate an umbrella project, with one application for your domain, and a second application for the web interface