mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
fix(docker): api address incorrect issue
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# replace default api path to new one
|
||||
python /app/bin/update_docker_js_api_address.py
|
||||
|
||||
crawlab-server server
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
# NOTE: deprecated
|
||||
|
||||
# replace env
|
||||
indexPath=/app/dist/index.html
|
||||
if test -z "$CRAWLAB_BASE_URL"; then
|
||||
:
|
||||
else
|
||||
sed -i "s?/js/?${CRAWLAB_BASE_URL}/js/?g" ${indexPath}
|
||||
sed -i "s?/css/?${CRAWLAB_BASE_URL}/css/?g" ${indexPath}
|
||||
sed -i "s/ <link rel=\"icon\" type=\"image\/x-icon\" href=\"/ <link rel=\"icon\" type=\"image\/x-icon\" href=\"\/${CRAWLAB_BASE_URL}/g" ${indexPath}
|
||||
sed -i "s/ <link rel=\"stylesheet\" href=\"/ <link rel=\"stylesheet\" href=\"${CRAWLAB_BASE_URL}\//g" ${indexPath}
|
||||
sed -i "s/ window.VUE_APP_API_BASE_URL = '/ window.VUE_APP_API_BASE_URL = '\/${CRAWLAB_BASE_URL}/g" ${indexPath}
|
||||
fi
|
||||
if test -z "$CRAWLAB_INIT_BAIDU_TONGJI"; then
|
||||
:
|
||||
else
|
||||
sed -i "s/ window.VUE_APP_INIT_BAIDU_TONGJI = ''/ window.VUE_APP_INIT_BAIDU_TONGJI = '${CRAWLAB_INIT_BAIDU_TONGJI}'/g" ${indexPath}
|
||||
fi
|
||||
if test -z "$CRAWLAB_INIT_UMENG"; then
|
||||
:
|
||||
else
|
||||
sed -i "s/ window.VUE_APP_INIT_UMENG = ''/ window.VUE_APP_INIT_UMENG = '${CRAWLAB_INIT_UMENG}'/g" ${indexPath}
|
||||
fi
|
||||
|
||||
# start nginx
|
||||
service nginx start
|
||||
|
||||
# start seaweedfs server
|
||||
seaweedfsDataPath=/data/seaweedfs
|
||||
if [ -e ${seaweedfsDataPath} ]; then
|
||||
:
|
||||
else
|
||||
mkdir -p ${seaweedfsDataPath}
|
||||
fi
|
||||
weed server \
|
||||
-dir /data \
|
||||
-master.dir ${seaweedfsDataPath} \
|
||||
-volume.dir.idx ${seaweedfsDataPath} \
|
||||
-ip localhost \
|
||||
-volume.port 9999 \
|
||||
-filer \
|
||||
>>/var/log/weed.log 2>&1 &
|
||||
24
bin/update_docker_js_api_address.py
Normal file
24
bin/update_docker_js_api_address.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
dir_path = '/app/dist/assets'
|
||||
|
||||
for file_name in os.listdir(dir_path):
|
||||
if not file_name.endswith('.js'):
|
||||
continue
|
||||
|
||||
file_path = os.path.join(dir_path, file_name)
|
||||
|
||||
api_url = 'http://localhost:8000'
|
||||
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
if api_url not in content:
|
||||
continue
|
||||
|
||||
content = content.replace(api_url, '/api')
|
||||
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print(f'replaced api url in file: {file_name}')
|
||||
Reference in New Issue
Block a user