Skip to content

Docker compose + ENV generator#2889

Open
atharvadeosthale wants to merge 1 commit intomainfrom
atharva/compose-generator
Open

Docker compose + ENV generator#2889
atharvadeosthale wants to merge 1 commit intomainfrom
atharva/compose-generator

Conversation

@atharvadeosthale
Copy link
Copy Markdown
Member

image

@appwrite
Copy link
Copy Markdown

appwrite bot commented Apr 14, 2026

Appwrite Website

Project ID: 69d7efb00023389e8d27

Sites (1)
Site Status Logs Preview QR
 website
69d7f2670014e24571ca
Failed Failed View Logs Preview URL QR Code

Website (appwrite/website)

Project ID: 684969cb000a2f6c0a02

Sites (1)
Site Status Logs Preview QR
 website
68496a17000f03d62013
Processing Processing View Logs Preview URL QR Code


Tip

Environment variables can be scoped per function or shared across your project

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 14, 2026

Greptile Summary

This PR adds an interactive Docker Compose + .env generator to the self-hosting installation page, letting users pick a database (MongoDB or MariaDB) and toggle the AI assistant before downloading or copying the generated files. There are several issues in the generated templates that need to be fixed before this ships to users.

  • _APP_DB_ADAPTER is duplicated in every service in the compose template (~15+ services), producing malformed output files with repeated environment entries throughout.
  • MongoDB service is missing restart: unless-stopped, so the database won't recover automatically from crashes — every other service in the compose has this policy.
  • MongoDB port 27017 is bound to the host, exposing the database outside the Docker network; MariaDB has no equivalent host-port mapping.

Confidence Score: 2/5

  • Not safe to merge — the generated compose template contains systematic duplicate env vars across every service, a missing restart policy on MongoDB, and an exposed database port that would affect every user who downloads the generated config.
  • Three P1 issues directly impact the correctness and security of the output files that users will download and run in production. The _APP_DB_ADAPTER duplication is a copy-paste error repeated across all 15+ services, the missing restart policy on MongoDB breaks self-healing, and the exposed port 27017 is a security risk for any cloud deployment.
  • src/lib/components/compose-generator/composeData.ts requires the most attention — all three critical issues are in this file.

Security Review

  • MongoDB port exposure (composeData.ts): The generated docker-compose.yml for MongoDB binds port 27017 to the host ("27017:27017"), making the database reachable from outside the Docker network. MariaDB has no equivalent host port mapping. Users deploying this template in a cloud environment with a permissive firewall would expose their database directly to the internet, even with auth enabled.

Important Files Changed

Filename Overview
src/lib/components/compose-generator/composeData.ts New file containing Docker Compose and .env templates; has three issues: _APP_DB_ADAPTER duplicated in every service's environment list (~15 services), MongoDB service missing restart: unless-stopped, and appwrite-mongodb-config volume declared but never mounted. Also exposes MongoDB port 27017 to the host.
src/markdoc/tags/Compose_Generator.svelte New Svelte component for interactive compose/env generator; the handleDownload function does not append the anchor element to the DOM before clicking, which silently breaks file downloads in Firefox.
src/markdoc/tags/_Module.svelte Exports the new Compose_Generator component to make it available as a markdoc tag — straightforward one-line addition.
src/routes/docs/advanced/self-hosting/installation/+page.markdoc Replaces the static "download config files" section with the new {% compose_generator %} tag and condenses the manual setup instructions into a cleaner 3-step guide.

Reviews (1): Last reviewed commit: "init generator" | Re-trigger Greptile

Comment on lines +216 to +222
- _APP_DB_ADAPTER
- _APP_DB_HOST
- _APP_DB_PORT
- _APP_DB_SCHEMA
- _APP_DB_USER
- _APP_DB_PASS
- _APP_DB_ADAPTER
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 _APP_DB_ADAPTER duplicated in every service environment list

_APP_DB_ADAPTER appears twice in the environment block of every service in the compose template. The duplicate occurs after _APP_DB_PASS in every service (e.g. lines 216 and 222 for appwrite, lines 352 and 358 for appwrite-realtime, and the same pattern repeats across all 15+ services). The generated docker-compose.yml will contain duplicate environment variable declarations throughout. While Docker Compose processes these without error, the output file is malformed and will confuse users.

The second occurrence (after _APP_DB_PASS) should be removed from every service block.

Comment on lines +30 to +35
- appwrite
volumes:
- appwrite-mongodb:/data/db
- appwrite-mongodb-keyfile:/data/keyfile
ports:
- "27017:27017"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 MongoDB service missing restart: unless-stopped

The MONGODB_SERVICE template does not include a restart policy, while every other service in the compose (including MARIADB_SERVICE) has restart: unless-stopped. Without this, MongoDB will not automatically restart after a crash or host reboot, leaving the entire Appwrite stack in a broken state.

Suggested change
- appwrite
volumes:
- appwrite-mongodb:/data/db
- appwrite-mongodb-keyfile:/data/keyfile
ports:
- "27017:27017"
const MONGODB_SERVICE = ` mongodb:
image: mongo:8.2.5
container_name: appwrite-mongodb
<<: *x-logging
restart: unless-stopped
networks:
- appwrite
volumes:
- appwrite-mongodb:/data/db
- appwrite-mongodb-keyfile:/data/keyfile
ports:
- "27017:27017"

Comment on lines +114 to +116
// __DB_BLOCK__ for the database service definition,
// __ASSISTANT_BLOCK__ for the optional assistant service,
// __DB_VOLUMES__ for database-specific volumes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 appwrite-mongodb-config volume declared but never mounted

MONGODB_VOLUMES declares appwrite-mongodb-config but the MONGODB_SERVICE only mounts appwrite-mongodb and appwrite-mongodb-keyfile. The config volume is created by Docker but never used, leading to an orphaned volume in the generated compose file.

Suggested change
// __DB_BLOCK__ for the database service definition,
// __ASSISTANT_BLOCK__ for the optional assistant service,
// __DB_VOLUMES__ for database-specific volumes.
const MONGODB_VOLUMES = ` appwrite-mongodb:
appwrite-mongodb-keyfile:`;

Comment on lines +34 to +35
ports:
- "27017:27017"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security MongoDB port 27017 exposed to host

The MongoDB service binds port 27017 to the host, making the database directly reachable from outside the Docker network. Unlike other services (e.g. MariaDB) which are only on the internal appwrite network with no host port mapping, this exposes the database to anyone who can reach the host. For a self-hosted production deployment, this is a significant attack surface even with authentication enabled.

Consider removing the ports block and relying on the internal appwrite network for connectivity.

Comment on lines +38 to +46
function handleDownload() {
const blob = new Blob([activeContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = activeFilename;
a.click();
URL.revokeObjectURL(url);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Download anchor not appended to DOM

The temporary anchor element is never appended to the document before .click() is called. While Chrome handles this fine, Firefox requires the element to be attached to the document for a programmatic click to trigger a file download. Without the append/remove steps the download will silently fail for Firefox users.

Suggested change
function handleDownload() {
const blob = new Blob([activeContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = activeFilename;
a.click();
URL.revokeObjectURL(url);
}
function handleDownload() {
const blob = new Blob([activeContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = activeFilename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant