├── .dockerignore ├── .gitignore ├── .gitmodules ├── .travis.yml ├── Dockerfile ├── LICENSE ├── README-zh.md ├── README.md ├── config ├── ide.sh └── mvn_settings.xml /.dockerignore: -------------------------------------------------------------------------------- 1 | */.idea/ 2 | */*.iml 3 | *.orig 4 | frontend/ 5 | frontend-webjars/ 6 | backend/ 7 | *.env 8 | **/*.db 9 | */*.ipr 10 | */*.iws 11 | .DS_Store 12 | */.git/ 13 | !backend/target/ide-backend.jar 14 | !backend/src/main/resources/lib 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules/ 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "backend"] 2 | path = backend 3 | url = ../WebIDE-Backend.git 4 | [submodule "frontend"] 5 | path = frontend 6 | url = ../WebIDE-Frontend.git 7 | [submodule "frontend-webjars"] 8 | path = frontend-webjars 9 | url = ../WebIDE-Frontend-Webjars.git 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | language: java 3 | jdk: 4 | - oraclejdk8 5 | 6 | service: 7 | - docker 8 | 9 | cache: 10 | directories: 11 | - $HOME/.m2 12 | - $HOME/docker 13 | - $HOME/.yarn-cache 14 | - frontend/node_modules 15 | 16 | env: 17 | global: 18 | - secure: NtkK4A4aYmudQue+KzS/PRyO2+5YkKp9x0r0AFRpZB6F9v+4cX+aWynX1reVQ1By9NmB/F3W9t+hujS2Dm7pIwlzj4oDRzdSda/aakOF6fiJvy41xaa4fGNEDdrvrtzfFHoFCuG7lg8mO5hVAIlwXeLR+XjDQXj6XklgHcjxF5WCEzElN9ZcA8K3b7tU1pxyaGeKTN3Qu+L1xVNkFnfi7sCiLIkXG8LV/0O8al/qow5SAm3gBAIqplSN7o2AKur331IsZD6PfTqPTZJbQMYFkcRZisZ+8J/H+xCHTk/Bf56BpMuJYLr0ScZURznmX5Hhh+JSx4kZnQbgs6F26/c1k1vWy9G1ZMRdepBZm+UG3yobbAKH/Nu4tt47UjBdbkedvRJbLUQQCo/StUE0kqRFa9ykQYltGYPm879NRyZbryEK5LHkwW0CNSZFU1zlToo8q7IH47cZz+kJTDFkYoP/0wOVf9sSCV07tWTnegI7P6YR5s+q7n7XYhVUOcS+x0PERYajIybgU0bJ0r2hQc8kg05YlVOH88wR3BGegKnv0J2kw2IKpENIG6FNRmhIeXi27dTIAfcC4w+1XsqBBQZr6f/HKHgLvMi+Y6lrXV/hGJL1CkiEtkuuUyDF8zC68jfqhvunXAuIZD6FnRkHJBVnKqbcqMYD0BxLae4ic5sRXfI= 19 | - secure: HZipPIhxoHUMxO+EsCImjcbaJNsbXTo4NpmBzGm5uv2RdQRTyauePpwNfcFnpZNrCz0e6BfSAxzEZ6HZ+hIViPZUCWBrB3us7XOSd9U9S40a6E4LnfMMfX53awC7BFAoiU5eIrcOAgSppIic0ZaOHdM0BbIFJeU3mUsApHQ9s4fj8pRp38e9PYfAQ7K0zreU5rnEV/cWJhF2G1Qx7jkeiA99tf4ndjNP9L8Olcs/jaN1nxggR7QuT8hTfNJNIVeYBirhudu/5K2TblydBh7CKcmv77N5H6um07SP32oXAOoUESpfEntKS/FgUAMcckYYX1SIsYzMuqZbN60kgmPocppsDp2NARsKn4/EEV1aZe0Dm8udOXipxVaXBCnKXS5mm+zlmmgRY//DCoH8Jk8ULOhqc6Yevj3IMUK4KIL46q4tfaB9ktVVa+a3b/Ljqs0dgsAKC11tx+rUWHjUCX30ixH035H40xOzRw+5DVVyy2KtppNnwKWx+3xBRrwx1zwWBb2p9UsXZ1hEo3c/cCpseuHvbbXYVOoOXRxA2ZtJf5MnjU9Y5K20gBM4qFJ/E2xYJ5LiE5HOLluNECyF6lzIWZeVMp1qic98C662+Hpyj9HnHnDGdwkHyuBBWlsQxyKTiQt9S6HfG0WDQFvS1PF3/9dW4yO8bkrXBTeuBWy9638= 20 | - COMMIT=${TRAVIS_COMMIT::8} 21 | - DOCKER_CACHE_FILE=${HOME}/docker/cache.tar.gz 22 | - REPO=webide/webide 23 | - NODE_ENV=prod 24 | 25 | before_install: 26 | - sudo apt-get update 27 | - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce 28 | - nvm install 7 29 | - nvm use 7 30 | - if [ -f ${DOCKER_CACHE_FILE} ]; then gunzip -c ${DOCKER_CACHE_FILE} | docker load; fi 31 | 32 | install: true 33 | 34 | script: 35 | - set -e 36 | - cd frontend && yarn && yarn run build 37 | - cd ../frontend-webjars && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 38 | - cd ../backend && mvn package -DskipTests=true -Dmaven.javadoc.skip=true -B -V 39 | - cd .. && docker build -f Dockerfile -t $REPO:$COMMIT . 40 | - if [ -n "$TRAVIS_TAG" ]; then docker tag $REPO:$COMMIT $REPO:$TRAVIS_TAG ; docker tag $REPO:$COMMIT $REPO:latest ; docker login -u $DOCKER_USER -p $DOCKER_PASS ; docker push $REPO ; fi 41 | 42 | before_cache: 43 | - set -e 44 | - mkdir -p $(dirname ${DOCKER_CACHE_FILE}) 45 | - docker save $(docker history -q $REPO:$COMMIT | grep -v '') | gzip > ${DOCKER_CACHE_FILE} 46 | 47 | notifications: 48 | slack: 49 | on_failure: always 50 | on_success: change 51 | rooms: 52 | secure: htxsb1e6mOjdWfyyL2D46tDSwrZsJZd22/VlVLykoSt4vktIBGBFIyfroc0BAD3Bxn/4LT23q1TXVXafFDwUa9NWUFOTciyn5wWoJfTzC/GZ3fk4c9dLX2zcFf+Nz+2UU4Kyg7v4rvm5DiqfyGPmvzoKHG+GjbdYLUTjWr0jKscP5zDIRWv/0RUiea8kgGR4dQLY+xq2tAmvCZBzNnb20NWNzdWHviTN8sdbQMipeLm3rW8LwMQavU/IWNRn4yMVTtUzz1eE+cG74c0H4RTU7iJh1NQFjaFKZvEGuE3ZnTA7e6WGeA5bHbaYY44fjZEEu5uhixj08huMuK3fEyTu1rNh5bkAowxqrI53RLPHsECq0xF+Y5aZpV5dEx+gvz/dNCWlV8d658H11oBhL3gPQPcouJTMoktW+12kEqeKVRnSm6fXJmhYZHLal+bF9iQZjh2Ask+1hoWvQJbFONlrCHp+XGKzMxSxyqXWV491QIDZIQsBw17qNSD1zQG0dSdHogxl/N5MB7lgCCmjMPrPaD29tqO1a3qJAN/2dw0dW0VBOznixNz+hpBVbUELJJjsu8wlrm1wBFsdwLIwCVjSKJ3CgQPoMcYTI1nCm5vzuUEExfGTArh00uvYG4H7usfF/KbMt4zQkwxEwjihLvnw5G//YwWpG+JIte5BMnSJuFU= 53 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8-jdk-alpine 2 | 3 | EXPOSE 8080 4 | 5 | RUN set -ex && \ 6 | if [ $(wget -qO- ipinfo.io/country) == CN ]; then echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories ;fi && \ 7 | apk update && \ 8 | apk add --no-cache zsh git openssh 9 | 10 | # Install oh-my-zsh 11 | RUN git clone --depth=1 git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh \ 12 | && cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc 13 | 14 | ENV SHELL /bin/zsh 15 | 16 | ADD backend/target/ide-backend.jar /root 17 | ADD backend/src/main/resources/lib /root/lib 18 | 19 | WORKDIR /root 20 | CMD ["java", "-jar", "ide-backend.jar", "--PTY_LIB_FOLDER=/root/lib"] 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2016 CODING(https://coding.net/). 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | # Coding WebIDE 2 | [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/Coding/WebIDE/blob/master/LICENSE) [![Build Status](https://travis-ci.org/Coding/WebIDE.svg?branch=master)](https://travis-ci.org/Coding/WebIDE) [![Docker Stars](https://img.shields.io/docker/stars/webide/webide.svg)](https://hub.docker.com/r/webide/webide 'DockerHub') [![Docker Pulls](https://img.shields.io/docker/pulls/webide/webide.svg)](https://hub.docker.com/r/webide/webide 'DockerHub') 3 | 4 | README: [English](https://github.com/Coding/WebIDE/blob/master/README.md) | [中文](https://github.com/Coding/WebIDE/blob/master/README-zh.md) 5 | 6 | ---- 7 | ### 线上 WebIDE 现已全面升级为 Cloud Studio,欢迎访问 https://studio.coding.net/ 8 | ---- 9 | 10 | ![](https://raw.githubusercontent.com/Coding/WebIDE/gh-pages/screenshots/import.png) 11 | 12 | ![](https://raw.githubusercontent.com/Coding/WebIDE/gh-pages/screenshots/workspace.png) 13 | 14 | Coding WebIDE(https://ide.coding.net) 是 Coding 自主研发的在线集成开发环境 (IDE)。用户可以通过 WebIDE 创建项目的工作空间, 进行在线开发, 调试等操作。同时 WebIDE 集成了 Git 代码版本控制, 用户可以选择 Coding、GitHub、BitBucket、GitLab 等任意的代码仓库。 WebIDE 还提供了分享开发环境的功能, 用户可以保存当前的开发环境, 分享给团队的其他成员。 15 | 16 | [立即试用](https://ide.coding.net/ws/?ownerName=duwan&projectName=WordPress&isTry=true) 17 | 18 | 请诸位把 issues 提到对应的项目下,这样可以得到更及时的处理。前端请到 [WebIDE-Frontend](https://github.com/Coding/WebIDE-Frontend/issues),后端请到 [WebIDE-Backend](https://github.com/Coding/WebIDE-Backend/issues). 19 | 20 | 21 | ## 功能特色 22 | 23 | 1. *全功能 Web Terminal* 24 | 2. *语法加亮* 25 | 3. *代码补全* 26 | 4. *主题切换* 27 | 5. *分割视图* 28 | 6. *VIM/Emacs 模式* 29 | 7. *实时预览* 30 | 31 | 本项目是为了能够一键启动 `WebIDE` 开源版而创建的,以 git 子模块的形式引用了另外的三个项目,分别是 WebIDE-Frontend、WebIDE-Frontend-Webjars、WebIDE-Backend。 32 | 33 | 34 | ## 模块说明 35 | 36 | * [WebIDE-Frontend](https://github.com/Coding/WebIDE-Frontend) WebIDE 前端项目 37 | * [WebIDE-Frontend-Webjars](https://github.com/Coding/WebIDE-Frontend-Webjars) webjar 项目,用于将 WebIDE 前端打包成 webjar 38 | * [WebIDE-Backend](https://github.com/Coding/WebIDE-Backend) WebIDE 后端项目 39 | 40 | 41 | ## 运行环境 42 | 43 | WebIDE Frontend 需要 **node v6.x** 作为编译运行环境(可以避免很多奇怪的错误),使用 **yarn** 做包管理工具,做构建工具使用 **webpack** 和 **babel** 44 | 45 | WebIDE-Frontend-Webjars & WebIDE-Backend 项目依赖 **maven3** 和 **java8** 46 | 47 | 运行该项目需要至少 512MB 的内存空间。在编译、运行项目前,请保证环境依赖已被正确配置。 48 | 49 | ## Server 版 50 | 51 | 从 Coding 克隆项目: 52 | ``` 53 | git clone git@git.coding.net:coding/WebIDE.git 54 | ``` 55 | 56 | 从 Github 克隆项目: 57 | ``` 58 | git clone git@github.com:Coding/WebIDE.git 59 | ``` 60 | 61 | 拉取子项目: 62 | ``` 63 | git submodule init 64 | git submodule update 65 | ``` 66 | 这样就会通过 git 的 submodule 机制 clone 另外 3 个 repo。 67 | 68 | ``` 69 | ./ide.sh build # 编译并打包前端项目 70 | ./ide.sh run # 启动项目 71 | ``` 72 | 73 | ### 修改默认配置 74 | 75 | `backend/src/main/resources/application.properties` 包括用户、项目、数据库等配置,可以通过修改配置定制服务: 76 | 77 | * **SPACE_HOME:** 存放 workspace 的目录,默认为 `~/.coding-ide/workspace` 78 | * **server.port:** 应用启动的端口 79 | * **USERNAME:** 用户名,git 提交时会使用该值作为 user.name,默认为 coding。 80 | * **EMAIL:** 用户邮箱,git 提交时会使用该值作为 user.email,默认为 coding@coding.net 81 | * **AVATAR:** 用户头像 82 | * **CODING_IDE_HOME:** 应用数据存放目录,默认为 `~/.coding-ide` 83 | 84 | 修改配置后,需要重启应用。另外如果修改了 `USERNAME`、`EMAIL` 的值,会在创建新的 Workspace 时生效。 85 | 86 | ## docker 版 87 | 88 | ``` 89 | docker run -p 8080:8080 -v coding-ide-home:/root/.coding-ide webide/webide 90 | ``` 91 | 92 | 更多 docker 命令,参照 wiki [English](https://github.com/Coding/WebIDE/wiki/Docker-Server.en) [中文](https://github.com/Coding/WebIDE/wiki/Docker-Server.zh) 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Coding WebIDE 2 | [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/Coding/WebIDE/blob/master/LICENSE) [![Build Status](https://travis-ci.org/Coding/WebIDE.svg?branch=master)](https://travis-ci.org/Coding/WebIDE) [![Docker Stars](https://img.shields.io/docker/stars/webide/webide.svg)](https://hub.docker.com/r/webide/webide 'DockerHub') [![Docker Pulls](https://img.shields.io/docker/pulls/webide/webide.svg)](https://hub.docker.com/r/webide/webide 'DockerHub') 3 | 4 | README: [English](https://github.com/Coding/WebIDE/blob/master/README.md) | [中文](https://github.com/Coding/WebIDE/blob/master/README-zh.md) 5 | 6 | ---- 7 | ### WebIDE is now upgraded to Cloud Studio,welcome to our new homepage https://studio.coding.net/ 8 | ---- 9 | 10 | ![](https://raw.githubusercontent.com/Coding/WebIDE/gh-pages/screenshots/import.png) 11 | 12 | ![](https://raw.githubusercontent.com/Coding/WebIDE/gh-pages/screenshots/workspace.png) 13 | 14 | Coding WebIDE(https://ide.coding.net) is a cloud-based IDE developed by Coding Team.You can create your own workspace and develop projects here.WebIDE works fine with Git. You can use Coding、GitHub、BitBucket、GitLab as your Git repository. Workspaces are powered by Docker Ubuntu containers.The development environment can be saved and shared to your team member. 15 | 16 | [Live Demo](https://ide.coding.net/ws/?ownerName=duwan&projectName=WordPress&isTry=true) 17 | 18 | Please submit issues to corresponding projects, that'll help us make issues tracking easier so that we can provide timely help to you. Submit frontend issues at [WebIDE-Frontend](https://github.com/Coding/WebIDE-Frontend/issues) and backend issues at [WebIDE-Backend](https://github.com/Coding/WebIDE-Backend/issues). 19 | 20 | 21 | ## Features 22 | 23 | 1. *Built-In Terminal* 24 | 2. *Syntax Highlighting* 25 | 3. *Language Tools* 26 | 4. *Themes* 27 | 5. *Split View* 28 | 6. *VIM/Emacs Mode* 29 | 7. *Previews* 30 | 31 | This is the entry point to setup and run the WebIDE Community Edition project. It includes other 3 repos as git submodules. 32 | 33 | 34 | ## Modules 35 | 36 | * [WebIDE-Frontend](https://github.com/Coding/WebIDE-Frontend) contains frontend code. 37 | * [WebIDE-Frontend-Webjars](https://github.com/Coding/WebIDE-Frontend-Webjars) packs frontend to webjar. 38 | * [WebIDE-Backend](https://github.com/Coding/WebIDE-Backend) contains backend code. 39 | 40 | 41 | ## Environment 42 | 43 | WebIDE Frontend require **node v6.x** as build environment (this will save you from alot of weird errors). We recommend **yarn** for package management, **webpack** and **babel** is used for building. 44 | 45 | Frontend Webjars & WebIDE Backend use **maven3** and **java8**. 46 | 47 | The project requires at minimum 512MB memory to run. Please ensure you have corresponding tools installed in your environment before build and run the project. 48 | 49 | 50 | ## Native Server 51 | 52 | Clone from coding.net: 53 | ``` 54 | git clone git@git.coding.net:coding/WebIDE.git 55 | ``` 56 | 57 | Clone from github.com: 58 | ``` 59 | git clone git@github.com:Coding/WebIDE.git 60 | ``` 61 | 62 | Init and pull submodules: 63 | ``` 64 | git submodule init 65 | git submodule update 66 | ``` 67 | This will also clone the other 3 repos via git submodule mechanism. 68 | 69 | We provide a shell script `ide.sh` to ease the process for you. 70 | 71 | ``` 72 | ./ide.sh build # transpile and pack the frontend to webjars 73 | ./ide.sh run # start the backend server 74 | ``` 75 | Server runs on port 8080 by default, visit localhost:8080 to check it out. 76 | 77 | 78 | ### Configurations 79 | 80 | `backend/src/main/resources/application.properties` contains configurations of user, project, database, etc., you can change these parameters to meet your need: 81 | 82 | * **SPACE_HOME:** path to your workspace directory, default to `~/.coding-ide/workspace` 83 | * **server.port:** backend server port 84 | * **USERNAME:** username, used by git as its `user.name` config when commit, defaults to "coding" 85 | * **EMAIL:** email, used by git as its `user.email` config when commit, defaults to "coding@coding.net" 86 | * **AVATAR:** user's avatar 87 | * **CODING_IDE_HOME:** path to store WebIDE application's data, default to `~/.coding-ide` 88 | 89 | If changed, restart the application to let your configurations take effect. Note that changes on `USERNAME`, `EMAIL` *WILL NOT* apply to workspaces that are already created. 90 | 91 | 92 | ## Docker Server 93 | 94 | ``` 95 | docker run -p 8080:8080 -v coding-ide-home:/root/.coding-ide webide/webide 96 | ``` 97 | 98 | To learn more about docker commands,please refer to wiki [English](https://github.com/Coding/WebIDE/wiki/Docker-Server.en) [中文](https://github.com/Coding/WebIDE/wiki/Docker-Server.zh) 99 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | # Environment for running the application, either "prod" or "dev" 2 | #RUN_ENV= 3 | 4 | # USER INFO 5 | #USERNAME= 6 | #EMAIL= 7 | #AVATAR= 8 | 9 | # CORS (Seprate with comma) 10 | #ALLOWED_ORIGINS= 11 | 12 | # Home Directory(Do not modify when using docker) 13 | #CODING_IDE_HOME= 14 | #SPACE_HOME= 15 | 16 | # Max file size to upload (in Mb) 17 | #UPLOAD_FILE_SIZE_LIMIT= 18 | 19 | -------------------------------------------------------------------------------- /ide.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BASEDIR=$(cd "$(dirname "$0")"; pwd) 4 | 5 | PROG_NAME=$(basename $0) 6 | 7 | BACKEND=$BASEDIR/backend 8 | FRONTEND=$BASEDIR/frontend 9 | FRONTEND_WEBJARS=$BASEDIR/frontend-webjars 10 | CONTAINER=webide 11 | 12 | valid_last_cmd() { 13 | if [ $? -ne 0 ]; then 14 | exit 1 15 | fi 16 | } 17 | 18 | sub_help(){ 19 | echo "Usage: $PROG_NAME " 20 | echo "" 21 | echo "Subcommands:" 22 | echo " build [-t tag]" 23 | echo " run [-p port]" 24 | echo " docker [build|run|attach|stop|logs|exec]" 25 | echo "" 26 | echo "For help with each subcommand run:" 27 | echo "$PROG_NAME -h | --help" 28 | echo "" 29 | } 30 | 31 | sub_backend() { 32 | bakend_usage() { 33 | echo "Usage: $PROG_NAME backend [clean]" 34 | } 35 | 36 | case $1 in 37 | "-h" | "--help") 38 | backend_usage 39 | ;; 40 | "clean") 41 | cd $BACKEND 42 | mvn clean 43 | cd $BASEDIR 44 | ;; 45 | esac 46 | } 47 | 48 | do_build_frontend() { 49 | cd $FRONTEND 50 | echo "building frontend..." 51 | yarn install 52 | yarn run build 53 | valid_last_cmd 54 | 55 | cd $FRONTEND_WEBJARS 56 | echo "packing frontend...." 57 | mvn clean install 58 | valid_last_cmd 59 | cd $BASEDIR 60 | } 61 | 62 | do_build_backend() { 63 | cd $BACKEND 64 | echo "mvn clean and packaging..." 65 | mvn clean package -Dmaven.test.skip=true 66 | valid_last_cmd 67 | cd $BASEDIR 68 | } 69 | 70 | sub_build() { 71 | 72 | build_usage() { 73 | echo "Usage: $PROG_NAME build [frontend | backend | run]" 74 | } 75 | 76 | case $1 in 77 | "-h" | "--help") 78 | build_usage 79 | ;; 80 | "") 81 | do_build_frontend 82 | do_build_backend 83 | ;; 84 | "backend") 85 | do_build_backend 86 | ;; 87 | "frontend") 88 | do_build_frontend 89 | ;; 90 | "run") # build and run 91 | do_build_frontend 92 | do_build_backend 93 | do_run_backend 94 | ;; 95 | esac 96 | } 97 | 98 | error() { 99 | printf "${RED}ERROR:${NC} %s\n" "${1}" 100 | } 101 | 102 | error_exit() { 103 | # echo "---------------------------------------" 104 | # error "!!!" 105 | error "${1}" 106 | # error "!!!" 107 | # echo "---------------------------------------" 108 | exit 1 109 | } 110 | 111 | valid_container_exist() { 112 | RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) 113 | 114 | if [ $? -eq 1 ]; then 115 | echo "UNKNOWN - container $CONTAINER does not exist." 116 | exit 3 117 | fi 118 | } 119 | 120 | assert_container_is_running() { 121 | RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) 122 | 123 | if [ $? -eq 1 ]; then 124 | echo "UNKNOWN - $CONTAINER does not exist." 125 | exit 3 126 | fi 127 | 128 | if [ "$RUNNING" == "false" ]; then 129 | echo "CRITICAL - $CONTAINER is not running." 130 | exit 2 131 | fi 132 | } 133 | 134 | container_exist() { 135 | RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) 136 | 137 | if [ $? -eq 0 ]; then 138 | return 0 139 | else 140 | return 1 141 | fi 142 | } 143 | 144 | container_is_running() { 145 | RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) 146 | 147 | if [ $? -eq 1 ]; then 148 | return 1 149 | fi 150 | 151 | if [ "$RUNNING" == "true" ]; then 152 | return 0 153 | else 154 | return 1 155 | fi 156 | } 157 | 158 | 159 | sub_docker() { 160 | 161 | local OPTIND opt 162 | 163 | check_docker() { 164 | if ! docker ps > /dev/null 2>&1; then 165 | output=$(docker ps) 166 | error_exit "Error - Docker not installed properly: \n${output}" 167 | fi 168 | } 169 | 170 | docker_usage() { 171 | echo "Usage: $PROG_NAME docker [build|run|attach|stop|logs|exec]" 172 | } 173 | 174 | check_docker 175 | 176 | # process options 177 | while getopts ":t:" opt; do 178 | case $opt in 179 | t) 180 | EXTRA_VARS="-t ${OPTARG}" 181 | ;; 182 | \?) 183 | docker_usage 184 | exit 1 185 | ;; 186 | esac 187 | done 188 | 189 | case $1 in 190 | "-h" | "--help") 191 | docker_usage 192 | ;; 193 | "build") 194 | docker build $EXTRA_VARS -t webide/webide . 195 | ;; 196 | "run") 197 | RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) 198 | 199 | if ! container_exist ; then 200 | 201 | echo "creating container $CONTAINER" 202 | docker create -p 8080:8080 --env-file config -v coding-ide-home:/root/.coding-ide --name webide -h webide webide/webide 203 | valid_last_cmd 204 | elif [ "$RUNNING" == "true" ]; then 205 | echo "CRITICAL - $CONTAINER is running." 206 | exit 2 207 | fi 208 | 209 | echo "starting container $CONTAINER" 210 | docker start webide 211 | valid_last_cmd 212 | docker attach --sig-proxy=false webide 213 | ;; 214 | "stop") 215 | assert_container_is_running 216 | docker stop webide 217 | ;; 218 | "attach") 219 | assert_container_is_running 220 | docker attach --sig-proxy=false webide 221 | ;; 222 | "logs") 223 | assert_container_is_running 224 | docker logs -f webide 225 | ;; 226 | "remove") 227 | if container_is_running ; then 228 | echo "stoping webide..." 229 | docker stop webide 230 | fi 231 | echo "removing webide..." 232 | docker rm webide 233 | echo "done..." 234 | ;; 235 | "exec") 236 | assert_container_is_running 237 | docker exec -it webide bash 238 | ;; 239 | esac 240 | } 241 | 242 | do_run_backend() { 243 | if [ ! -f $BACKEND/target/ide-backend.jar ]; then 244 | sub_build 245 | fi 246 | . $BASEDIR/config 247 | java -jar $BACKEND/target/ide-backend.jar --PTY_LIB_FOLDER=$BACKEND/src/main/resources/lib ${1} 248 | } 249 | 250 | sub_run() { 251 | local OPTIND opt 252 | 253 | run_usage() { 254 | echo "Usage: $PROG_NAME run [-p port]" 255 | } 256 | 257 | # process options 258 | while getopts ":p:" opt; do 259 | case $opt in 260 | p) 261 | EXTRA_VARS="--server.port=${OPTARG}" 262 | ;; 263 | \?) 264 | run_usage 265 | exit 1 266 | ;; 267 | esac 268 | done 269 | 270 | shift $((OPTIND-1)) 271 | 272 | case $1 in 273 | "-h" | "--help") 274 | run_usage 275 | ;; 276 | "") 277 | do_run_backend $EXTRA_VARS 278 | ;; 279 | esac 280 | } 281 | 282 | # process subcommands 283 | subcommand=$1 284 | case $subcommand in 285 | "" | "-h" | "--help") 286 | sub_help 287 | ;; 288 | *) 289 | shift 290 | 291 | sub_${subcommand} $@ 292 | 293 | if [ $? = 127 ]; then 294 | echo "Error: '$subcommand' is not a known subcommand." >&2 295 | echo " Run '$PROG_NAME --help' for a list of known subcommands." >&2 296 | exit 1 297 | fi 298 | ;; 299 | esac 300 | -------------------------------------------------------------------------------- /mvn_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | nexus-aliyun 9 | central 10 | Nexus aliyun 11 | http://maven.aliyun.com/nexus/content/groups/public 12 | 13 | 14 | 15 | --------------------------------------------------------------------------------