add dcusr outline, add socs dir (#50)
This commit is contained in:
		
							parent
							
								
									c06d80fc63
								
							
						
					
					
						commit
						3f0ae5d23b
					
				
					 6 changed files with 197 additions and 0 deletions
				
			
		
							
								
								
									
										50
									
								
								jobs/socs/dcusr-outline-backup.hcl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								jobs/socs/dcusr-outline-backup.hcl
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,50 @@
 | 
				
			||||||
 | 
					job "dcusr-outline-backup" {
 | 
				
			||||||
 | 
					  datacenters = ["aperture"]
 | 
				
			||||||
 | 
					  type        = "batch"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  periodic {
 | 
				
			||||||
 | 
					    crons            = ["0 */3 * * * *"]
 | 
				
			||||||
 | 
					    prohibit_overlap = true
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  group "db-backup" {
 | 
				
			||||||
 | 
					    task "postgres-backup" {
 | 
				
			||||||
 | 
					      driver = "raw_exec"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      config {
 | 
				
			||||||
 | 
					        command = "/bin/bash"
 | 
				
			||||||
 | 
					        args    = ["local/script.sh"]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      template {
 | 
				
			||||||
 | 
					        data        = <<EOH
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					file=/storage/backups/nomad/postgres/dcusr/outline/postgresql-outline-$(date +%Y-%m-%d_%H-%M-%S).sql
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mkdir -p /storage/backups/nomad/postgres/dcusr/outline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					alloc_id=$(nomad job status dcusr-outline | grep running | tail -n 1 | cut -d " " -f 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					job_name=$(echo ${NOMAD_JOB_NAME} | cut -d "/" -f 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nomad alloc exec -task outline-db $alloc_id pg_dumpall -U {{ key "outline/db/username" }} > "${file}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find /storage/backups/nomad/postgres/dcusr/outline/postgresql-outline* -ctime +3 -exec rm {} \; || true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -s "$file" ]; then # check if file exists and is not empty
 | 
				
			||||||
 | 
					  echo "Backup successful"
 | 
				
			||||||
 | 
					  exit 0
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  rm $file
 | 
				
			||||||
 | 
					  curl -H "Content-Type: application/json" -d \
 | 
				
			||||||
 | 
					  '{"content": "<@&585512338728419341> `PostgreSQL` backup for **'"${job_name}"'** has just **FAILED**\nFile name: `'"$file"'`\nDate: `'"$(TZ=Europe/Dublin date)"'`\nTurn off this script with `nomad job stop '"${job_name}"'` \n\n## Remember to restart this backup job when fixed!!!"}' \
 | 
				
			||||||
 | 
					  {{ key "postgres/webhook/discord" }}
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					EOH
 | 
				
			||||||
 | 
					        destination = "local/script.sh"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										147
									
								
								jobs/socs/dcusr-outline.hcl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								jobs/socs/dcusr-outline.hcl
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,147 @@
 | 
				
			||||||
 | 
					job "dcusr-outline" {
 | 
				
			||||||
 | 
					  datacenters = ["aperture"]
 | 
				
			||||||
 | 
					  type        = "service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  meta {
 | 
				
			||||||
 | 
					    domain = "outline.solarracing.ie"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  group "outline" {
 | 
				
			||||||
 | 
					    network {
 | 
				
			||||||
 | 
					      # mode = "bridge"
 | 
				
			||||||
 | 
					      port "http" {
 | 
				
			||||||
 | 
					        static = 3000
 | 
				
			||||||
 | 
					        to     = 3000
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      port "db" {
 | 
				
			||||||
 | 
					        to = 5432
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      port "redis" {
 | 
				
			||||||
 | 
					        to = 6379
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    service {
 | 
				
			||||||
 | 
					      name = "outline"
 | 
				
			||||||
 | 
					      port = "http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      check {
 | 
				
			||||||
 | 
					        type     = "http"
 | 
				
			||||||
 | 
					        path     = "/"
 | 
				
			||||||
 | 
					        interval = "10s"
 | 
				
			||||||
 | 
					        timeout  = "2s"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      tags = [
 | 
				
			||||||
 | 
					        "traefik.enable=true",
 | 
				
			||||||
 | 
					        "traefik.port=${NOMAD_PORT_http}",
 | 
				
			||||||
 | 
					        "traefik.http.routers.dcusr-outline.rule=Host(`${NOMAD_META_domain}`)",
 | 
				
			||||||
 | 
					        "traefik.http.routers.dcusr-outline.tls=true",
 | 
				
			||||||
 | 
					        "traefik.http.routers.dcusr-outline.tls.certresolver=lets-encrypt",
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    task "app" {
 | 
				
			||||||
 | 
					      driver = "docker"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      config {
 | 
				
			||||||
 | 
					        image = "docker.getoutline.com/outlinewiki/outline:latest"
 | 
				
			||||||
 | 
					        ports = ["http"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        volumes = [
 | 
				
			||||||
 | 
					          "/storage/nomad/outline/data:/var/lib/outline/data"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      resources {
 | 
				
			||||||
 | 
					        cpu    = 1000
 | 
				
			||||||
 | 
					        memory = 500
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      template {
 | 
				
			||||||
 | 
					        data        = <<EOH
 | 
				
			||||||
 | 
					NODE_ENV=production
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SECRET_KEY={{ key "outline/secret/key" }}
 | 
				
			||||||
 | 
					UTILS_SECRET={{ key "outline/secret/utils" }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DATABASE_URL=postgres://{{ key "outline/db/username" }}:{{ key "outline/db/password" }}@{{ env "NOMAD_ADDR_db" }}/{{ key "outline/db/name" }}
 | 
				
			||||||
 | 
					DATABASE_CONNECTION_POOL_MIN=
 | 
				
			||||||
 | 
					DATABASE_CONNECTION_POOL_MAX=
 | 
				
			||||||
 | 
					# Uncomment this to disable SSL for connecting to Postgres
 | 
				
			||||||
 | 
					PGSSLMODE=disable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					REDIS_URL=redis://{{ env "NOMAD_ADDR_redis" }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					URL=https://{{ env "NOMAD_META_domain" }}
 | 
				
			||||||
 | 
					PORT=3000
 | 
				
			||||||
 | 
					COLLABORATION_URL=https://{{ env "NOMAD_META_domain" }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FILE_STORAGE=local
 | 
				
			||||||
 | 
					FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Maximum allowed size for the uploaded attachment.
 | 
				
			||||||
 | 
					FILE_STORAGE_UPLOAD_MAX_SIZE=262144000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GOOGLE_CLIENT_ID     = "{{ key "outline/google/client/id" }}"
 | 
				
			||||||
 | 
					GOOGLE_CLIENT_SECRET = "{{ key "outline/google/client/secret" }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FORCE_HTTPS = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENABLE_UPDATES = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WEB_CONCURRENCY = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEBUG = http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# error, warn, info, http, verbose, debug and silly
 | 
				
			||||||
 | 
					LOG_LEVEL=info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SMTP_HOST       = "{{ key "outline/smtp/host" }}"
 | 
				
			||||||
 | 
					SMTP_PORT       = "{{ key "outline/smtp/port" }}"
 | 
				
			||||||
 | 
					SMTP_USERNAME   = "{{ key "outline/smtp/username" }}"
 | 
				
			||||||
 | 
					SMTP_PASSWORD   = "{{ key "outline/smtp/password" }}"
 | 
				
			||||||
 | 
					SMTP_FROM_EMAIL = "{{ key "outline/smtp/from" }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFAULT_LANGUAGE=en_US
 | 
				
			||||||
 | 
					EOH
 | 
				
			||||||
 | 
					        destination = "local/.env"
 | 
				
			||||||
 | 
					        env         = true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    task "outline-redis" {
 | 
				
			||||||
 | 
					      driver = "docker"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      config {
 | 
				
			||||||
 | 
					        image = "redis:latest"
 | 
				
			||||||
 | 
					        ports = ["redis"]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    task "outline-db" {
 | 
				
			||||||
 | 
					      driver = "docker"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      config {
 | 
				
			||||||
 | 
					        image = "postgres:alpine"
 | 
				
			||||||
 | 
					        ports = ["db"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        volumes = [
 | 
				
			||||||
 | 
					          "/storage/nomad/outline/postgres:/var/lib/postgresql/data"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      template {
 | 
				
			||||||
 | 
					        data        = <<EOH
 | 
				
			||||||
 | 
					POSTGRES_DB       = "{{ key "outline/db/name" }}"
 | 
				
			||||||
 | 
					POSTGRES_USER     = "{{ key "outline/db/username" }}"
 | 
				
			||||||
 | 
					POSTGRES_PASSWORD = "{{ key "outline/db/password" }}"
 | 
				
			||||||
 | 
					EOH
 | 
				
			||||||
 | 
					        destination = "local/db.env"
 | 
				
			||||||
 | 
					        env         = true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in a new issue