Commit cc4efa38 by Ivan

feat: update entrypoint

parent 876ec3a5
......@@ -29,7 +29,7 @@ RUN apt-get update -qq && \
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/bundle" \
BUNDLE_WITHOUT="development" \
BUNDLE_WITHOUT="development:test" \
BUNDLE_JOBS="4" \
BUNDLE_RETRY="3" \
MALLOC_ARENA_MAX="2" \
......@@ -71,4 +71,5 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["/rails/code/bin/rails", "server"]
# 使用链接后的bin/rails路径,这样可以确保正确的环境变量和gem路径
CMD ["/rails/bin/rails", "server"]
......@@ -192,7 +192,7 @@ for dir in app bin config db lib public vendor; do
fi
done
# Link important files
# Link important files and directories
for file in Gemfile Gemfile.lock Rakefile config.ru package.json package-lock.json; do
if [ -f "/rails/code/$file" ]; then
ln -sf /rails/code/$file /rails/$file
......@@ -202,6 +202,14 @@ for file in Gemfile Gemfile.lock Rakefile config.ru package.json package-lock.js
fi
done
# Link bin directory for rails commands
if [ -d "/rails/code/bin" ]; then
echo "Linking bin directory"
ln -sf /rails/code/bin /rails/bin
else
echo "Warning: bin directory not found in /rails/code"
fi
# Link node_modules if it exists in the mounted volume
if [ -d "/rails/node_modules" ]; then
ln -sfn /rails/node_modules /rails/code/node_modules
......@@ -217,12 +225,20 @@ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
free -h || echo "free command not available"
df -h || echo "df command not available"
# 显示当前的bundle配置
echo "Current bundle config:"
bundle config
if [ ! -d "${BUNDLE_PATH}/ruby" ] || [ "$FORCE_BUNDLE_INSTALL" = "true" ]; then
# 尝试使用更少的并发任务和内存
echo "Running bundle install with optimized settings..."
bundle config set --local jobs 2
bundle config set --local retry 3
bundle config set --local without "development test"
bundle config set --local without "development:test"
# 确保正确的路径
echo "BUNDLE_PATH is set to: ${BUNDLE_PATH}"
mkdir -p "${BUNDLE_PATH}"
# 添加错误处理
if ! bundle install; then
......@@ -231,7 +247,7 @@ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
bundle install --verbose || {
echo "❌ Bundle install failed again!"
echo "Last 100 lines of gem installation logs:"
find /usr/local/bundle/extensions -name "gem_make.out" -exec tail -n 100 {} \; 2>/dev/null || echo "No gem_make.out files found"
find "${BUNDLE_PATH}/extensions" -name "gem_make.out" -exec tail -n 100 {} \; 2>/dev/null || echo "No gem_make.out files found"
exit 1
}
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment