Conventions
Conventions
Section titled “Conventions”Terminology
Section titled “Terminology”- local vs remote: terms signaling location, where local is the local workstation (i.e. docker running locally), remote is at a hosting provider
- dev vs prod: terms signaling the purpose of the deployment. AKA the “environment,” though I want to call out what the environment is for vs where it lives. In practice “dev” will be synonymous with “local” and “prod” with “remote.” There’s no “staging” or “uat,” given I’m going for simplicity, but supporting other remote environments could be a thing in the future.
Practices
Section titled “Practices”- prefer keep local and remote paths the same when possible
- e.g. for bind mounts like daps
dockerand projects’_dockerfolders, or Caddyfile inside a caddy folder instead of in the root
- e.g. for bind mounts like daps
- prefer not to copy files to central daps if possible
- e.g.
caddy_sitesare copied centrally because I don’t think it would work otherwise, but docker compose files don’t need to be copied to a central dapsdockerfolder
- e.g.
daps.yaml
Section titled “daps.yaml”Configuration file for daps
- providers section
- remote host info
- projects section
- contains settings for each project
- most project settings should be discoverable by convention, but just knowing the project exists is the least info needed in this file
Docker compose filenames
Section titled “Docker compose filenames”compose_daps.yamlcompose_projectname.yaml- used by both dev and prod
- appears first when executing compose
- daps files are composed first
compose_daps.dev.yamlcompose_projectname.dev.yaml- used only by dev
compose_daps_projectname.yaml- executed when composing daps
- used to bind mount project folders to the toolkit
- should only be for dev(?)
compose_daps.prod.yamlcompose_projectname.prod.yaml- used only by prod
Docker compose file locations
Section titled “Docker compose file locations”compose_daps.yamlcompose_daps.dev.yamlcompose_daps.prod.yaml- in the daps project folder, inside folder named
docker
- in the daps project folder, inside folder named
compose_projectname.yamlcompose_projectname.dev.yamlcompose_projectname.prod.yamlcompose_daps_projectname.yaml- in project folder, inside folder named
_docker - underscore is to alphabetize it “out of the way” of the project source
- during compose, should be read from this location (i.e. not copied elsewhere first)
- in project folder, inside folder named
Docker folders
Section titled “Docker folders”docker- in daps project root
_docker- in project root
- underscore is to alphabetize it “out of the way” of the project source
- the underscore should be maintained in bind mounts (as in, don’t bind
projectname/_dockerto/srv/projects/projectname/dockerbut to/srv/projects/projectname/_docker)
Docker context
Section titled “Docker context”- for local deployment, docker runs on your local workstation
- for remote deployment, docker runs on the remote VM (e.g. an OpenStack instance or a generic VPS)
- for building images, docker runs on the local workstation to save on compute costs, assuming you’re charged for those on the remote VM
A note on docker paths
Section titled “A note on docker paths”- Write project compose files assuming paths are relative to the compose file directory (
_docker). - Avoid relying on current shell working directory.
- dapsman uses
-f <absolute path>when generating a docker compose command. compose_daps_projectname.yamlfiles need paths relative to wherecompose_daps.yamllives- e.g.
../../projectname/_docker:/srv/projects/projectname/_docker - longer-term dapsman should generate absolute paths from daps.yaml project paths
- e.g.
Project scripts
Section titled “Project scripts”- Project scripts for use with daps appear in a folder
_scripts(the underscore alphabetizes them away from the main project files) build-docker-images.toolkit.shdaps will look for this file for instructions for building container images for the project.
Caddy files
Section titled “Caddy files”Caddyfile- located in
caddyfolder for dev, VM’s/srv/daps/caddy/folder for prod - both locations are bind-mounted identically in
compose_daps.yaml- why bind mount it? We might want to change it while deployed, e.g. to set it http only for testing, or to set up maintenance redirects or something
- no setup inside, only imports files (
*.caddy) fromcaddy_sitesfolder
- located in
project.dev.caddy- file to be copied into
caddy_sitesfolder for dev
- file to be copied into
project.prod.caddy- file to be copied into
caddy_sitesfolder for prod
- file to be copied into
Caddy folders
Section titled “Caddy folders”caddy- located in daps project root
- contains
Caddyfile
caddy_sites(dev)- located in daps root
- should be empty for daps in git (or .gitignored) — will receive files copied from projects
- for prod a folder should be created with project files copied into it
- should be bind-mounted from caddy container — to
daps/caddy_sitesin dev, to VMcaddy_sitesin prod
caddy_sites(prod)- located in VM (openstack)
/srv/daps/caddy_sites - bind mounted (readonly) from caddy
/etc/caddy/sites
- located in VM (openstack)
_caddy_sites- located in project root
- underscore is to alphabetize it “out of the way” of the project source
- contains caddy config to be imported by
Caddyfile
Hosting folder and files
Section titled “Hosting folder and files”hosting- located in daps project root
- contains files specific to a particular hosting provider, to separate provider-specific configuration from generic scripts
- can include files for multiple hosting providers
- for OpenStack providers: OpenRC file and instance vars file
- for generic-vps providers: no files needed (hostname and user live directly in
daps.yaml)
- openrc file
- the openrc filename is not restricted by convention, since typically you download this file from the OpenStack provider
- if the name given at download is too generic, lean toward
<providername>_openrc(e.g.ramnode_openrcwhere RamNode is a hosting company)
openstack_providername_instance_vars.sh- variables describing OpenStack “flavor,” “image” and “network” IDs which are specific to the hosting provider
- this file is read/write, meaning we should allow Dapsman to write to it if/when we can support an interactive setup workflow. One can also just update it directly
Backup folders and scripts
Section titled “Backup folders and scripts”_backups- located in project root
- underscore is to alphabetize it “out of the way” of the project source
- created automatically when a backup is run; should be gitignored (may contain database dumps, uploaded files, or other sensitive data)
- backups from prod are placed in
_backups/from_prod/ - the toolkit container accesses this folder via the project’s bind mount (same path as other
_folders)
_scripts/backup-remote.toolkit.sh- optional; daps skips the backup workflow for projects that don’t have this script
- runs inside the toolkit container (never uploaded to the remote)
- receives env vars:
DAPS_PROJECT,DAPS_REMOTE_HOST,DAPS_REMOTE_USER,DAPS_SSH_KEY - receives args:
--env prod --to <destination-path-in-toolkit>
OpenStack resources
Section titled “OpenStack resources”- keys
- we’ll need a security key to access the OpenStack instance/VM. Naming convention is
daps-key-providername(e.g.daps-key-dreamcompute) for both the OpenStack key and the ssh key that goes with it (saved in toolkit’s/root/.ssh)
- we’ll need a security key to access the OpenStack instance/VM. Naming convention is
- instance name
- to start we only support one instance for any OpenStack host, but might want to add support for more later
- default name should be
daps-environmentwhereprodis the assumed environment for remote daps deployments. Again, might want to support others later - should be able to override instance name in the daps.yaml file
Remote VM
Section titled “Remote VM”On the remote openstack instance or whichever VM we’re running docker on, we will also have conventions.
- folder locations
/srv/daps/caddy/Caddyfile- copy the Caddyfile.prod heredocker/- copy daps shared and prod compose files
/srv/projects/projectname/_docker/- copy project daps-linked, shared and prod compose filesprojectname/_docker/image-exports- copy built docker image tars here