|
| 1 | +# S3 Backend |
| 2 | + |
| 3 | +{{ extra.project }} supports S3 backend. This means that it can store |
| 4 | +document files in S3 storage. |
| 5 | + |
| 6 | +There are two parts to consider here: |
| 7 | + |
| 8 | +1. Documents upload to S3 storage |
| 9 | +2. Content delivery i.e. serving of document files |
| 10 | + |
| 11 | +The second part, content delivery, is about offloading document files delivery |
| 12 | +from {{ extra.project }} to CDN. Once files are served via CDN, `webapp` |
| 13 | +becomes stateless, which means you can have multiple instances of `webapp` |
| 14 | +and thus scale it as much as you have want. |
| 15 | + |
| 16 | + |
| 17 | +## Documents Upload to S3 Storage |
| 18 | + |
| 19 | +This scenario is straightforward - {{ extra.project }} will upload every |
| 20 | +document version to S3 storage. However, in this scenario |
| 21 | +{{ extra.project }} **serves documents from its local disk**. This works if |
| 22 | +and only if you have exactly one instance of webapp. |
| 23 | + |
| 24 | +If you change document version, {{ extra.project }} will upload changed version as well. |
| 25 | +If you delete a document, {{ extra.project }} will remove deleted document |
| 26 | +from S3 bucket as well. |
| 27 | + |
| 28 | +This setup is useful for small deployments accessible only to couple of users on |
| 29 | +local network. |
| 30 | + |
| 31 | +!!! Remember |
| 32 | + |
| 33 | + 1. This setup works only for one instance of `webapp` |
| 34 | + 2. In this scenario `webapp` is serving document files |
| 35 | + |
| 36 | +To make this work, you need to provide to S3 worker following settings: |
| 37 | + |
| 38 | +``` |
| 39 | +* PAPERMERGE__S3__BUCKET_NAME |
| 40 | +* AWS_REGION_NAME |
| 41 | +* AWS_ACCESS_KEY_ID |
| 42 | +* AWS_SECRET_ACCESS_KEY |
| 43 | +* S3_WORKER_ARGS should be set to "-Q s3 -c 2" |
| 44 | +``` |
| 45 | + |
| 46 | +Note that both `webapp` and `s3worker` need to have access same `PAPERMERGE__REDIS__URL` |
| 47 | +and `PAPERMERGE__DATABASE__URL`. |
| 48 | + |
| 49 | +Here is an example of docker compose file: |
| 50 | + |
| 51 | + |
| 52 | +```yaml |
| 53 | +services: |
| 54 | + webapp: |
| 55 | + image: papermerge/papermerge:{{ extra.docker_image_version }} |
| 56 | + environment: |
| 57 | + PAPERMERGE__SECURITY__SECRET_KEY: "random-sequence-of-characters" |
| 58 | + PAPERMERGE__AUTH__USERNAME: admin |
| 59 | + PAPERMERGE__AUTH__PASSWORD: 1234 |
| 60 | + PAPERMERGE__DATABASE__URL: postgresql://coco:jumbo@db:5432/pmgdb |
| 61 | + PAPERMERGE__MAIN__MEDIA_ROOT: /var/media/pmg |
| 62 | + PAPERMERGE__REDIS__URL: redis://redis:6379/0 |
| 63 | + ports: |
| 64 | + - "12000:80" |
| 65 | + depends_on: |
| 66 | + - db |
| 67 | + - redis |
| 68 | + volumes: |
| 69 | + - media_root:/var/media/pmg |
| 70 | + path_template_worker: |
| 71 | + image: papermerge/path-tmpl-worker:0.4 |
| 72 | + command: worker |
| 73 | + environment: |
| 74 | + PAPERMERGE__DATABASE__URL: postgresql://coco:jumbo@db:5432/pmgdb |
| 75 | + PAPERMERGE__REDIS__URL: redis://redis:6379/0 |
| 76 | + PATH_TMPL_WORKER_ARGS: "-Q path_tmpl -c 2" |
| 77 | + depends_on: |
| 78 | + - db |
| 79 | + - redis |
| 80 | + s3worker: |
| 81 | + image: papermerge/s3worker:{{ extra.s3_worker_version }} |
| 82 | + command: worker |
| 83 | + environment: |
| 84 | + PAPERMERGE__DATABASE__URL: postgresql://coco:jumbo@db:5432/pmgdb |
| 85 | + PAPERMERGE__REDIS__URL: redis://redis:6379/0 |
| 86 | + PAPERMERGE__MAIN__MEDIA_ROOT: /var/media/pmg |
| 87 | + PAPERMERGE__S3__BUCKET_NAME: p<your bucket name>l |
| 88 | + S3_WORKER_ARGS: "-Q s3 -c 2" |
| 89 | + AWS_REGION_NAME: eu-central-1 |
| 90 | + AWS_ACCESS_KEY_ID: A<your value here>L |
| 91 | + AWS_SECRET_ACCESS_KEY: s<your value here>j |
| 92 | + depends_on: |
| 93 | + - db |
| 94 | + - redis |
| 95 | + volumes: |
| 96 | + - media_root:/var/media/pmg |
| 97 | + db: |
| 98 | + image: postgres:16.1 |
| 99 | + volumes: |
| 100 | + - pgdata:/var/lib/postgresql/data/ |
| 101 | + environment: |
| 102 | + POSTGRES_PASSWORD: jumbo |
| 103 | + POSTGRES_DB: pmgdb |
| 104 | + POSTGRES_USER: coco |
| 105 | + healthcheck: |
| 106 | + test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB |
| 107 | + interval: 5s |
| 108 | + timeout: 10s |
| 109 | + retries: 5 |
| 110 | + start_period: 10s |
| 111 | + redis: |
| 112 | + image: bitnami/redis:7.2 |
| 113 | + ports: |
| 114 | + - "6379:6379" |
| 115 | + environment: |
| 116 | + ALLOW_EMPTY_PASSWORD: "yes" |
| 117 | +volumes: |
| 118 | + pgdata: |
| 119 | + media_root: |
| 120 | +``` |
| 121 | +
|
| 122 | +
|
| 123 | +## Content Delivery |
| 124 | +
|
| 125 | +docs: work in progress |
0 commit comments