
epigenesys/rails本镜像为GitLab CI/CD环境优化,基于官方Rails镜像构建,集成了持续集成流程所需的核心工具和依赖,旨在简化Rails应用在GitLab CI流水线中的配置与执行过程。镜像预配置了Ruby、Bundler、数据库客户端及构建工具,可直接用于测试、构建和部署阶段,减少CI环境准备时间。
通过Docker Hub或私有仓库拉取镜像:
bashdocker pull [镜像仓库地址]/rails-gitlab-ci:[tag] # 示例:拉取Rails 7.0版本 docker pull example/rails-gitlab-ci:7.0
可通过以下命令在本地模拟CI环境:
bashdocker run -it --rm \ -v $(pwd):/app \ -e RAILS_ENV=test \ -e DATABASE_URL=postgresql://user:pass@db:5432/test_db \ example/rails-gitlab-ci:7.0 \ bundle exec rspec
在.gitlab-ci.yml中使用该镜像配置CI job:
yamlstages: - test - build test: stage: test image: example/rails-gitlab-ci:7.0 services: - postgres:14 variables: RAILS_ENV: test DATABASE_URL: postgresql://postgres:postgres@postgres:5432/test BUNDLE_PATH: vendor/bundle before_script: - bundle install --jobs $(nproc) - bundle exec rails db:create db:migrate script: - bundle exec rspec spec/ - bundle exec rubocop build: stage: build image: example/rails-gitlab-ci:7.0 variables: RAILS_ENV: production script: - bundle install --without development test - bundle exec rails assets:precompile artifacts: paths: - public/assets/ - tmp/cache/
| 变量名 | 描述 | 默认值 |
|---|---|---|
RAILS_ENV | Rails运行环境 | test |
BUNDLE_PATH | Bundler依赖安装路径 | /usr/local/bundle |
DATABASE_URL | 数据库连接URL | 无(需根据服务配置) |
NODE_ENV | Node.js环境 | 与RAILS_ENV一致 |
镜像标签遵循[rails版本]-[基础镜像类型]格式,例如:
7.0-alpine:基于Alpine的Rails 7.0版本6.1-slim:基于Debian slim的Rails 6.1版本latest:最新稳定Rails版本(默认Debian slim)services(如mysql:8.0、postgres:14).gitlab-ci.yml中配置cache字段缓存vendor/bundle和node_modules,减少依赖安装时间


manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务