Skip to content

Commit d5f51a0

Browse files
authored
Merge pull request #22 from Coding/tanhehe/rename_docker_image_name
enhance docker support 1. Better use of the DockerFile 2. pushed images to docker hub, webide can be run in one command 3. frontend use relative path 4. mvn speed up for docker build
2 parents 9ef2779 + ea104e2 commit d5f51a0

File tree

7 files changed

+48
-85
lines changed

7 files changed

+48
-85
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ ADD . /opt/coding/WebIDE
1616

1717
RUN sudo chown -R coding /opt/coding/WebIDE
1818

19-
CMD ["/opt/coding/WebIDE/ide.sh", "build", "run"]
19+
RUN cd /opt/coding/WebIDE/frontend && npm install && npm run build
20+
21+
RUN cd /opt/coding/WebIDE/frontend-webjars && mvn -s ../mvn_settings.xml clean install
22+
23+
RUN cd /opt/coding/WebIDE/backend && mvn -s ../mvn_settings.xml clean package -Dmaven.test.skip=true
24+
25+
CMD ["java", "-jar", "/opt/coding/WebIDE/backend/target/ide-backend.jar", "--PTY_LIB_FOLDER=/opt/coding/WebIDE/backend/src/main/resources/lib"]

README-zh.md

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ WebIDE-Frontend-Webjars & WebIDE-Backend 项目依赖 **maven3** 和 **java8**
4040

4141
在编译、运行项目前,请保证环境依赖已被正确配置。
4242

43-
## 编译、打包、运行
44-
45-
### 克隆项目
43+
## Server 版
4644

4745
从 Coding 克隆项目:
4846
```
@@ -59,50 +57,17 @@ git clone [email protected]:Coding/WebIDE.git
5957
git submodule init
6058
git submodule update
6159
```
62-
63-
### 本机版
64-
65-
本项目提供了一个脚本 `ide.sh`,用于编译、打包、运行项目:
60+
这样就会通过 git 的 submodule 机制 clone 另外 3 个 repo。
6661

6762
```
6863
./ide.sh build # 编译并打包前端项目
6964
./ide.sh run # 启动项目
7065
```
71-
启动完成后,默认端口为 8080,访问 localhost:8080 即可。打开浏览器访问 http://localhost:8080
72-
73-
### Docker 版
7466

75-
#### 通过使用 ide.sh
67+
## docker 版
7668

7769
```
78-
./ide.sh docker build # 创建 docker 镜像
79-
./ide.sh docker run # 创建并启动 container
80-
./ide.sh docker stop # 停止 container
81-
./ide.sh docker attach # attach container
82-
./ide.sh docker logs # 查看 container log
83-
./ide.sh docker exec # 进入 container
70+
docker run -p 8080:8080 --name webide webide/webide
8471
```
8572

