feat: adjust docker image build
This commit is contained in:
+3
-6
@@ -29,9 +29,11 @@ ARG BUILD_TIME
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Go mod files
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod download
|
RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod download
|
||||||
|
|
||||||
|
# Copy backend source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Copy frontend dist
|
# Copy frontend dist
|
||||||
@@ -61,11 +63,6 @@ RUN sed -i 's@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.li
|
|||||||
&& python3 -m venv /opt/venv \
|
&& python3 -m venv /opt/venv \
|
||||||
&& /opt/venv/bin/pip install --upgrade pip \
|
&& /opt/venv/bin/pip install --upgrade pip \
|
||||||
&& /opt/venv/bin/pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
&& /opt/venv/bin/pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||||
# 设置虚拟环境 Python 为系统默认
|
|
||||||
&& update-alternatives --install /usr/bin/python python /opt/venv/bin/python 1 \
|
|
||||||
&& update-alternatives --install /usr/bin/python3 python3 /opt/venv/bin/python 1 \
|
|
||||||
&& update-alternatives --install /usr/bin/pip pip /opt/venv/bin/pip 1 \
|
|
||||||
&& update-alternatives --install /usr/bin/pip3 pip3 /opt/venv/bin/pip 1 \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -83,4 +80,4 @@ RUN chmod +x docker-entrypoint.sh
|
|||||||
|
|
||||||
EXPOSE 8052
|
EXPOSE 8052
|
||||||
|
|
||||||
CMD ["./docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
||||||
|
|||||||
+15
-4
@@ -1,22 +1,33 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# 创建必要的目录
|
# ============================
|
||||||
|
# 激活 Python 虚拟环境
|
||||||
|
# ============================
|
||||||
|
if [ -d /opt/venv ]; then
|
||||||
|
export PATH="/opt/venv/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ============================
|
||||||
|
# 创建必要目录
|
||||||
|
# ============================
|
||||||
mkdir -p /app/data /app/data/scripts /app/configs
|
mkdir -p /app/data /app/data/scripts /app/configs
|
||||||
|
|
||||||
# 如果数据库文件存在,设置不可变属性防止误删
|
# ============================
|
||||||
|
# 设置不可变属性
|
||||||
|
# ============================
|
||||||
if [ -f /app/data/ql.db ]; then
|
if [ -f /app/data/ql.db ]; then
|
||||||
chattr +i /app/data/ql.db 2>/dev/null || true
|
chattr +i /app/data/ql.db 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 如果 configs 目录存在,设置不可变属性
|
|
||||||
if [ -d /app/configs ]; then
|
if [ -d /app/configs ]; then
|
||||||
chattr +i /app/configs 2>/dev/null || true
|
chattr +i /app/configs 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 如果 scripts 目录存在,设置不可变属性
|
|
||||||
if [ -d /app/data/scripts ]; then
|
if [ -d /app/data/scripts ]; then
|
||||||
chattr +i /app/data/scripts 2>/dev/null || true
|
chattr +i /app/data/scripts 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ============================
|
||||||
# 启动应用
|
# 启动应用
|
||||||
|
# ============================
|
||||||
exec ./baihu
|
exec ./baihu
|
||||||
|
|||||||
Reference in New Issue
Block a user