Skip to content

grails/grails-forge

Repository files navigation

Grails Application Forge

Maven Central Build Status Revved up by Gradle Enterprise

Generates Grails applications.

Installation

The CLI application comes in various flavours from a universal Java applications to native applications for Windows, Linux and OS X. These are available for direct download on the releases page. For installation see the Grails documentation.

If you prefer not to install an application to create Grails applications you can do so with curl directly from the API:

$ curl 'https://grailsforge-latest-cjmq3uyfcq-uc.a.run.app/demo.zip' -o demo.zip
$ unzip demo.zip -d demo
$ cd demo
$ ./gradlew run

Run curl https://grailsforge-latest-cjmq3uyfcq-uc.a.run.app/ for more information on how to use the API or see the API documentation referenced below.

UI

If you prefer a browser based user interface you can visit Grails Forge.

The user interface is written in React and is a static single page application that simply interacts with the https://start.grails.org API.

API

API documentation for the production instance can be found at:

API documentation for the snapshot /development instance can be found at:

Documentation

See the Snapshot Documentation for the current development docs.

Snapshots and Releases

Snapshots are automatically published to Sonatype OSSRH using Github Actions.

Releases are published to Maven Central via Github Actions.

A release is performed with the following steps:

Architecture

Grails Forge Architecture

Distribution to Google Cloud Run via GitHub Actions

Cloud Run

To make your life easier, export these environment variables so that you can copy and paste the commands used here. Choose whatever name you want, but the $PROJECT_ID has to be a unique name, because project IDs can't be reused in Google Cloud.

export PROJECT_ID=
export ACCOUNT_NAME=

For example, your commands should look something like this:

export PROJECT_ID=grailsforge
export ACCOUNT_NAME=grailsforge

Log in with your Google account:

gcloud auth login
gcloud projects create $PROJECT_ID
gcloud config set project $PROJECT_ID

Enable billing for your project, and create a billing profile if you don’t have one:

open "https://console.cloud.google.com/billing/linkedaccount?project=$PROJECT_ID"

Enable the necessary services:

gcloud services enable cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com

Create a service account:

gcloud iam service-accounts create $ACCOUNT_NAME \
--description="Cloud Run deploy account" \
--display-name="Cloud-Run-Deploy"
Give the service account Cloud Run Admin, Storage Admin, and Service Account User roles. You can’t set all of them at once, so you have to run separate commands:


gcloud projects add-iam-policy-binding $PROJECT_ID \
--member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \
--role=roles/run.admin

gcloud projects add-iam-policy-binding $PROJECT_ID \
--member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \
--role=roles/storage.admin

gcloud projects add-iam-policy-binding $PROJECT_ID \
--member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \
--role=roles/iam.serviceAccountUser

gcloud projects add-iam-policy-binding $PROJECT_ID \
--member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \
--role=roles/artifactregistry.writer

Generate a key.json file with your credentials, so your GitHub workflow can authenticate with Google Cloud:

gcloud iam service-accounts keys create key.json \
--iam-account $ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com

GitHub Actions

GitHub, you need to set up a secrets environment in your repository, with the following values:

  • GCP_PROJECT_ID is your $PROJECT_ID.
  • GCP_APP_NAME is your app name.
  • GCP_EMAIL is the email from the service account you created, which should look like this: $ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com
  • GCP_CREDENTIALS is the content from the key.json file that you just created.

For example, your settings should look something like this:

GCP_PROJECT_ID = grailsforge
GCP_APP_NAME = grailsforge
GCP_EMAIL = account-name@project-example.iam.gserviceaccount.com

Cat the key.json content and paste it into the GCP_CREDENTIALS secret value.

Now you just need to create a YAML file telling which commands your workflow should run. In your project directory, create a folder called .github and create another one inside it called workflows.

See the workflows in this project for examples.

Cloud SQL Setup

Cloud SQL Admin API Enable Screenshot

Cloud SQL Instance

Create an instance of Cloud SQL:

Choose PostgreSQL as your database engine:

Enable Compute Engine API

Configure it with the following options:

Databases

Create two databases grailsforge-production and grailsforge-snapshot

Cloud SQL Databases Screenshot

Cloud Run environment variables

Latest Env

Cloud Run grailsforge-latest

Name Value
MICRONAUT_ENV_DEDUCTION false
MICRONAUT_ENVIRONMENTS gcp
MICRONAUT_HTTP_SERVICES_ANALYTICS_READ_TIMEOUT 20s
MICRONAUT_HTTP_SERVICES_ANALYTICS_URL URL of cloud run grailsforge-analytics-latest
GITHUB_OAUTH_APP_CLIENT_ID The Client ID shared after creating GitHub OAuth App
GITHUB_OAUTH_APP_CLIENT_SECRET The Client secret shared after creating the GitHub OAuth app
GITHUB_USER_AGENT URL of the grails-forge-ui static website. For example, https://start.grails.org/. The default value is https://start.grails.org/.
GITHUB_REDIRECT_URL URL of the grails-forge-ui static website. For example, https://start.grails.org/. The default value is https://start.grails.org/.

Cloud Run grailsforge-analytics-latest

Name Value
CLOUD_SQL_CONNECTION_NAME grailsforge:us-central1:grailsforge-postgresdb
DB_NAME grailsforge-production
MICRONAUT_ENV_DEDUCTION false
MICRONAUT_ENVIRONMENTS gcp
DATASOURCES_DEFAULT_USERNAME ***
DATASOURCES_DEFAULT_PASSWORD ***
DATASOURCES_DEFAULT_URL jdbc:postgresql:///grailsforge-production

Snapshot Env

Cloud Run grailsforge-snapshot

Name Value
MICRONAUT_ENV_DEDUCTION false
MICRONAUT_ENVIRONMENTS gcp
MICRONAUT_HTTP_SERVICES_ANALYTICS_READ_TIMEOUT 20s
MICRONAUT_HTTP_SERVICES_ANALYTICS_URL URL of cloud run grailsforge-analytics-snapshot
GITHUB_OAUTH_APP_CLIENT_ID The Client ID shared after creating GitHub OAuth App
GITHUB_OAUTH_APP_CLIENT_SECRET The Client secret shared after creating the GitHub OAuth app
GITHUB_USER_AGENT URL of the grails-forge-ui static website. For example, https://start.grails.org/. The default value is https://grails.github.io/grails-forge-ui/.
GITHUB_REDIRECT_URL URL of the grails-forge-ui static website. For example, https://start.grails.org/. The default value is https://grails.github.io/grails-forge-ui/.

Cloud Run grailsforge-analytics-latest

Name Value
CLOUD_SQL_CONNECTION_NAME grailsforge:us-central1:grailsforge-postgresdb
DB_NAME grailsforge-snapshot
MICRONAUT_ENV_DEDUCTION false
MICRONAUT_ENVIRONMENTS gcp
DATASOURCES_DEFAULT_USERNAME ***
DATASOURCES_DEFAULT_PASSWORD ***
DATASOURCES_DEFAULT_URL jdbc:postgresql:///grailsforge-snapshot

About

This is Grails project creator. Grails projects may be created using the browser interface, Command Line, or via CURL.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published