86-
#### 通过使用 docker 命令
87-
88-
如果在使用脚本的过程中遇到了困难,可以直接使用 docker 的命令。
89-
90-
```
91-
# 创建 docker 镜像
92-
docker build -t coding/webide
93-
94-
# 创建并启动 container
95-
docker run -p 8080:8080 -v $HOME/.m2:/home/coding/.m2 -v $HOME/.coding-ide-home:/home/coding/.coding-ide-home --name webide coding/webide
96-
97-
# 停止 container
98-
docker stop webide
99-
100-
# attach container
101-
docker attach webide
102-
103-
# 查看 container log
104-
docker logs webide
105-
106-
# 进入 container
107-
docker exec -it webide bash
108-
```
73+
更多 docker 命令,参照 wiki [English](https://github.com/Coding/WebIDE/wiki/Docker-Server.en) [中文](https://github.com/Coding/WebIDE/wiki/Docker-Server.zh)

README.md

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ Frontend Webjars & WebIDE Backend use **maven3** and **java8**.
4141
Please ensure you have corresponding tools installed in your environment before build and run the project.
4242

4343

44-
## Build and run
45-
46-
### Clone the repo
44+
## Native Server
4745

4846
Clone from coding.net:
4947
```
5048
git clone [email protected]:coding/WebIDE.git
5149
```
50+
5251
Clone from github.com:
5352
```
5453
git clone [email protected]:Coding/WebIDE.git
@@ -61,9 +60,6 @@ git submodule update
6160
```
6261
This will also clone the other 3 repos via git submodule mechanism.
6362

64-
65-
### Run on a normal host
66-
6763
We provide a shell script `ide.sh` to ease the process for you.
6864

6965
```
@@ -72,40 +68,10 @@ We provide a shell script `ide.sh` to ease the process for you.
7268
```
7369
Server runs on port 8080 by default, visit localhost:8080 to check it out.
7470

75-
76-
### Run in a docker container
77-
78-
#### Using `ide.sh`
71+
## Docker Server
7972

8073
```
81-
./ide.sh docker build # create docker image
82-
./ide.sh docker run # create and start a container
83-
./ide.sh docker stop # stop container
84-
./ide.sh docker attach # attach container
85-
./ide.sh docker logs # check container's logs
86-
./ide.sh docker exec # create a new Bash session in the container
74+
docker run -p 8080:8080 --name webide webide/webide
8775
```
8876

89-
#### Using `docker` CLI
90-
91-
If you encounter any problem using `ide.sh`, try get around it using docker CLI directly.
92-
93-
```
94-
# create docker image
95-
docker build -t coding/webide
96-
97-
# create and start a container
98-
docker run -p 8080:8080 -v $HOME/.m2:/home/coding/.m2 -v $HOME/.coding-ide-home:/home/coding/.coding-ide-home --name webide coding/webide
99-
100-
# stop container
101-
docker stop webide
102-
103-
# attach container
104-
docker attach webide
105-
106-
# check container's logs
107-
docker logs webide
108-
109-
# create a new Bash session in the container
110-
docker exec -it webide bash
111-
```
77+
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)

backend

Submodule backend updated 1 file

ide.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BACKEND=$BASEDIR/backend
88
FRONTEND=$BASEDIR/frontend
99
FRONTEND_WEBJARS=$BASEDIR/frontend-webjars
1010
CONTAINER=webide
11+
CODING_IDE_HOME=$HOME/.coding-ide-home
1112

1213
valid_last_cmd() {
1314
if [ $? -ne 0 ]; then
@@ -141,6 +142,13 @@ container_is_running() {
141142
fi
142143
}
143144

145+
create_dir_if_not_exist() {
146+
if [ ! -d "$1" ]; then
147+
echo "$1 is not exist, creating..."
148+
mkdir $1
149+
fi
150+
}
151+
144152
sub_docker() {
145153

146154
check_docker() {
@@ -161,14 +169,16 @@ sub_docker() {
161169
docker_usage
162170
;;
163171
"build")
164-
docker build -t coding/webide .
172+
docker build -t webide/webide .
165173
;;
166174
"run")
167175
RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
168176

169177
if ! container_exist ; then
178+
create_dir_if_not_exist $HOME/.coding-ide-home
179+
170180
echo "creating container $CONTAINER"
171-
docker create -p 8080:8080 -v $HOME/.m2:/home/coding/.m2 -v $HOME/.coding-ide-home:/home/coding/.coding-ide-home --name webide coding/webide
181+
docker create -p 8080:8080 -v $HOME/.coding-ide-home:/home/coding/.coding-ide-home --name webide webide/webide
172182
valid_last_cmd
173183
elif [ "$RUNNING" == "true" ]; then
174184
echo "CRITICAL - $CONTAINER is running."
@@ -177,14 +187,16 @@ sub_docker() {
177187

178188
echo "starting container $CONTAINER"
179189
docker start webide
190+
valid_last_cmd
191+
docker attach --sig-proxy=false webide
180192
;;
181193
"stop")
182194
assert_container_is_running
183195
docker stop webide
184196
;;
185197
"attach")
186198
assert_container_is_running
187-
docker attach webide
199+
docker attach --sig-proxy=false webide
188200
;;
189201
"logs")
190202
assert_container_is_running

mvn_settings.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
<mirrors>
7+
<mirror>
8+
<id>nexus-aliyun</id>
9+
<mirrorOf>central</mirrorOf>
10+
<name>Nexus aliyun</name>
11+
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
12+
</mirror>
13+
</mirrors>
14+
</settings>

0 commit comments

Comments
 (0)