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 |
相關文章
- Python資料庫模組(sqlite3,SQLite3)Python資料庫SQLite
- Docker的組合優於繼承 - frankelDocker繼承
- 組合數字首和
- 【力扣】組合總和3(組合的去重)力扣
- Docker 搭建多容器組合服務 (nginx + PHP)DockerNginxPHP
- 如何結合phpstorm配置在docker中的xdebugPHPORMDocker
- 377. 組合總和 Ⅳ
- Docker配置容器位置和小技巧Docker
- docker配置前端和資料庫Docker前端資料庫
- HomeAssistantOS和docker的組織關係Docker
- Spring Boot 自動配置之組合註解Spring Boot
- LeetCode39. 組合總和LeetCode
- Docker中SQlite的配置和掛載DockerSQLite
- SQLite3原始碼學習(33) Pager模組中的相關問題和細節SQLite原始碼
- LeetCode 39. 組合總和 40.組合總和II 131.分割回文串LeetCode
- VUE Cookbook 系列:實現可配置組合表單Vue
- js的curry和函式組合JS函式
- leetcode:組合總和II(回溯java)LeetCodeJava
- LeetCode216.組合總和lllLeetCode
- LeetCode40.組合總和IILeetCode
- 組合語言-CALL和RET指令組合語言
- LeetCode-040-組合總和 IILeetCode
- JavaScript中的繼承和組合JavaScript繼承
- Docker和containerd服務配置國內源DockerAI
- Docker的ARG、ENV和.env配置完整指南Docker
- Day 26| 39. 組合總和 、 40.組合總和II 、 131.分割回文串
- docker下nginx反向代理和負載均衡配置DockerNginx負載
- Docker 日誌自動輪轉和清理配置Docker
- Ubuntu安裝和配置Docker-CE映象加速UbuntuDocker
- JS 函式式概念: 管道 和 組合JS函式
- Docker配置nginxDockerNginx
- docker配置代理Docker
- Docker 代理配置Docker
- Docker 源配置Docker
- 組合
- 【數學】組合數學 - 排列組合
- 配置docker和containerd,使用ca證書訪問harborDockerAI
- MySQL組合索引和最左匹配原則MySql索引