fix: fix terminal not opening in Docker and slim down Docker image

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-03 13:59:30 +08:00
parent ae93cc062b
commit 858ea9d10a
3 changed files with 15 additions and 7 deletions

View File

@@ -26,9 +26,6 @@ RUN apt-get update && apt-get install -y \
curl \ curl \
python3 \ python3 \
python3-pip \ python3-pip \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=backend /app/src-tauri/target/release/codeg-server /usr/local/bin/codeg-server COPY --from=backend /app/src-tauri/target/release/codeg-server /usr/local/bin/codeg-server
@@ -38,6 +35,7 @@ ENV CODEG_STATIC_DIR=/app/web
ENV CODEG_DATA_DIR=/data ENV CODEG_DATA_DIR=/data
ENV CODEG_PORT=3080 ENV CODEG_PORT=3080
ENV CODEG_HOST=0.0.0.0 ENV CODEG_HOST=0.0.0.0
ENV SHELL=/bin/bash
EXPOSE 3080 EXPOSE 3080
VOLUME /data VOLUME /data

View File

@@ -12,9 +12,6 @@ RUN apt-get update && apt-get install -y \
curl \ curl \
python3 \ python3 \
python3-pip \ python3-pip \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY dist/${TARGETARCH}/codeg-server /usr/local/bin/codeg-server COPY dist/${TARGETARCH}/codeg-server /usr/local/bin/codeg-server
@@ -24,6 +21,7 @@ ENV CODEG_STATIC_DIR=/app/web
ENV CODEG_DATA_DIR=/data ENV CODEG_DATA_DIR=/data
ENV CODEG_PORT=3080 ENV CODEG_PORT=3080
ENV CODEG_HOST=0.0.0.0 ENV CODEG_HOST=0.0.0.0
ENV SHELL=/bin/bash
EXPOSE 3080 EXPOSE 3080
VOLUME /data VOLUME /data

View File

@@ -44,7 +44,19 @@ fn resolve_shell() -> String {
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
{ {
std::env::var("SHELL").unwrap_or_else(|_| "/bin/zsh".to_string()) if let Ok(shell) = std::env::var("SHELL") {
let trimmed = shell.trim();
if !trimmed.is_empty() {
return trimmed.to_string();
}
}
// Try common shells in order of preference
for candidate in ["/bin/zsh", "/bin/bash", "/bin/sh"] {
if std::path::Path::new(candidate).exists() {
return candidate.to_string();
}
}
"/bin/sh".to_string()
} }
} }