GoogleCloudPlatform / appengine-plugins

A client Java library to manage App Engine Java applications for any project that performs App Engine Java application management. For example, the Maven, Gradle and Eclipse App Engine plugins, custom user tools, etc.
Apache License 2.0
36 stars 25 forks source link

how to choose the environment in app engine gradle plugin ? #996

Open pradeepsimba opened 8 months ago

pradeepsimba commented 8 months ago

I am using this plugin apply plugin: 'com.google.cloud.tools.appengine'.

I want to deploy my spring boot app on app engine's standard envronment. But , I have some doubts.

where do I represent the environment name ?

This is my project : https://github.com/Jeevasimba/appengine_example

my gradle file : https://github.com/Jeevasimba/appengine_example/blob/main/build.gradle

my YAML file : https://github.com/Jeevasimba/appengine_example/blob/main/src/main/appengine/app.yaml

what is difference between appengineDeploy and appengineDeployAll ?

image

I am new to gcloud app engine's standard environment .

### I referred online to deploy in standard env.

step 1: enable 'App engine Api'

step 2: INSTALL this sdk in projects terminal.

# Install the gcloud CLI
gcloud components install app-engine-java cloud-sdk

step 3: choosing server location

    # Create a new App Engine standard environment app
    gcloud app create

step 4: deploying

gradle appengineDeploy       

my doubt is where do I mention the environment's name as standard ?

This is my project : https://github.com/Jeevasimba/appengine_example. are there any mistake I have done in my project ?

is there any sample project with spring boot with gradle build for app engine's standard environment in github ?

help me to solve this problem !!!

chanseokoh commented 8 months ago

You already specified the standard env in src/main/appengine/app.yaml.

runtime: java11
env: standard
instance_class: B8

But the current App Engine standard env doc doesn't mention the env element, so I'm guessing it defaults to standard when it's missing. OTOH, the flexible doc does say env: flexible is required.

env: flex Required: Select the flexible environment.


appengineDeployAll runs all the deploy tasks: appengineDeployCron, appengineDeployDispatch, appengineDeployDos, appengineDeployIndex, appengineDeployQueue, and most importantly, appengineDeploy. That is, it deploys all the YAML config files together with the app.

pradeepsimba commented 8 months ago

gradle.build

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.5'
        }
    }

    plugins {
        id 'java'
        id 'org.springframework.boot' version '2.5.4'
        id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    }

    apply plugin: 'com.google.cloud.tools.appengine'

    repositories {
        mavenCentral()
        maven { url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" }
        flatDir {
            dirs 'lib'
        }
        google()
    }

    dependencies {
        testImplementation platform('org.junit:junit-bom:5.9.1')
        testImplementation 'org.junit.jupiter:junit-jupiter'

        implementation 'com.google.firebase:firebase-database:20.0.1'
        implementation 'com.google.firebase:firebase-admin:9.0.0'
        // https://mvnrepository.com/artifact/org.json/json
        implementation group: 'org.json', name: 'json', version: '20230618'

        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation 'org.springframework.boot:spring-boot-starter'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
    }

    test {
        useJUnitPlatform()
    }

    appengine {
        deploy {
            stopPreviousVersion = true
        }
    }

below code is a common way to configure an App Engine app to stop the previous version when the new version is deployed using the gcloud command-line tool.

appengine {
    deploy {
        stopPreviousVersion = true
    }
}

If I push new code to github it will automatically deploy it on gcloud and stop the previous version app.

How do I do this with this plugin ?

stjasink commented 6 months ago

How do I do this with this plugin ?

appengine {
    deploy {
        stopPreviousVersion = true
    }
}
diegomarquezp commented 1 week ago

Hi @pradeepsimba, did @stjasink and @chanseokoh suggestion work for you?