*Warning Use at your own risk. paper2code uses Restricted Python to define a subset of Python that is allowed to be executed. However, there could still be potential vulnerabilities.
- Obtain Google Application Key and download to a local path
- Rename file to
p2p.json
- Export path with keys (needs to be done every shell session, consider adding to
~/.bashrc
):export GOOGLE_APPLICATION_CREDENTIALS="path/to/p2p.json"
- Build:
gcloud builds submit --tag gcr.io/[PROJECT-ID]/[IMAGE]
- Local testing:
PORT=8080 && docker run -p 8080:${PORT} \
--name my-p2p \
-e PORT=${PORT} \
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/p2p.json \
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/p2p.json:ro \
-v </path/to/src>:/app \
gcr.io/[PROJECT-ID]/[IMAGE]
- Have container up and running
- Access docker container shell:
docker exec -it my-p2p sh
- Exit app folder
cd ..
- Install package:
pipenv install <package-name>
*Note use --dev for dev packages - Copy Pipfile and Pipfile.lock to local directory:
docker cp my-p2p:/Pipfile . && docker cp my-p2p:/Pipfile.lock .
docker exec -it my-p2p pipenv run pylint app
- Add lint pre-commit hook:
cp pre-commit.sh .git/hooks/pre-commit
. Can also use a symlink here
- Ensure you are using
Dockerfile.prod
- Generate requirements.txt using pipenv (need to do this within local container):
pipenv lock -r > requirements.txt
- Deploy:
gcloud builds submit --tag gcr.io/[PROJECT-ID]/[IMAGE]
- Ensure Cloud Run service is selected to newest image.