@powersync/cli-plugin-docker 0.0.0-dev-20260305082615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +67 -0
- package/README.md +75 -0
- package/dist/DockerCommand.d.ts +7 -0
- package/dist/DockerCommand.js +7 -0
- package/dist/api/docker.d.ts +47 -0
- package/dist/api/docker.js +109 -0
- package/dist/commands/docker/configure.d.ts +13 -0
- package/dist/commands/docker/configure.js +182 -0
- package/dist/commands/docker/index.d.ts +12 -0
- package/dist/commands/docker/index.js +13 -0
- package/dist/commands/docker/reset.d.ts +11 -0
- package/dist/commands/docker/reset.js +37 -0
- package/dist/commands/docker/start.d.ts +11 -0
- package/dist/commands/docker/start.js +26 -0
- package/dist/commands/docker/stop.d.ts +14 -0
- package/dist/commands/docker/stop.js +44 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +4 -0
- package/dist/docker.d.ts +1 -0
- package/dist/docker.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/templates/bucket-storage/external/ExternalBucketStorageModule.d.ts +3 -0
- package/dist/templates/bucket-storage/external/ExternalBucketStorageModule.js +24 -0
- package/dist/templates/bucket-storage/postgres/PostgresBucketStorageModule.d.ts +3 -0
- package/dist/templates/bucket-storage/postgres/PostgresBucketStorageModule.js +58 -0
- package/dist/templates/bucket-storage/postgres/resources/init-scripts/01-storage-db.sql +2 -0
- package/dist/templates/bucket-storage/postgres/resources/postgres.storage.compose.yaml +26 -0
- package/dist/templates/main-compose.yaml +32 -0
- package/dist/templates/source-database/external/ExternalSourceDatabaseModule.d.ts +3 -0
- package/dist/templates/source-database/external/ExternalSourceDatabaseModule.js +30 -0
- package/dist/templates/source-database/postgres/PostgresSourceDatabaseModule.d.ts +3 -0
- package/dist/templates/source-database/postgres/PostgresSourceDatabaseModule.js +73 -0
- package/dist/templates/source-database/postgres/resources/init-scripts/.gitkeep +0 -0
- package/dist/templates/source-database/postgres/resources/init-scripts/01-powersync-publication.sql +15 -0
- package/dist/templates/source-database/postgres/resources/postgres.database.compose.yaml +27 -0
- package/dist/templates/templates-index.d.ts +2 -0
- package/dist/templates/templates-index.js +10 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +6 -0
- package/oclif.manifest.json +278 -0
- package/package.json +56 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Flags, ux } from '@oclif/core';
|
|
2
|
+
import { getDockerProjectName, runDockerComposeDown, runDockerComposeStop } from '../../docker.js';
|
|
3
|
+
import { DockerCommand } from '../../DockerCommand.js';
|
|
4
|
+
export default class DockerStop extends DockerCommand {
|
|
5
|
+
static description = 'Run `docker compose -p <project-name> stop` (containers are not removed by default). Does not require the project directory or a compose file, so you can run it from anywhere (e.g. after a reset conflict). Use --project-name or run from a project with cli.yaml to choose which project to stop. Use --remove to also remove the containers. Use --remove-volumes to also remove volumes (e.g. to re-run DB init scripts on next reset).';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %>',
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --project-name=powersync_myapp --remove'
|
|
9
|
+
];
|
|
10
|
+
static flags = {
|
|
11
|
+
...DockerCommand.flags,
|
|
12
|
+
'project-name': Flags.string({
|
|
13
|
+
description: 'Docker Compose project name to stop (e.g. powersync_myapp). If omitted and run from a project directory, uses plugins.docker.project_name from cli.yaml. Pass this to stop from any directory without loading the project.'
|
|
14
|
+
}),
|
|
15
|
+
remove: Flags.boolean({
|
|
16
|
+
default: false,
|
|
17
|
+
description: 'Remove containers after stopping (docker compose down). By default only stop (docker compose stop).'
|
|
18
|
+
}),
|
|
19
|
+
'remove-volumes': Flags.boolean({
|
|
20
|
+
default: false,
|
|
21
|
+
description: 'Remove named volumes (docker compose down -v). Use to reset database/storage so init scripts run again on next reset. Implies --remove.'
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
static summary = 'Stop a PowerSync Docker Compose project by name.';
|
|
25
|
+
async run() {
|
|
26
|
+
const { flags } = await this.parse(DockerStop);
|
|
27
|
+
let projectName = flags['project-name'];
|
|
28
|
+
if (projectName == null || projectName === '') {
|
|
29
|
+
const { projectDirectory } = this.loadProject(flags, {
|
|
30
|
+
configFileRequired: true
|
|
31
|
+
});
|
|
32
|
+
projectName = getDockerProjectName(projectDirectory) ?? undefined;
|
|
33
|
+
}
|
|
34
|
+
if (projectName == null || projectName === '') {
|
|
35
|
+
this.error(ux.colorize('red', 'Project name required. Pass --project-name=<name> or run from a project directory that has cli.yaml with plugins.docker.project_name.'), { exit: 1 });
|
|
36
|
+
}
|
|
37
|
+
if (flags['remove-volumes'] || flags.remove) {
|
|
38
|
+
runDockerComposeDown(projectName, { removeVolumes: flags['remove-volumes'] });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
runDockerComposeStop(projectName);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/docker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type DockerComposeOptions, getDockerProjectName, listPowersyncProjectNames, logPowersyncProjectsStopHelp, resolveComposePath, runDockerCompose, runDockerComposeDown, runDockerComposeStop } from './api/docker.js';
|
package/dist/docker.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDockerProjectName, listPowersyncProjectNames, logPowersyncProjectsStopHelp, resolveComposePath, runDockerCompose, runDockerComposeDown, runDockerComposeStop } from './api/docker.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Scalar } from 'yaml';
|
|
2
|
+
import { DockerModuleType } from '../../../types.js';
|
|
3
|
+
const ExternalBucketStorageModule = {
|
|
4
|
+
async apply(context) {
|
|
5
|
+
const { serviceConfig } = context;
|
|
6
|
+
context.command.log('Using external bucket storage. Set PS_STORAGE_SOURCE_URI in docker/.env to your PostgreSQL connection string before deploying.');
|
|
7
|
+
const uri = new Scalar('PS_STORAGE_SOURCE_URI');
|
|
8
|
+
uri.type = 'PLAIN';
|
|
9
|
+
uri.tag = '!env';
|
|
10
|
+
const storageConfig = {
|
|
11
|
+
sslmode: 'disable',
|
|
12
|
+
type: 'postgresql',
|
|
13
|
+
uri
|
|
14
|
+
};
|
|
15
|
+
serviceConfig.set('storage', storageConfig);
|
|
16
|
+
const additionalEnvironment = {
|
|
17
|
+
PS_STORAGE_SOURCE_URI: '<set-your-external-postgres-connection-string-in-env>'
|
|
18
|
+
};
|
|
19
|
+
return { additionalEnvironment };
|
|
20
|
+
},
|
|
21
|
+
name: 'external',
|
|
22
|
+
type: DockerModuleType.STORAGE
|
|
23
|
+
};
|
|
24
|
+
export default ExternalBucketStorageModule;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { isMap, Scalar } from 'yaml';
|
|
5
|
+
import { DockerModuleType } from '../../../types.js';
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const RESOURCES_DIR = path.join(__dirname, 'resources');
|
|
8
|
+
const PostgresBucketStorageModule = {
|
|
9
|
+
async apply(context) {
|
|
10
|
+
const { mainComposeDocument, modulesOutputDirectory, serviceConfig } = context;
|
|
11
|
+
const moduleOutputDirectory = path.join(modulesOutputDirectory, 'storage-postgres');
|
|
12
|
+
fs.mkdirSync(moduleOutputDirectory, { recursive: true });
|
|
13
|
+
const storageComposeFilePath = path.join(moduleOutputDirectory, 'postgres.storage.compose.yaml');
|
|
14
|
+
fs.copyFileSync(path.join(RESOURCES_DIR, 'postgres.storage.compose.yaml'), storageComposeFilePath);
|
|
15
|
+
const initScriptsSrc = path.join(RESOURCES_DIR, 'init-scripts');
|
|
16
|
+
const initScriptsDest = path.join(moduleOutputDirectory, 'init-scripts');
|
|
17
|
+
fs.mkdirSync(initScriptsDest, { recursive: true });
|
|
18
|
+
if (fs.existsSync(initScriptsSrc)) {
|
|
19
|
+
fs.cpSync(initScriptsSrc, initScriptsDest, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
const includePath = path.relative(context.composeOutputDirectory, storageComposeFilePath);
|
|
22
|
+
mainComposeDocument.get('include').add(includePath);
|
|
23
|
+
const servicesNode = mainComposeDocument.get('services');
|
|
24
|
+
if (isMap(servicesNode)) {
|
|
25
|
+
const powersyncServiceNode = servicesNode.get('powersync');
|
|
26
|
+
if (isMap(powersyncServiceNode)) {
|
|
27
|
+
const dependsOnNode = powersyncServiceNode.get('depends_on');
|
|
28
|
+
if (isMap(dependsOnNode)) {
|
|
29
|
+
dependsOnNode.set('pg-storage', { condition: 'service_healthy' });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const uri = new Scalar('PS_STORAGE_SOURCE_URI');
|
|
34
|
+
uri.type = 'PLAIN';
|
|
35
|
+
uri.tag = '!env';
|
|
36
|
+
const storageConfig = {
|
|
37
|
+
sslmode: 'disable',
|
|
38
|
+
type: 'postgresql',
|
|
39
|
+
uri
|
|
40
|
+
};
|
|
41
|
+
serviceConfig.set('storage', storageConfig);
|
|
42
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
43
|
+
const additionalEnvironment = {
|
|
44
|
+
PS_STORAGE_DATABASE: 'powersync_storage',
|
|
45
|
+
PS_STORAGE_PASSWORD: 'changeme',
|
|
46
|
+
PS_STORAGE_PORT: '5433',
|
|
47
|
+
PS_STORAGE_USER: 'postgres',
|
|
48
|
+
PS_STORAGE_SOURCE_URI:
|
|
49
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
50
|
+
'postgresql://${PS_STORAGE_USER}:${PS_STORAGE_PASSWORD}@pg-storage:${PS_STORAGE_PORT}/${PS_STORAGE_DATABASE}'
|
|
51
|
+
};
|
|
52
|
+
/* eslint-enable perfectionist/sort-objects */
|
|
53
|
+
return { additionalEnvironment };
|
|
54
|
+
},
|
|
55
|
+
name: 'postgres',
|
|
56
|
+
type: DockerModuleType.STORAGE
|
|
57
|
+
};
|
|
58
|
+
export default PostgresBucketStorageModule;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Storage module: PostgreSQL for PowerSync bucket metadata.
|
|
2
|
+
# Paths are relative to this file's directory when using include (Compose resolves from the included file).
|
|
3
|
+
# Include from main: path: modules/storage-postgres/postgres.storage.compose.yaml
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
pg-storage:
|
|
7
|
+
image: postgres:18
|
|
8
|
+
restart: always
|
|
9
|
+
environment:
|
|
10
|
+
- POSTGRES_USER=${PS_STORAGE_USER}
|
|
11
|
+
- POSTGRES_DB=${PS_STORAGE_DATABASE}
|
|
12
|
+
- POSTGRES_PASSWORD=${PS_STORAGE_PASSWORD}
|
|
13
|
+
- PGPORT=${PS_STORAGE_PORT}
|
|
14
|
+
volumes:
|
|
15
|
+
- pg_storage_data:/var/lib/postgresql
|
|
16
|
+
- ./init-scripts:/docker-entrypoint-initdb.d
|
|
17
|
+
ports:
|
|
18
|
+
- '${PS_STORAGE_PORT}:${PS_STORAGE_PORT}'
|
|
19
|
+
healthcheck:
|
|
20
|
+
test: ['CMD-SHELL', 'pg_isready -U ${PS_STORAGE_USER} -d ${PS_STORAGE_DATABASE}']
|
|
21
|
+
interval: 5s
|
|
22
|
+
timeout: 5s
|
|
23
|
+
retries: 5
|
|
24
|
+
|
|
25
|
+
volumes:
|
|
26
|
+
pg_storage_data:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Composed PowerSync Docker stack (generated by powersync docker configure).
|
|
2
|
+
# Modules add entries to include and to services.powersync.depends_on.
|
|
3
|
+
# Relative paths: . = powersync/docker, .. = powersync.
|
|
4
|
+
# Include syntax requires Docker Compose v2.20.3+
|
|
5
|
+
|
|
6
|
+
include: []
|
|
7
|
+
|
|
8
|
+
services:
|
|
9
|
+
powersync:
|
|
10
|
+
restart: unless-stopped
|
|
11
|
+
image: journeyapps/powersync-service:latest
|
|
12
|
+
command: ['start', '-r', 'unified']
|
|
13
|
+
env_file:
|
|
14
|
+
- .env
|
|
15
|
+
volumes:
|
|
16
|
+
- ../service.yaml:/config/service.yaml
|
|
17
|
+
- ../sync-config.yaml:/config/sync-config.yaml
|
|
18
|
+
environment:
|
|
19
|
+
POWERSYNC_CONFIG_PATH: /config/service.yaml
|
|
20
|
+
NODE_OPTIONS: --max-old-space-size=1000
|
|
21
|
+
healthcheck:
|
|
22
|
+
test:
|
|
23
|
+
- 'CMD'
|
|
24
|
+
- 'node'
|
|
25
|
+
- '-e'
|
|
26
|
+
- "fetch('http://localhost:${PS_PORT:-8080}/probes/liveness').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"
|
|
27
|
+
interval: 5s
|
|
28
|
+
timeout: 1s
|
|
29
|
+
retries: 15
|
|
30
|
+
ports:
|
|
31
|
+
- '${PS_PORT:-8080}:${PS_PORT:-8080}'
|
|
32
|
+
depends_on: {}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Scalar } from 'yaml';
|
|
4
|
+
import { DockerModuleType } from '../../../types.js';
|
|
5
|
+
const ExternalSourceDatabaseModule = {
|
|
6
|
+
async apply(context) {
|
|
7
|
+
const { projectDirectory, serviceConfig } = context;
|
|
8
|
+
context.command.log(ux.colorize('yellow', `Using external replication database. Set PS_DATA_SOURCE_URI in ${path.join(projectDirectory, 'docker', '.env')} to your PostgreSQL connection string before deploying.`));
|
|
9
|
+
const uri = new Scalar('PS_DATA_SOURCE_URI');
|
|
10
|
+
uri.type = 'PLAIN';
|
|
11
|
+
uri.tag = '!env';
|
|
12
|
+
const replicationConfig = {
|
|
13
|
+
connections: [
|
|
14
|
+
{
|
|
15
|
+
sslmode: 'disable',
|
|
16
|
+
type: 'postgresql',
|
|
17
|
+
uri
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
};
|
|
21
|
+
serviceConfig.set('replication', replicationConfig);
|
|
22
|
+
const additionalEnvironment = {
|
|
23
|
+
PS_DATA_SOURCE_URI: '<set-your-external-postgres-connection-string-in-env>'
|
|
24
|
+
};
|
|
25
|
+
return { additionalEnvironment };
|
|
26
|
+
},
|
|
27
|
+
name: 'external',
|
|
28
|
+
type: DockerModuleType.SOURCE_DATABASE
|
|
29
|
+
};
|
|
30
|
+
export default ExternalSourceDatabaseModule;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { isMap, Scalar } from 'yaml';
|
|
6
|
+
import { DockerModuleType } from '../../../types.js';
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const RESOURCES_DIR = path.join(__dirname, 'resources');
|
|
9
|
+
const PostgresSourceDatabaseModule = {
|
|
10
|
+
async apply(context) {
|
|
11
|
+
const { mainComposeDocument, modulesOutputDirectory, serviceConfig } = context;
|
|
12
|
+
context.command.log([
|
|
13
|
+
`${ux.colorize('yellow', 'Note')}: the Postgres database template is incomplete.`,
|
|
14
|
+
'Update docker/modules/database-postgres/init-scripts/ with your schema (tables and publication) before deploying.',
|
|
15
|
+
'Init scripts run only when the DB volume is empty. If you see "Publication powersync does not exist", run: ' +
|
|
16
|
+
ux.colorize('blue', 'powersync docker stop --remove --remove-volumes') +
|
|
17
|
+
' then ' +
|
|
18
|
+
ux.colorize('blue', 'powersync docker reset') +
|
|
19
|
+
' again.'
|
|
20
|
+
].join('\n'));
|
|
21
|
+
context.command.log('');
|
|
22
|
+
const moduleOutputDirectory = path.join(modulesOutputDirectory, 'database-postgres');
|
|
23
|
+
fs.mkdirSync(moduleOutputDirectory, { recursive: true });
|
|
24
|
+
const databaseComposeFilePath = path.join(moduleOutputDirectory, 'postgres.database.compose.yaml');
|
|
25
|
+
fs.copyFileSync(path.join(RESOURCES_DIR, 'postgres.database.compose.yaml'), databaseComposeFilePath);
|
|
26
|
+
const initScriptsSrc = path.join(RESOURCES_DIR, 'init-scripts');
|
|
27
|
+
const initScriptsDest = path.join(moduleOutputDirectory, 'init-scripts');
|
|
28
|
+
fs.mkdirSync(initScriptsDest, { recursive: true });
|
|
29
|
+
if (fs.existsSync(initScriptsSrc)) {
|
|
30
|
+
fs.cpSync(initScriptsSrc, initScriptsDest, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
const includePath = path.relative(context.composeOutputDirectory, databaseComposeFilePath);
|
|
33
|
+
mainComposeDocument.get('include').add(includePath);
|
|
34
|
+
const servicesNode = mainComposeDocument.get('services');
|
|
35
|
+
if (isMap(servicesNode)) {
|
|
36
|
+
const powersyncServiceNode = servicesNode.get('powersync');
|
|
37
|
+
if (isMap(powersyncServiceNode)) {
|
|
38
|
+
const dependsOnNode = powersyncServiceNode.get('depends_on');
|
|
39
|
+
if (isMap(dependsOnNode)) {
|
|
40
|
+
dependsOnNode.set('pg-db', { condition: 'service_healthy' });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const uri = new Scalar('PS_DATA_SOURCE_URI');
|
|
45
|
+
uri.type = 'PLAIN';
|
|
46
|
+
uri.tag = '!env';
|
|
47
|
+
const replicationConfig = {
|
|
48
|
+
connections: [
|
|
49
|
+
{
|
|
50
|
+
sslmode: 'disable',
|
|
51
|
+
type: 'postgresql',
|
|
52
|
+
uri
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
serviceConfig.set('replication', replicationConfig);
|
|
57
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
58
|
+
const additionalEnvironment = {
|
|
59
|
+
PS_DATABASE_NAME: 'postgres',
|
|
60
|
+
PS_DATABASE_PASSWORD: 'changeme',
|
|
61
|
+
PS_DATABASE_PORT: '5432',
|
|
62
|
+
PS_DATABASE_USER: 'postgres',
|
|
63
|
+
PS_DATA_SOURCE_URI:
|
|
64
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
65
|
+
'postgresql://${PS_DATABASE_USER}:${PS_DATABASE_PASSWORD}@pg-db:${PS_DATABASE_PORT}/${PS_DATABASE_NAME}'
|
|
66
|
+
};
|
|
67
|
+
/* eslint-enable perfectionist/sort-objects */
|
|
68
|
+
return { additionalEnvironment };
|
|
69
|
+
},
|
|
70
|
+
name: 'postgres',
|
|
71
|
+
type: DockerModuleType.SOURCE_DATABASE
|
|
72
|
+
};
|
|
73
|
+
export default PostgresSourceDatabaseModule;
|
|
File without changes
|
package/dist/templates/source-database/postgres/resources/init-scripts/01-powersync-publication.sql
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- PowerSync logical replication requires a PostgreSQL publication.
|
|
2
|
+
-- Create a publication named "powersync" that includes the tables
|
|
3
|
+
-- mentioned in your sync config (sync-config.yaml). This script uses
|
|
4
|
+
-- FOR ALL TABLES so any tables you create are replicated; for production
|
|
5
|
+
-- you may create a publication that lists only the tables used in sync-config.yaml.
|
|
6
|
+
--
|
|
7
|
+
-- Example for a single table: CREATE PUBLICATION powersync FOR TABLE my_table;
|
|
8
|
+
-- Example for multiple: CREATE PUBLICATION powersync FOR TABLE t1, t2, t3;
|
|
9
|
+
--
|
|
10
|
+
-- Note: Init scripts run only when the Postgres data directory is empty (first
|
|
11
|
+
-- container start). If you see "Publication 'powersync' does not exist", remove
|
|
12
|
+
-- the database volume and redeploy so init runs again, e.g.:
|
|
13
|
+
-- powersync docker stop --remove --remove-volumes && powersync docker reset
|
|
14
|
+
|
|
15
|
+
CREATE PUBLICATION powersync FOR ALL TABLES;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Database module: PostgreSQL for replication source (logical replication).
|
|
2
|
+
# Paths are relative to this file's directory when using include (Compose resolves from the included file).
|
|
3
|
+
# Include from main: path: modules/database-postgres/postgres.database.compose.yaml
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
pg-db:
|
|
7
|
+
image: postgres:18
|
|
8
|
+
restart: always
|
|
9
|
+
environment:
|
|
10
|
+
- POSTGRES_USER=${PS_DATABASE_USER}
|
|
11
|
+
- POSTGRES_DB=${PS_DATABASE_NAME}
|
|
12
|
+
- POSTGRES_PASSWORD=${PS_DATABASE_PASSWORD}
|
|
13
|
+
- PGPORT=${PS_DATABASE_PORT}
|
|
14
|
+
volumes:
|
|
15
|
+
- pg_data:/var/lib/postgresql
|
|
16
|
+
- ./init-scripts:/docker-entrypoint-initdb.d
|
|
17
|
+
ports:
|
|
18
|
+
- '${PS_DATABASE_PORT}:${PS_DATABASE_PORT}'
|
|
19
|
+
command: ['postgres', '-c', 'wal_level=logical']
|
|
20
|
+
healthcheck:
|
|
21
|
+
test: ['CMD-SHELL', 'pg_isready -U ${PS_DATABASE_USER} -d ${PS_DATABASE_NAME}']
|
|
22
|
+
interval: 5s
|
|
23
|
+
timeout: 5s
|
|
24
|
+
retries: 5
|
|
25
|
+
|
|
26
|
+
volumes:
|
|
27
|
+
pg_data:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DockerModuleType } from '../types.js';
|
|
2
|
+
import ExternalBucketStorageModule from './bucket-storage/external/ExternalBucketStorageModule.js';
|
|
3
|
+
import PostgresBucketStorageModule from './bucket-storage/postgres/PostgresBucketStorageModule.js';
|
|
4
|
+
import ExternalSourceDatabaseModule from './source-database/external/ExternalSourceDatabaseModule.js';
|
|
5
|
+
import PostgresSourceDatabaseModule from './source-database/postgres/PostgresSourceDatabaseModule.js';
|
|
6
|
+
export const TEMPLATES = {
|
|
7
|
+
[DockerModuleType.BACKEND]: [],
|
|
8
|
+
[DockerModuleType.SOURCE_DATABASE]: [PostgresSourceDatabaseModule, ExternalSourceDatabaseModule],
|
|
9
|
+
[DockerModuleType.STORAGE]: [PostgresBucketStorageModule, ExternalBucketStorageModule]
|
|
10
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Command } from '@oclif/core';
|
|
2
|
+
import type { Document } from 'yaml';
|
|
3
|
+
export declare enum DockerModuleType {
|
|
4
|
+
BACKEND = "backend",
|
|
5
|
+
SOURCE_DATABASE = "source_database",
|
|
6
|
+
STORAGE = "storage"
|
|
7
|
+
}
|
|
8
|
+
export type DockerModuleContext = {
|
|
9
|
+
/** Invoking command, for logging and output. */
|
|
10
|
+
command: Command;
|
|
11
|
+
/** Directory containing docker-compose.yaml (powersync/docker/). Used for relative include paths. */
|
|
12
|
+
composeOutputDirectory: string;
|
|
13
|
+
/** Main docker-compose document (docker/). Modules may add to include and services.powersync.depends_on. */
|
|
14
|
+
mainComposeDocument: Document;
|
|
15
|
+
modulesOutputDirectory: string;
|
|
16
|
+
projectDirectory: string;
|
|
17
|
+
serviceConfig: Document;
|
|
18
|
+
};
|
|
19
|
+
export type DockerModuleConfigResponse = {
|
|
20
|
+
additionalEnvironment?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
export type DockerModule = {
|
|
23
|
+
apply: (context: DockerModuleContext) => Promise<DockerModuleConfigResponse>;
|
|
24
|
+
name: string;
|
|
25
|
+
type: DockerModuleType;
|
|
26
|
+
};
|
package/dist/types.js
ADDED