diff --git a/.changeset/blue-peas-tie.md b/.changeset/blue-peas-tie.md new file mode 100644 index 0000000000..a2d2142207 --- /dev/null +++ b/.changeset/blue-peas-tie.md @@ -0,0 +1,5 @@ +--- +"electric-sql": patch +--- + +CLI support for Docker compose version 2.24.6 by removing inheritance from docker-compose files. diff --git a/clients/typescript/src/cli/docker-commands/command-start.ts b/clients/typescript/src/cli/docker-commands/command-start.ts index a197c8d61c..d8cae31772 100644 --- a/clients/typescript/src/cli/docker-commands/command-start.ts +++ b/clients/typescript/src/cli/docker-commands/command-start.ts @@ -68,7 +68,6 @@ export function start(options: StartSettings) { ...(options.withPostgres ? { COMPOSE_PROFILES: 'with-postgres', - COMPOSE_ELECTRIC_SERVICE: 'electric-with-postgres', DATABASE_URL: `postgresql://postgres:${ env?.DATABASE_PASSWORD ?? 'pg_password' }@postgres:${env?.DATABASE_PORT ?? '5432'}/${ diff --git a/clients/typescript/src/cli/docker-commands/docker-utils.ts b/clients/typescript/src/cli/docker-commands/docker-utils.ts index 73b21c40a2..2e9dca755f 100644 --- a/clients/typescript/src/cli/docker-commands/docker-utils.ts +++ b/clients/typescript/src/cli/docker-commands/docker-utils.ts @@ -8,18 +8,25 @@ const composeFile = path.join( 'compose.yaml' ) +const composeFileWithPostgres = path.join( + path.dirname(fileURLToPath(import.meta.url)), + 'docker', + 'compose-with-postgres.yaml' +) + export function dockerCompose( command: string, userArgs: string[] = [], containerName?: string, env: { [key: string]: string } = {} ) { + const withPostgres = env?.COMPOSE_PROFILES == 'with-postgres' const args = [ 'compose', '--ansi', 'always', '-f', - composeFile, + withPostgres ? composeFileWithPostgres : composeFile, command, ...userArgs, ] diff --git a/clients/typescript/src/cli/docker-commands/docker/compose-base.yaml b/clients/typescript/src/cli/docker-commands/docker/compose-base.yaml deleted file mode 100644 index 49bcee0391..0000000000 --- a/clients/typescript/src/cli/docker-commands/docker/compose-base.yaml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.8' - -services: - electric-no-postgres: - init: true - stop_signal: SIGINT # use SIGINT as the more speedy alternative to SIGTERM - - electric-with-postgres: - extends: - service: electric-no-postgres - depends_on: - - postgres diff --git a/clients/typescript/src/cli/docker-commands/docker/compose-with-postgres.yaml b/clients/typescript/src/cli/docker-commands/docker/compose-with-postgres.yaml new file mode 100644 index 0000000000..5cb4da4bdc --- /dev/null +++ b/clients/typescript/src/cli/docker-commands/docker/compose-with-postgres.yaml @@ -0,0 +1,64 @@ +version: '3.8' + +configs: + postgres_config: + file: './postgres.conf' + +volumes: + pg_data: + +services: + postgres: + profiles: ['with-postgres'] + image: '${POSTGRESQL_IMAGE:-postgres:14-alpine}' + environment: + POSTGRES_DB: ${DATABASE_NAME:-electric} + POSTGRES_USER: ${DATABASE_USER:-postgres} + POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-db_password} + command: + - -c + - config_file=/etc/postgresql.conf + - -p + - ${DATABASE_PORT:-5432} + configs: + - source: postgres_config + target: /etc/postgresql.conf + healthcheck: + test: + [ + 'CMD-SHELL', + 'pg_isready -U ${DATABASE_USER:-postgres} -p ${DATABASE_PORT:-5432}', + ] + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - ${DATABASE_PORT:-5432}:${DATABASE_PORT:-5432} + volumes: + - pg_data:/var/lib/postgresql/data + + electric: + image: '${ELECTRIC_IMAGE:-electricsql/electric:latest}' + init: true + stop_signal: SIGINT # use SIGINT as the more speedy alternative to SIGTERM + ports: + - ${HTTP_PORT:-5133}:${HTTP_PORT:-5133} + - ${PG_PROXY_PORT_PARSED:-65432}:${PG_PROXY_PORT_PARSED:-65432} + environment: + DATABASE_REQUIRE_SSL: ${DATABASE_REQUIRE_SSL:-} + DATABASE_URL: ${DATABASE_URL:-} + DATABASE_USE_IPV6: ${DATABASE_USE_IPV6:-} + ELECTRIC_USE_IPV6: ${ELECTRIC_USE_IPV6:-} + HTTP_PORT: ${HTTP_PORT:-5133} + ELECTRIC_WRITE_TO_PG_MODE: ${ELECTRIC_WRITE_TO_PG_MODE:-} + LOGICAL_PUBLISHER_HOST: ${LOGICAL_PUBLISHER_HOST:-} + LOGICAL_PUBLISHER_PORT: ${LOGICAL_PUBLISHER_PORT:-5433} + PG_PROXY_PASSWORD: ${PG_PROXY_PASSWORD:-proxy_password} + PG_PROXY_PORT: ${PG_PROXY_PORT:-65432} + AUTH_MODE: ${AUTH_MODE:-insecure} + AUTH_JWT_ALG: ${AUTH_JWT_ALG:-} + AUTH_JWT_AUD: ${AUTH_JWT_AUD:-} + AUTH_JWT_ISS: ${AUTH_JWT_ISS:-} + AUTH_JWT_KEY: ${AUTH_JWT_KEY:-} + AUTH_JWT_NAMESPACE: ${AUTH_JWT_NAMESPACE:-} + depends_on: + - postgres diff --git a/clients/typescript/src/cli/docker-commands/docker/compose.yaml b/clients/typescript/src/cli/docker-commands/docker/compose.yaml index ff6104e087..dfd8f40ccd 100644 --- a/clients/typescript/src/cli/docker-commands/docker/compose.yaml +++ b/clients/typescript/src/cli/docker-commands/docker/compose.yaml @@ -37,10 +37,9 @@ services: - pg_data:/var/lib/postgresql/data electric: - extends: - file: compose-base.yaml - service: ${COMPOSE_ELECTRIC_SERVICE:-electric-no-postgres} image: '${ELECTRIC_IMAGE:-electricsql/electric:latest}' + init: true + stop_signal: SIGINT # use SIGINT as the more speedy alternative to SIGTERM ports: - ${HTTP_PORT:-5133}:${HTTP_PORT:-5133} - ${PG_PROXY_PORT_PARSED:-65432}:${PG_PROXY_PORT_PARSED:-65432}