-
Notifications
You must be signed in to change notification settings - Fork 2
appdata
Application data can be divided as:
- code - files with code (models, libs). Stored in git repo. Maintained by developer and uploaded to server. Cannot be changed on the server directly.
- database - data in mysql.
- config - files with settings.
- content. Can be changed on the server. Includes:
- text files for pages/templates content, views.
- assets - CSS, JS files.
- images - as part of site design.
- user data - files uploaded by site users.
Storages:
- local - directory on the disk
- Git repository
- File storage accessible by SSH
Storages accessible by SSH. Usually used to store images, binary files.
We will store views (app/views) and assets (app/assets) in git repo.
-
Setup
-
create Git storage for storing views and assets -
ssh://git@github.com/myuser/site-data.git -
edit config
config/appdata/appdata.yml:
development:
<<: *default
content:
-
name: "views"
dirs:
- app/views
- app/assets
storage:
type: git
remote_repo: "ssh://git@github.com/myuser/site-data.git"
local_repo_dir: "/path/to/site/temp/repo-data"
remote_repo_ssh_key: "/path/to/key/id_rsa"
# ... other contents
production:
<<: *default
content:
-
name: "views"
dirs:
- app/views
- app/assets
storage:
type: git
remote_repo: "ssh://git@github.com/myuser/site-data.git"
local_repo_dir: "/path/to/site/temp/prod/repo-data"
remote_repo_ssh_key: "/path/to/key/id_rsa"
# ... other contents
Storage:
- remote_repo - Git repo
- local_repo_dir - path to directory for local cache
- remote_repo_ssh_key - ssh key (private key) used to access git repo
Operations:
- init storage
cap production deploy:appdata:setup
this will
-
create local directory ('local_repo_dir') and init git repo in it
-
save changes from local project to remote repo
RAILS_ENV=development rake appdata:save['views']
this will
-
setup local cache: create directory 'local_repo_dir' and init git repo
-
copy files ('dirs' option in content configs) from local project to the 'local_repo_dir'
-
git commit in the local repo
-
git push to the remote repo
-
get changes from the remote repo to the production server
name=views cap production deploy:appdata:server_update
- save changes from the production server to the remote repo
name=views cap production deploy:appdata:server_save
this will
-
git pullfrom remote git repo to local dirlocal_repo_dir -
copy files (rsync or copy) from the site folders (
dirsoption for content) to the local cache (directorylocal_repo_dir) -
git commitin the local git repo -
git pushfrom local git repo to remote repo -
get changes from remote repo to local project
RAILS_ENV=development rake appdata:update['views']
This will
- setup local cache: create folder for local cache
local_repo_dirand init git repo - git pull from remote repo
- copy all files from local cache to the project (including directories specified by
dirsoption)
-
Sync data stored in public/uploads folder.
-
Remote storage:
- it assumes that we have a storage accessible by SSH: 'mystorage.com:/data/repo-uploads'.
-
config/appdata/appdata.yml:
production:
<<: *default
content:
-
name: "uploads"
dirs:
- public/uploads
exclude:
- tmp
storage:
type: ssh
host: "mystorage.com"
ssh_port: 22
path: "/data/repo-uploads"
ssh_user: "myuser"
ssh_key: "/path/to/key/id_rsa"
#ssh_password: "mypwd"
Storage:
-
host - server name
-
ssh_port - ssh port. by default, 22
-
path - path on the remote storage
-
ssh_user - ssh username
-
ssh_password - ssh password
-
ssh_key - path to ssh key (private key) used to access storage
-
use ssh_key or ssh_password.
Operations:
- init
cap production deploy:appdata:setup
- save files from local project to the remote storage
RAILS_ENV=development rake appdata:save['uploads']
this will
-
rsync files from local project to the remote storage
-
get files from the remote storage to the server
name=uploads cap production deploy:appdata:server_update
- save files from the server to the remote storage
name=uploads cap production deploy:appdata:server_save
- get files from the remote storage to local project
RAILS_ENV=development rake appdata:update['uploads']