Skip to content

Commit

Permalink
Support Platform CLI (#54)
Browse files Browse the repository at this point in the history
Switch to the Platform CLI[1] for install/update. 

- Add `copier.yml` config file
- Move template files into `template/`
- Move Docker Compose files from project root to `{{app_name}}/`. And tag the
  app services with `{{app_name}}`. In a multi-app environment, it is
  unreasonable (and high source of conflicts on update) for a single application
  template to provide a root Compose file. So apps should provide their own
  Compose files, the the project can import them into one project-wide Compose
  file if desired.
- Drop unnecessary `.grype.yml`. Can use template-infra's project-wide version
  since we don't need any app overrides.
- Pull back a few things from `pfml-starter-kit`
- Remove old install/update scripts

[1] https://github.com/navapbc/platform-cli
  • Loading branch information
doshitan authored Jan 14, 2025
1 parent 95f5ab6 commit 62fd48e
Show file tree
Hide file tree
Showing 195 changed files with 169 additions and 425 deletions.
18 changes: 0 additions & 18 deletions .grype.yml

This file was deleted.

57 changes: 20 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,34 @@ See [`navapbc/platform`](https://github.com/navapbc/platform) for other template
## Repo structure

```text
├── .github # GitHub workflows and repo templates
├── docs # Project docs and decision records
├── app-rails # Web application
├── template-only-bin # Scripts for managing this template; not copied into your project
├── template-only-docs # Documentation for this template; not copied into your project
.
├── template # The template (the things that get installed/updated)
│ ├── .github # GitHub workflows
│ ├── docs # Project docs and decision records
│ └── {{app_name}} # Application code
└── template-only-docs # Template repo docs
```

## Installation

To get started using the template application on your project:
To get started using the template application on your project, for an
application to be called `<APP_NAME>`:

1. Run the [download and install script](./template-only-bin/download-and-install-template) in your project's root directory.

```bash
curl https://raw.githubusercontent.com/navapbc/template-application-rails/main/template-only-bin/download-and-install-template | bash -s
```

This script will:

1. Clone the template repository
2. Copy the template files into your project directory
3. Ignore any files specific to the template repository, like this README.

You can optionally pass in a branch, commit hash, or release that you want to install. For example:

```bash
curl https://raw.githubusercontent.com/navapbc/template-application-rails/main/template-only-bin/download-and-install-template | bash -s -- <commit_hash>
1. [Install the nava-platform tool](https://github.com/navapbc/platform-cli).
2. Install template by running in your project's root:
```sh
nava-platform app install --template-uri https://github.com/navapbc/template-application-rails . <APP_NAME>
```
2. [Follow the steps in `app-rails/README.md`](./app-rails/README.md) to set up the application locally.
3. Optional, if using the Platform infrastructure template: [Follow the steps in the `template-infra` README](https://github.com/navapbc/template-infra#installation) to set up the various pieces of your infrastructure.
3. Follow the steps in `<APP_NAME>/README.md` to set up the application locally.
4. Optional, if using the Platform infrastructure template: [Follow the steps in the `template-infra` README](https://github.com/navapbc/template-infra#installation) to set up the various pieces of your infrastructure.

## Updates

If you have previously installed this template and would like to update your project to use a newer version of this application:

1. Run the [update script](./template-only-bin/update-template) in your project's root directory and pass in the branch, commit hash, or release that you want to update to, followed by the name of your application directory (e.g. `app-rails`).
If you have previously installed this template and would like to update your
project to use a newer version of this template:

```bash
curl https://raw.githubusercontent.com/navapbc/template-application-rails/main/template-only-bin/update-template | bash -s -- <commit_hash> <app_name>
1. [Install the nava-platform tool](https://github.com/navapbc/platform-cli).
2. Update app template by running in your project's root:
```sh
nava-platform app update . <APP_NAME>
```
This script will:
1. Clone the template repository
2. Copy the template files into your project directory
3. Ignore any files specific to the template repository, like this README.
⚠️ Warning! This will modify existing files. Review all changes carefully after executing the script by running `git diff`.
29 changes: 29 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# App vars
#
app_name:
type: str
help: The name of the app
validator: >-
{% if not (app_name | regex_search('^[a-z0-9\-_]+$')) %}
The app name can not be empty and should only contain lower case letters, digits, dashes, and underscores.
{% endif %}
app_local_port:
type: int
help: "The port to be used in local development of '{{ app_name }}'"
default: 3000

_envops:
trim_blocks: true
lstrip_blocks: true

# ideally we could just:
#
# _answers_file: .template-application-rails/{{app_name}}.yml
#
# but alas, no:
#
# https://github.com/copier-org/copier/issues/1868

_subdirectory: template
Empty file removed docs/app-rails/decisions/README.md
Empty file.
Empty file removed template-only-bin/README.md
Empty file.
42 changes: 0 additions & 42 deletions template-only-bin/download-and-install-template

This file was deleted.

43 changes: 0 additions & 43 deletions template-only-bin/install-template

This file was deleted.

89 changes: 0 additions & 89 deletions template-only-bin/rename-template-app

This file was deleted.

75 changes: 0 additions & 75 deletions template-only-bin/update-template

This file was deleted.

Loading

0 comments on commit 62fd48e

Please sign in to comment.