github.com/googleapis/api-linter@v1.65.2/docs/serve.sh (about) 1 #!/bin/bash 2 # Copyright 2019 Google LLC 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # https://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 # ----------------------------------------------------------------------------- 17 # This script runs a "development server" from Docker. 18 # ----------------------------------------------------------------------------- 19 20 # Build the image (if and only if it is not already built). 21 if [[ "$(docker images -q googleapis-site 2> /dev/null)" == "" ]]; then 22 docker build -t googleapis-site . 23 if [ $? != 0 ]; then 24 exit $? 25 fi 26 fi 27 28 # Unless we are in incremental mode, the source filesystem should 29 # be read-only. Incremental mode sadly requires writing a file to the 30 # source directory. 31 READ_ONLY=',readonly' 32 if [[ $* == *--incremental* ]]; then 33 READ_ONLY='' 34 fi 35 36 # Run the image. 37 docker run --rm \ 38 -p 4000:4000/tcp -p 4000:4000/udp \ 39 -p 35729:35729/tcp -p 35729:35729/udp \ 40 --mount type=bind,source=`pwd`,destination=/code/${READ_ONLY} \ 41 googleapis-site \ 42 "$@"