Repository navigation
Expand file tree
/
Copy pathdeployment.yml
More file actions
138 lines (130 loc) · 6.96 KB
/
Copy pathdeployment.yml
File metadata and controls
138 lines (130 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# What every DocSpring Enterprise deployment runs. Each folder in this repository (docker-compose, kubernetes,
# aws-ecs, convox, aptible) implements this, and scripts/check_deployments fails CI when one of them drifts from it.
#
# People: the docs explain all of this at https://docspring.com/docs/enterprise/
# Agents: read AGENTS.md at the root of this repository first.
image:
# One multi-arch image (linux/amd64 and linux/arm64). Pulling a tag picks the right architecture.
repositories:
docker_hub: docspringcom/docspring-enterprise
ecr: 691950705664.dkr.ecr.us-east-1.amazonaws.com/docspring/enterprise
# <version> is the first 10 characters of the commit the image was built from, such as c648191044. Every release is
# listed at https://docspring.com/enterprise-releases. `latest` moves with each release: pin a version in production.
tags: ['<version>', '<version>-amd64', '<version>-arm64', latest]
platforms: [linux/amd64, linux/arm64]
# Both registries are private: DocSpring sends each customer their registry credentials with their license key.
# Every service and command starts with run_as_deploy, which runs it under tini as the unprivileged `deploy` user,
# after blocking the cloud metadata address (169.254.169.254) when the container has NET_ADMIN.
services:
web:
command: run_as_deploy puma -C config/puma.rb
port: 4001 # the PORT env var
health_checks:
# Answers once Rails has booted. Use it for liveness, readiness and load balancer target health.
liveness: /health/site
readiness: /health/site
# Also checks the database, Redis and the Rails cache: use it for uptime monitoring.
monitoring: /health
# Enterprise requests can run for 210 seconds (the Admin API's synchronous imports and exports), so give the load
# balancer or proxy at least 240 seconds, and allow request bodies up to 110 MB (template uploads).
request_timeout_seconds: 240
max_request_body: 110MB
# On a stop, Puma finishes the requests it's running (up to 215 seconds). Give it that long where the platform
# allows; where it allows less, a long request is cut off.
stop_grace_seconds: 240
recommended:
replicas: 2
memory: 1536Mi
cpu: 1000m
worker:
# Sidekiq: generates PDFs, runs the document tools (Chromium, LibreOffice, the PDF and image tools) inline,
# sends email and webhooks.
command: run_as_deploy sidekiq
# On a stop, Sidekiq finishes its jobs for 25 seconds, then puts the rest back on the queue.
stop_grace_seconds: 60
recommended:
replicas: 2
memory: 3072Mi
cpu: 1000m
worker_gj:
# GoodJob: account exports and imports (the Admin API). Its DATABASE_URL must be a direct database connection, not
# a pgbouncer transaction pool. Goes away when these jobs move to Sidekiq.
command: run_as_deploy good_job
stop_grace_seconds: 60
recommended:
replicas: 1
memory: 1024Mi
cpu: 500m
# Runs once before each release's services start (and on the first install, when it loads the database schema and
# creates the admin user from DOCSPRING_ADMIN_EMAIL and DOCSPRING_ADMIN_PASSWORD). Safe to run again. Like worker_gj,
# it needs a direct database connection.
release_command: run_as_deploy rake db:prepare
# The image decides what each of these runs, so a new release can add or remove tasks without a change here. Times are
# UTC; any time works, as long as each runs on its schedule. A run that's still going when the next starts makes the
# next one exit. That check is a PostgreSQL session lock, so like worker_gj they need a direct database connection.
scheduled_tasks:
hourly:
command: run_as_deploy rake timers:hourly
cron: '15 * * * *'
daily:
command: run_as_deploy rake timers:daily
cron: '0 3 * * *'
weekly:
command: run_as_deploy rake timers:weekly
cron: '0 4 * * 0'
container:
# Starts as root so run_as_deploy can add the firewall rule and switch to `deploy`; the app itself never runs as
# root. Don't set runAsNonRoot or a USER.
capabilities:
drop: [ALL]
# SETUID and SETGID switch to `deploy`. KILL lets a stop signal reach the app, so it finishes its requests and jobs
# before it exits.
add: [SETUID, SETGID, KILL]
# Lets run_as_deploy block the cloud metadata address (169.254.169.254), so nothing in the app can read the
# server's cloud credentials. Add it where the platform allows. Where it doesn't (AWS Fargate, Aptible, a
# Kubernetes namespace below the `privileged` Pod Security level), run_as_deploy logs a warning and carries on:
# block that address at the network level instead (a NetworkPolicy), or run where it isn't reachable (Fargate).
recommended_add: [NET_ADMIN]
allow_privilege_escalation: false
seccomp_profile: RuntimeDefault
read_only_root_filesystem: false
dependencies:
postgres: '14 or later (17 recommended)'
redis: '6.2 or later'
file_storage: 'An S3 bucket (any region), a Google Cloud Storage bucket, or a volume for one-server installs'
email: 'An SMTP server or Postmark, SendGrid, Mailgun or Amazon SES'
network:
inbound: 'HTTPS to the web service, through your load balancer or reverse proxy (it terminates TLS and sets X-Forwarded-Proto)'
outbound:
- host: api.docspring.com
port: 443
why: 'The license check, about once an hour (counts only: no documents, data or personal information)'
- host: 'your file storage, database, Redis and email service'
# The settings an install can't run without. Every other setting is optional:
# https://docspring.com/docs/enterprise/configuration/environment-variables/
environment:
required:
DATABASE_URL: 'postgres://user:password@host:5432/docspring'
REDIS_URL: 'redis://host:6379/0 (rediss:// for TLS)'
SECRET_KEY_BASE: 'openssl rand -hex 64'
DOCSPRING_SUBMISSION_DATA_ENCRYPTION_KEY: 'openssl rand -hex 32. Never change or lose it: it encrypts stored data'
DOCSPRING_LICENSE: 'Your license key'
DOCSPRING_DOMAIN_NAME: 'The host name people use, such as docspring.example.com'
first_install:
DOCSPRING_ADMIN_EMAIL: 'The first admin user, created by the release command on an empty database'
DOCSPRING_ADMIN_PASSWORD: 'Their password. Change it after you sign in'
file_storage:
s3:
DOCSPRING_AWS_UPLOADS_S3_BUCKET: 'The bucket'
DOCSPRING_AWS_UPLOADS_S3_REGION: 'Its region'
# Without these, the AWS SDK's default credentials are used: EKS Pod Identity, IRSA, an ECS task role, or
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Not an EC2 instance profile: run_as_deploy blocks the metadata
# address it's read from.
DOCSPRING_AWS_ACCESS_KEY_ID: 'Optional'
DOCSPRING_AWS_ACCESS_KEY_SECRET: 'Optional'
# The bucket needs a CORS rule for the app's origin: browsers upload template files straight to it.
s3_cors:
allowed_methods: [GET, PUT, POST]
allowed_headers: [Authorization, cache-control, x-requested-with, content-type]
allowed_origins: ['https://<DOCSPRING_DOMAIN_NAME>']
max_age_seconds: 3000