ubuntu18.04容器专用-编译并运行alist

启动容器:

docker run --name u1804 -dit --hostname OK8 \
-v /sbin/busybox:/sbin/busybox -v /sbin/busybox:/sbin/netstat ubuntu:18.04

进入容器控制台:

docker exec -it u1804 bash

运行命令:

cd /tmp;
which git wget curl bash apt perl unzip busybox ssh ps netstat npm node;
apt update;
apt install -y git wget unzip;

git clone https://github.com/alist-org/alist.git;\
git clone --recursive https://github.com/alist-org/alist-web.git;

#echo https://crowdin.com/project/alist/zh-CN;

cd /tmp;
wget https://crowdin.com/backend/download/project/alist/zh-CN.zip --no-check-certificate;\
unzip zh-CN.zip;   #apt install -y nodejs ;
apt install -y npm;
node -v;  # v8.10.0


# npm install -g pnpm;  
#WARN engine [email protected]: wanted: {"node":">=16.14"} (current: {"node":"8.10.0","npm":"3.5.2"})

#WARN engine [email protected]: wanted: {"node":">=16.14"} (current: {"node":"8.10.0","npm":"3.5.2"})

node版本不够高

通过nvm安装高版本node v17.8.0 ,    v18.0.0版本太高了安装不了:

export HOME=/root;
wget --no-check-certificate https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh;
bash install.sh;
nvm --version

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

nvm --version
nvm ls-remote


nvm install v17.8.0;
node -v;

[ -f /tmp/src/lang/zh-CN/settings.json ] && [ -d /tmp/alist-web ] && [ -d /tmp/alist ] &&(
cd /tmp;
cp -r ./src/lang/zh-CN ./alist-web/src/lang/
cd alist-web;ls -al ./src/lang/;
node ./scripts/i18n.mjs;
npm install -g pnpm;
)
root@OK8:/tmp# nvm install v18.0.0
Downloading and installing node v18.0.0...
Downloading https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz...
############################################################################################################################################################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v18.0.0` to unset it.
root@OK8:/tmp# 



root@OK8:/tmp/alist-web# npm install -g pnpm;

added 1 package, and audited 2 packages in 2s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New major version of npm available! 8.5.5 -> 9.8.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.0
npm notice Run npm install -g [email protected] to update!
npm notice 
root@OK8:/tmp/alist-web# 

继续:

cd /tmp/alist-web/;
pnpm install;
ls -al vite.config.*s ;
# vite.config.ts

#echo cat  vite.config.*s ;

grep  -r  "chunkSizeWarningLimit"   .

#./node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-74663fff.js:        chunkSizeWarningLimit: 500,
sed -i "s/chunkSizeWarningLimit: 500/chunkSizeWarningLimit: 6500/g" ./node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-74663fff.js;
grep  -r  "chunkSizeWarningLimit"   .


pnpm build;

#pnpm run build;

cd /tmp/alist-web;

cd ../alist;
rm -rf ./public/dist/*;
cp -r ../alist-web/dist ./public/  

export HOME=/root;

cd /tmp;
wget  --no-check-certificate https://go.dev/dl/go1.20.linux-amd64.tar.gz;\
which tar&&tar -xvf go1.20.linux-amd64.tar.gz;


cd /tmp/alist;
# go build -o main2 main.go;
/tmp/go/bin/go build -ldflags="-s -w" -o main2 main.go;

./main2 admin;./main2 server;

Go 编译器默认编译出来的程序会带有符号表和调试信息,一般来说 release 版本可以去除调试信息以减小二进制体积。
 -s:忽略符号表和调试信息。
 -w:忽略DWARFv3调试信息,使用该选项后将无法使用gdb进行调试。

从容器里复制出来:

docker cp u1804:/tmp/alist/main2 /tmp/alist2;

压缩一下(不压缩的话45M,upx压缩后15M):

upx -9 alist2 ;

参考文档:

alist编译记录_EthanZhu的博客-CSDN博客服务器环境Linux version 3.10.0-327.el7.x86_64 (https://blog.csdn.net/iethanzhu/article/details/131495456

Alist v3 自编译粗略教程 - 哔哩哔哩前言‪ 有的小伙伴想着自己编译一下Alist,不管是出于自己想折腾还是自己想改改源码哩.大家都可以编译~ (๑•́₃ •)编译之前的前提条件‪ 大家可以看一下这里需要啥..https://github.com/alist-org/alist/blob/main/CONTRIBUTING.md‪ 编译Alist Go竟然需要 1.19+了...呜呜呜‪ 我没记错前几个月才升级了1.18+...升级真快(´◔‸◔')”编译之前我们需要先准备安装好以下软https://www.bilibili.com/read/cv19125768

查看安装的node版本
node --version
npm --version


切换node版本
nvm use v11.3.0


将此版本设为默认
nvm alias default v11.3.0

你可能感兴趣的:(linux,ubuntu)