Insights Hub Download a copy of your application hosted in Cloud Foundry instance

2024-04-30T15:13:36.000-0400
Developer Tools

Summary

Steps to help with downloading a copy of deployed application hosted Cloud Foundry instance.


Details

Guide provides step by step how to: 

  • Checking application stack version.
  • Generating manifest file.
  • Downloading application droplet.
  • Pushing application droplet.

These are useful if the original source code is no longer available to make an application update, need to update an application stack. The following example will show how to update your application stack from the deprecated Cloud Foundry stack cflinuxfs3 to cflinuxfs4 without the original source code.

As of May 1, 2024, all applications using cflinuxfs3 will stop working. 

 

Useful Cloud Foundry CLI commands:

cf login -a https://api.cf.eu1.mindsphere.io --sso
cf space-users <ORG_NAME> <SPACE_NAME>
cf target -o <ORG_NAME> -s <SPACE_NAME>
cf droplets <APP_NAME>
cf cancel-deployment <APP_NAME>
cf scale <APP_NAME> -k 1G
cf scale <APP_NAME> -m 512M
cf push <APP_NAME> --droplet <DROPLET_NAME> -s cflinuxfs4
cf restage <APP_NAME> 

 

Prerequisites:

Users familiar with Cloud Foundry, CF CLI commands, and pushing applications.

Access to your CF org and proper CF roles assigned. E.g., Space Developer.

Cloud Foundry CLI tool v7+ installed.

https://docs.cloudfoundry.org/cf-cli/install-go-cli.html#bin

https://github.com/cloudfoundry/cli/wiki/V8-CLI-Installation-Guide#installers-and-compressed-binaries

 

 

Check which Cloud Foundry stack your application is using:

  1. Sign in to the org and space of the app you want a manifest file from. E.g., cf target -o <ORG_NAME> -s <SPACE_NAME>

  2. Use command cf app <APP_NAME> and you will see similar output:
    C:\> cf app <APP_NAME>
    Showing health and status for app <APP_NAME> in org <ORG_NAME> / space <SPACE_NAME> as user@company.com...

    name:              <APP_NAME>
    requested state:   started
    routes:            appname.apps.eu1.mindsphere.io
    last uploaded:     Tue 12 Oct 09:16:25 PDT 2021
    stack:             cflinuxfs3
    buildpacks:
            name            version   detect output   buildpack name
            php_buildpack   4.4.41    php             php

    type:           web
    sidecars:
    instances:      1/1
    memory usage:   128M
         state     since                  cpu    memory          disk             details
    #0   running   2024-04-29T16:37:12Z   0.5%   28.2M of 128M   234.6M of 512M

 

Generating a manifest file from an existing application:

  1. Sign in to the org and space of the app you want a manifest file from. E.g., cf target -o <ORG_NAME> -s <SPACE_NAME>

  2. Use command cf create-app-manifest <APP_NAME> and you will see similar output:
    C:\> cf create-app-manifest <APP_NAME>
    Creating an app manifest from current settings of app <APP_NAME> in org <ORG_NAME> / space <SPACE_NAME> as user@company.com...
    Manifest file created successfully at C:\<APP_NAME>_manifest.yml
    OK
  3. The manifest file will be located in your current directory. The file name will be:
    <APP_NAME>_manifest.yml

 

 

Download application droplet:

  1. Sign in to the org and space of the app you want a manifest file from. E.g., cf target -o <ORG_NAME> -s <SPACE_NAME>

  2. Use the command: cf download-droplet <APP_NAME> and you will see similar output:
    C:\> cf download-droplet <APP_NAME>
    Downloading current droplet for app <APP_NAME> in org <ORG_NAME> / space <SPACE_NAME> as user@scompany.com...
    Droplet downloaded successfully at C:\droplet_5569e13d-3e2d-4e73-a409-ae0c0000e621.tgz
    OK
  3. The file will be in your current directory. The file name will be similar:
    droplet_5569e13d-3e2d-4e73-a409-ae0c0000e621.tgz

  4. By unzipping the .TGZ file, you will get:
    droplet_5569e13d-3e2d-4e73-a409-ae0c0000e621.tar

  5. By unzipping the .TAR file you will see several files and folders.

    The source code* should be in the app folder.
    *Depending on the original programming language, the source code may not be available. E.g., Java programs are precompiled.

 

 

Push your application droplet using cflinuxfs4:

  1. Completed previous steps above to check your application is using depreciated stack cflinuxfs3 and have downloaded a copy of the application droplet. If not, complete above steps before continuing.

  2. Use the command cf push <APP_NAME> --droplet <DROPLET_NAME> -s cflinuxfs4 and the output will be similar:
    C:\> cf push <APP_NAME> --droplet droplet_5569e13d-3e2d-4e73-a409-ae0c0000e621.tgz -s cflinuxfs4
    Pushing app <APP_NAME> to org <ORG_NAME> / space <SPACE_NAME> as user@company.com...
    Uploading droplet bits...
     89.36 MiB / 89.36 MiB [===================================================================================] 100.00% 1m16s

    Waiting for API to complete processing files...

    Waiting for app <APP_NAME> to start...

    Instances starting...
    Instances starting...

    name:              <APP_NAME>
    requested state:   started
    routes:            appname.apps.eu1.mindsphere.io
    last uploaded:     Mon 29 Apr 11:51:33 PDT 2024
    stack:             cflinuxfs4
    buildpacks:
            name            version   detect output   buildpack name
            php_buildpack   4.6.17    php             php

    type:           web
    sidecars:
    instances:      1/1
    memory usage:   32M
         state     since                  cpu    memory         disk           details
    #0   running   2024-04-29T18:52:13Z   0.6%   19.2M of 32M   482.4M of 600M
  3. You can also use the command cf app <APP_NAME> to check as well.
    Any implementation issue e.g., programing language issues, is beyond the scope of this article.

 

 

Troubleshooting:

Q: If your app fails to start after updating from cfliunxfs3 to cflinuxfs4. For example:

name:              <APP_NAME>
requested state:   started
routes:            appname.apps.eu1.mindsphere.io
last uploaded:     Mon 29 Apr 11:46:48 PDT 2024
stack:
buildpacks:

type:           web
sidecars:
instances:      0/1
memory usage:   32M
     state     since                  cpu    memory        disk           details
#0   crashed   2024-04-29T18:49:46Z   0.0%   6.9M of 32M   282.7M of 1G
Start unsuccessful

TIP: use 'cf.exe logs <APP_NAME> --recent' for more information
FAILED

A: Check the application logs with the command cf logs <APP_NAME> --recent

  • Check if enough memory or disk space is allocated. In this case you can use commands like cf scale <APP_NAME> -k 1G and cf scale <APP_NAME> -m 512M to adjust the values.
    After an adjustment, use the cf restage <APP_NAME> command to rebuild your app with the new settings.
  • Command cf droplets <APP_NAME> can show you all available droplets. You can set the current droplet with command cf set-droplet <APP_NAME> <GUID>
  • If there is an issue with the deployment and you cannot deploy a previous version, you can use the command cf cancel-deployment <APP_NAME> to cancel an existing deployment.

 

 

Advanced method to download specific application droplet based on GUID:

  1. Use the command cf app <APP_NAME> --guid
  2. The app guid will display: c501c1f3-4f81-4905-aaa9-b39759535fe1
  3. Use the command: cf curl /v2/apps/<GUID_FROM_STEP_2>/droplet/download --output myapp.tgz
  4. This will save a compressed file called myapp.tgz to your current directory.

KB Article ID# KB000130921_EN_US

Contents

SummaryDetails

Associated Components

Cloud Foundry Developer Tools - Other