Rails7、sqlite3 和 litestream組合Docker配置
rails7、sqlite3 和 litestream 在一起非常棒。我把我所有的迷你 webapps 都換成了它。這是你見過的最簡單的生產設定。這個 docker 檔案是將 Rails 應用程式投入生產所需的全部內容:
# Rails production setup via SQLite3 made durable by https://litestream.io/ # Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine. # # try locally: docker build . -t rails && docker run -p3000:3000 -it rails # # in production you might want to map /data to somewhere on the host, # but you don't have to! # FROM ruby:3.0.2 # use https://github.com/benbjohnson/litestream/releases/download/v0.3.7/litestream-v0.3.7-linux-amd64-static.tar.gz on intel ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.7/litestream-v0.3.7-linux-arm64-static.tar.gz /tmp/litestream.tar.gz RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz ENV RAILS_ENV 'production' ENV DB_PATH '/data/production.sqlite3' # find a REPLICA_URL host/keys setup for persisting your sqlite3 database ( https://litestream.io/guides/ ) # supports sftp, s3, azure, google cloud storage, backblaze, etc. you probably have an account # already ENV REPLICA_URL 's3://<your-url>/db.sqlite3' ENV LITESTREAM_ACCESS_KEY_ID '<your-access-key-id>' ENV LITESTREAM_SECRET_ACCESS_KEY '<your-secret-access-key>' # get dependencies WORKDIR /app ADD Gemfile /app/ ADD Gemfile.lock /app/ RUN bundle install # add code (and bundle) ADD . /app RUN bundle exec rake assets:precompile # rails expects production.sqlite3 to be in db/production.sqlite3 RUN ln -nfs $DB_PATH /app/db/production.sqlite3 EXPOSE 3000 CMD \ # if the db file doesn't exist we get it from the REPLICA_URL [ ! -f $DB_PATH ] && litestream restore -v -if-replica-exists -o $DB_PATH "${REPLICA_URL}" \ # then we run the migrations ; bundle exec rake db:migrate \ # then we launch replicate and execute rails server ; litestream replicate -exec "bundle exec rails server -p 3000" $DB_PATH $REPLICA_URL |
相關文章
- IT組合和專案組合管理(轉)
- Docker的組合優於繼承 - frankelDocker繼承
- 【力扣】組合總和3(組合的去重)力扣
- Docker 搭建多容器組合服務 (nginx + PHP)DockerNginxPHP
- 分解和組合的機器學習機器學習
- 分解和組合的抽象方法抽象
- 適合最新版docker自定義啟動配置Docker
- Docker配置容器位置和小技巧Docker
- docker配置前端和資料庫Docker前端資料庫
- JavaScript中的繼承和組合JavaScript繼承
- js的curry和函式組合JS函式
- VUE Cookbook 系列:實現可配置組合表單Vue
- Spring Boot 自動配置之組合註解Spring Boot
- 【數學】組合數學 - 排列組合
- 如何結合phpstorm配置在docker中的xdebugPHPORMDocker
- JS 函式式概念: 管道 和 組合JS函式
- 屬性動畫:基本使用和組合動畫動畫
- Docker中SQlite的配置和掛載DockerSQLite
- 機器學習之特徵組合:組合獨熱向量機器學習特徵
- 組合數學筆記-排列與組合筆記
- LeetCode 39. 組合總和 40.組合總和II 131.分割回文串LeetCode
- 組合模式模式
- MySQL組合索引和最左匹配原則MySql索引
- leetcode:組合總和II(回溯java)LeetCodeJava
- LeetCode-040-組合總和 IILeetCode
- Windows下組合快捷鍵和常見命令Windows
- Docker的ARG、ENV和.env配置完整指南Docker
- zabbix docker - 安裝和初始化配置Docker
- 使用sqlite3 模組操作sqlite3資料庫SQLite資料庫
- Python資料庫模組(sqlite3,SQLite3)Python資料庫SQLite
- JavaScript組合字串JavaScript字串
- 組合語言組合語言
- 組合模型初探模型
- 字串 全組合字串
- 組合數學
- Docker配置nginxDockerNginx
- Docker 源配置Docker
- MySQL單列索引和組合索引的區別MySql索引