Set up a 12-Factor app rock¶
The following how-to guide provides instructions on initializing and configuring rocks for 12-factor apps.
Initialize a 12-factor app rock¶
Use rockcraft init and specify the relevant profile:
rockcraft init --profile <profile>
Rockcraft automatically creates a rockcraft.yaml project file
for the rock in your current directory. You will need to check the project
file to verify that the rock’s name and description are correct.
rockcraft init --profile django-framework
rockcraft init --profile expressjs-framework
rockcraft init --profile fastapi-framework
rockcraft init --profile flask-framework
rockcraft init --profile go-framework
For more information, see: init
Include extra files in the OCI image¶
The following files are included in the image by default from the root of the project:
app(does not apply to thego-framework)app.py(does not apply to thego-framework)migratemigrate.shmigrate.py(does not apply to thego-framework)statictemplates
To change this list, add the following snippet to the project file:
parts:
flask-framework/install-app:
prime:
- flask/app/.env
- flask/app/app.py
- flask/app/webapp
- flask/app/templates
- flask/app/static
Note the flask/app/ prefix that is required followed by the relative path to
the project root.
N/A
parts:
fastapi-framework/install-app:
prime:
- app/.env
- app/app.py
- app/webapp
- app/templates
- app/static
Note the app/ prefix that is required followed by the relative path to
the project root.
parts:
go-framework/assets:
prime:
- app/templates
- app/static
- app/migrate.sh
Note the app/ prefix that is required followed by the relative path to
the project root.
Include additional debs in the OCI image¶
If your app requires debs – for example, to connect to a database – add the following snippet to the project file:
parts:
flask-framework/dependencies:
stage-packages:
# list required packages or slices for your flask application below.
- libpq-dev
parts:
django-framework/dependencies:
stage-packages:
# list required packages or slices for your Django application below.
- libpq-dev
parts:
fastapi-framework/dependencies:
stage-packages:
# list required packages or slices for your FastAPI application below.
- libpq-dev
parts:
runtime-debs:
plugin: nil
stage-packages:
- postgresql-client
For the go-framework extension, a deb could be needed for example to use an external command in the migration process.