40 lines
658 B
Docker
40 lines
658 B
Docker
# 使用Ruby 3.3官方镜像
|
|
FROM ruby:3.3-slim
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update -qq && \
|
|
apt-get install -y \
|
|
build-essential \
|
|
libsqlite3-dev \
|
|
nodejs \
|
|
npm \
|
|
git \
|
|
curl && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 安装Rails 8.1
|
|
RUN gem install rails -v '8.1.0' --no-document
|
|
|
|
# 复制启动脚本
|
|
COPY start.sh /app/start.sh
|
|
RUN chmod +x /app/start.sh
|
|
|
|
# 复制Gemfile
|
|
COPY Gemfile* ./
|
|
RUN bundle install || true
|
|
|
|
# 复制应用代码
|
|
COPY . .
|
|
|
|
# 创建必要的目录
|
|
RUN mkdir -p /app/db /app/storage /app/tmp /app/log
|
|
|
|
# 暴露端口
|
|
EXPOSE 3000
|
|
|
|
# 启动命令
|
|
CMD ["/app/start.sh"]
|