Skip to content

Commit

Permalink
fix(CLI): CLI support for Docker v2.24.6 by removing inheritance from…
Browse files Browse the repository at this point in the history
… docker-compose files (#1025)

Fixes #1018

This removes the inheritance from the docker compose files. There are
now two mostly duplicated compose files, with the "with-postgres" file
have this addition for the electric service:

```
depends_on:
      - postgres
```

Not pretty, but works and is far less likely to break with future
versions of Docker.
  • Loading branch information
samwillis committed Mar 4, 2024
1 parent 31384af commit 85daa6e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-peas-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electric-sql": patch
---

CLI support for Docker compose version 2.24.6 by removing inheritance from docker-compose files.
Original file line number Diff line number Diff line change
Expand Up @@ -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'}/${
Expand Down
9 changes: 8 additions & 1 deletion clients/typescript/src/cli/docker-commands/docker-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 85daa6e

Please sign in to comment.