golang.org/x/playground@v0.0.0-20230418134305-14ebe15bcd59/sandbox/Makefile (about)

     1  ZONE := us-central1-f
     2  TEST_VM := gvisor-cos-test-vm
     3  PROJ := golang-org
     4  NETWORK := golang
     5  
     6  # Docker environment for the sandbox server itself (containing docker CLI, etc), running
     7  # in a privileged container.
     8  docker:
     9  	docker build -f Dockerfile --tag=golang/playground-sandbox ..
    10  	docker tag golang/playground-sandbox gcr.io/$(PROJ)/playground-sandbox:latest
    11  
    12  # dockergvisor builds the golang/playground-sandbox-gvisor docker
    13  # image, which is the environment that the untrusted programs run in
    14  # (a busybox:glibc world with this directory's sandbox binary which
    15  # runs in --mode=contained)
    16  dockergvisor:
    17  	docker build -f Dockerfile.gvisor --tag=golang/playground-sandbox-gvisor ..
    18  	docker tag golang/playground-sandbox-gvisor gcr.io/$(PROJ)/playground-sandbox-gvisor:latest
    19  
    20  push: docker dockergvisor
    21  	docker push gcr.io/$(PROJ)/playground-sandbox:latest
    22  	docker push gcr.io/$(PROJ)/playground-sandbox-gvisor:latest
    23  
    24  # runlocal runs the sandbox server locally, for use with the frontend
    25  # parent directory's "test_nacl" or "test_gvisor" test targets.
    26  runlocal: docker dockergvisor
    27  	docker network create sandnet || true
    28  	docker kill sandbox_dev || true
    29  	docker run --name=sandbox_dev --rm --network=sandnet -ti -p 127.0.0.1:8080:80/tcp -v /var/run/docker.sock:/var/run/docker.sock golang/playground-sandbox:latest --dev
    30  
    31  konlet.yaml.expanded: konlet.yaml
    32  	sed "s/PROJECT_NAME/$(PROJ)/" konlet.yaml > konlet.yaml.expanded
    33  
    34  # create_test_vm creates a test VM for interactive debugging.
    35  create_test_vm: konlet.yaml.expanded
    36  	gcloud --project=$(PROJ) compute instances create $(TEST_VM) \
    37  	--zone $(ZONE) \
    38  	--network $(NETWORK) \
    39  	--no-address \
    40  	--image-project cos-cloud \
    41  	--image cos-stable-76-12239-60-0 \
    42  	--metadata-from-file gce-container-declaration=konlet.yaml.expanded,user-data=cloud-init.yaml
    43  
    44  # delete_test_vm deletes the test VM from create_test_vm.
    45  delete_test_vm:
    46  	gcloud --project=$(PROJ) compute instances delete $(TEST_VM) --quiet --zone $(ZONE)
    47  
    48  # ssh connects to the create_test_vm VM. It must be run from the same network.
    49  ssh:
    50  	gcloud --project=$(PROJ) compute ssh $(TEST_VM) --internal-ip --zone $(ZONE)
    51  
    52