-
-
Save jstockdi/e2c9ab8864d8986d1b7fe05bec578235 to your computer and use it in GitHub Desktop.
swagger-editor docker script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Starts the local dockerized swagger editor. | |
| # To start the editor, just run the script: it doesn’t take any arguments. | |
| # You can change the port it uses by editing the SE_PORT variable. You need to make it executable: | |
| # | |
| # chmod 755 swagger-editor | |
| # | |
| # then start it with | |
| # | |
| # ./swagger-editor | |
| # The first time you invoke it the image will be downloaded from the public repository on Docker and started. | |
| # | |
| # If you invoke the script and the editor is running, it will politely say so and quit. | |
| # | |
| # If you want to stop the editor, use | |
| # | |
| # docker stop swagger_editor | |
| # | |
| # Run the script again and it will start that instance for you. | |
| # | |
| # If/when you want to purge the swagger_editor from your system: | |
| # | |
| # docker stop swagger_editor | |
| # docker rm swagger_editor | |
| # docker rm swaggerapi/swagger-editor | |
| # | |
| # Change this to whatever port you want to run the editor on | |
| SE_PORT=8733 | |
| if [ -z "$(docker images -q swaggerapi/swagger-editor)" ]; then | |
| docker pull swaggerapi/swagger-editor | |
| fi | |
| if [ -n "$(docker ps -q -f name=swagger_editor)" ]; then | |
| echo "The swagger-editor is already running" | |
| exit 0 | |
| fi | |
| # we have a stopped container, so just restart it | |
| if [ -n "$(docker ps -q -a -f name=swagger_editor)" ]; then | |
| docker start swagger_editor > /dev/null | |
| echo "Swagger Editor running on http://localhost:$SE_PORT" | |
| exit 0 | |
| fi | |
| # Otherwise create a new container from the image | |
| docker run -d -p $SE_PORT:8080 --name swagger_editor swaggerapi/swagger-editor > /dev/null | |
| if [ $? -ne 0 ]; then | |
| echo "Something went wrong starting the Swagger Editor docker image" | |
| exit 1 | |
| else | |
| echo "Swagger Editor running on http://localhost:$SE_PORT" | |
| exit 0 | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment