Last active
August 19, 2021 18:07
-
-
Save hhff/158a3ac397eb66df6a98 to your computer and use it in GitHub Desktop.
Setting up Spree on Dokku via Digital Ocean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree API Server Needs | |
- Easy Setup & Deployment (Dokku) | |
- New Relic | |
- Error Monitoring (Raven) | |
- Performance Monitoring (Skylight) | |
- Logging (Loggly or Logentries?) | |
- SSL (Dokku handles this) | |
- Database Backups (http://donpottinger.net/blog/2014/11/22/bye-bye-heroku-hello-dokku-part-2.html (See Clockwork section)) | |
- Caching (Memcached + Dalli) | |
- Worker (Sidekiq) | |
- AWS S3 Storage | |
- SMTP Mailing (Mandrill) | |
http://donpottinger.net/blog/2014/11/17/bye-bye-heroku-hello-dokku.html | |
Prerequisites: | |
Domain | |
Digital Ocean Account | |
Spree Dokku | |
1. Login to Digital Ocean | |
2. Setup a new Droplet with | |
- at least 2GB of Memory (Otherwise you'll get build problems) | |
- IPv6 disabled | |
- your Local SSH Key | |
3. Ensure you add your SSH Key to the Droplet | |
4. Setup DNS To point to your Dokku IP | |
5. Navigate to your Dokku IP in Browser and Setup the Installer | |
6. SSH in & install Postgres | |
ssh root@[droplet ip] | |
cd /var/lib/dokku/plugins | |
git clone https://github.com/Kloadut/dokku-pg-plugin.git postgresql | |
dokku plugins-install | |
7. Exit SSH | |
8. git remote add dokku dokku@[droplet ip]:[app-name] | |
9. git push dokku master | |
10. Precompile should fail | |
11. Setup a Database for the app | |
ssh root@[droplet ip] | |
dokku postgresql:create [app-name] | |
dokku postgresql:link app-name app-name | |
12. Exit SSG | |
13. git push dokku master | |
14. App Deployed! | |
15. Install Spree | |
ssh root@[droplet ip] | |
dokku run spree rake db:migrate | |
dokku run spree rake db:seed | |
optional: | |
dokku run spree rake spree_sample:load | |
16. Setup SMTP Environment Variables: | |
dokku config:set [app name] SMTP_ADDRESS=smtp.mandrillapp.com SMTP_PORT=587 SMTP_DOMAIN=[app domain] SMTP_USERNAME=[mandrill user name] SMTP_PASSWORD=[mandrill api key] [email protected] | |
Optimisation | |
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 | |
Useful Plugins: | |
https://github.com/jezdez/dokku-memcached-plugin | |
(requires https://github.com/rlaneve/dokku-link) | |
https://github.com/mperham/dalli | |
SSL: | |
http://progrium.viewdocs.io/dokku/nginx | |
Cron / Workers: | |
https://github.com/bigboxsoftware/dokku-sidekiq | |
http://canuckistani.ca/running-worker-scripts-with-dokku/ | |
Database Backups: | |
https://gist.github.com/dommmel/f79d4d648517ef015682 | |
http://donpottinger.net/blog/2014/11/25/postgres-backups-with-dokku.html | |
Redis: | |
https://github.com/luxifer/dokku-redis-plugin | |
http://filipstefansson.com/2014/04/09/delayed_job_with_dokku_and_shoreman.html | |
Dokku / Docker Maintenance: | |
http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html | |
Continuous Delivery: | |
From Local Machine: | |
- ssh-keygen -t rsa | |
(leave passphrase blank) | |
cat ~/.ssh/id_rsa_circleci.pub | ssh root@[droplet ip] "sudo sshcommand acl-add dokku circleci" | |
cat ~/.ssh/id_rsa_circleci | |
Copy on-screen output (including ----BEGIN etc---- and ----END etc---- tags | |
Paste into CI (circle CI: https://circleci.com/gh/{{github org}}/{{github repo}}/edit#ssh | |
- hostname | |
Paste hostname as key hostname | |
Now, assuming your apps are named appropriately, you can do: | |
(in circle.yml) | |
deployment: | |
staging: | |
branch: staging | |
commands: | |
- git remote add staging dokku@[droplet ip]:staging | |
- git push staging staging:master | |
Testing Redis | |
redis-cli -h [app url] -p [public port] ping | |
CORS on S3 Bucket | |
Change | |
<AllowedOrigin>*</AllowedOrigin> | |
to: | |
<AllowedOrigin>http://*</AllowedOrigin> | |
<AllowedOrigin>https://*</AllowedOrigin> | |
Deploying DOKKU to Root | |
dokku domains:add production mydomain.com | |
### SSL | |
Generate a CSR (certificate signing request - from root#home in Dokku) | |
openssl req -new -newkey rsa:2048 -nodes -keyout [domain-name].key -out [domain-name].csr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment