I want to download the source code in my Python 3 App Engine flexible environment. I see how you can SSH in, or go in from the terminal, to look at source code. But I don't want to turn debug on a production machine. Instead, is it possible to just list the files, and then download to my machine?
The app was uploaded using Docker, pushed to gcr.io, and deployed with gcloud app deploy
.
I managed to copy the source code from the App Engine Flex environment by following these steps:
Fetch the App Engine image to be used by performing either the following:
appengine
gcloud container images list --repository [region]/[project-name]/appengine
in Cloud ShellSupported regions:
gcr.io
us.gcr.io
eu.gcr.io
asia.gcr.io
Create a container using Docker:
docker create --name=gae-source [region]/[project-name]/appengine/[service].[version]:[tag]
It would be easier to copy the full repository name then add the tags
afterwards by clicking the copy button beside the repository name or
service.version
.
Copy the files from the docker container:
docker cp gae-source:/app . --follow-link
Check if the files are successfully copied:
ls ./app
Compress the files by performing:
tar -czvf app.tar.gz ./[folder]
You may now download the compressed file on your local machine.
I managed to view the source code by using the Cloud Shell Editor. I didn't have to download the files.
You can check this Github link that I followed.