Skip to content

Docker instance: always install directus-sync after starting container #167

@bartrail

Description

@bartrail

Hi there,

don't know if it is a bug or if I am just doing it wrong. Maybe you guys can help me out :)

I run directus-sync with the provided docker image from tractr/directus-sync:11.6.1. Everything is booting up and working fine so far. But when I try to run any commands from outside like docker compose exec directus npx directus-sync help I get the prompt that directus-sync is not available and needs to be installed:

Need to install the following packages:
[email protected]
Ok to proceed? (y) 

I know that I can run the command like this docker compose exec directus npx --yes directus-sync help to install it without asking, but this feels wrong, as I would guess it is already installed in the provided image.

I also tried the custom docker image version with the same result.

But when directus-sync is installed, everything works as expected, I can pull and push configs, seeds etc. Sharing the database schema across the team. Everything works out well so far. I need to develop some custom directus extensions for my current project, so I am a bit worried why directus-sync is not installed after booting up the container as expected.

For completenes, this is my docker-compose.yml:

services:
  proxy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./docker/dev/Caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./docker/dev/Caddy/data:/data
      - caddy_config:/config

  directus:
    image: 'tractr/directus-sync:11.6.1'
#    build:
#      context: .
#      dockerfile: Dockerfile
    volumes:
      - './directus/uploads:/directus/uploads'
#      - './directus/extensions:/directus/extensions'
      - './directus/templates:/directus/templates'
      - './directus/config:/directus/directus-config'
      - './directus/directus-sync.config.json:/directus/directus-sync.config.json:ro'
      - './directus/directus-sync.config.dev.json:/directus/directus-sync.config.dev.json:ro'
      - './directus/directus-sync.config.staging.json:/directus/directus-sync.config.staging.json:ro'
    ports:
      - 8055:8055
    environment:
      - SERVICE_FQDN_DIRECTUS_8055
      - KEY=$SERVICE_BASE64_64_KEY
      - SECRET=${SERVICE_BASE64_64_SECRET}
      - 'ADMIN_EMAIL=${ADMIN_EMAIL:[email protected]}'
      - ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN}
      - DB_CLIENT=postgres
      - DB_HOST=postgresql
      - DB_PORT=5432
      - 'DB_DATABASE=${POSTGRESQL_DATABASE:-directus}'
      - DB_USER=$SERVICE_USER_POSTGRESQL
      - DB_PASSWORD=$SERVICE_PASSWORD_POSTGRESQL
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - WEBSOCKETS_ENABLED=true
      - EXTENSIONS_AUTO_RELOAD=true
      - MARKETPLACE_TRUST=all
      - QUERY_LIMIT_MAX=10000
    healthcheck:
      test:
        - CMD
        - wget
        - '-q'
        - '--spider'
        - 'http://127.0.0.1:8055/admin/login'
      interval: 5s
      timeout: 20s
      retries: 10
    depends_on:
      postgresql:
        condition: service_healthy
      redis:
        condition: service_healthy
  postgresql:
    image: 'postgis/postgis:16-3.4-alpine'
    platform: linux/amd64
    ports:
      - 5432:5432
    volumes:
      - 'directus-postgresql-data:/var/lib/postgresql/data'
    environment:
      - 'POSTGRES_USER=${SERVICE_USER_POSTGRESQL}'
      - 'POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRESQL}'
      - 'POSTGRES_DB=${POSTGRESQL_DATABASE:-directus}'
    healthcheck:
      test:
        - CMD-SHELL
        - 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'
      interval: 5s
      timeout: 20s
      retries: 10
  redis:
    image: 'redis:7-alpine'
    command: 'redis-server --appendonly yes'
    volumes:
      - 'directus-redis-data:/data'
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
      interval: 5s
      timeout: 20s
      retries: 10

volumes:
  caddy_data:
  caddy_config:
  directus-postgresql-data:
  directus-redis-data:

Some explanations:

The commented out line in volumes # - './directus/extensions:/directus/extensions' was a test because with the installation of directus-extension-sync - otherwise it would not work at all (see the screenshot)
Image

I guess that I can create my custom directus extensions in this directory and then mount it to the directus container - which would be missing out directus-extension-sync then..

It's a bit confusing :D At least for me..

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions