Terrastories / terrastories

Terrastories is a geostorytelling application for mapping, managing and sharing place-based stories.
https://terrastories.app
MIT License
319 stars 157 forks source link

[Bug][Docker] Getting Terrastories working with Docker Compose V2; invalid compose project error #695

Closed rudokemper closed 2 years ago

rudokemper commented 3 years ago

Describe the bug With the latest version of Docker Desktop (Windows) which uses Docker Compose V2, trying to build Terrastories results in the following error: service "extensions" has neither an image nor a build context specified: invalid compose project

We can avoid this error by unchecking "Use Docker Compose V2" in the Docker settings, but since docker-compose (v1) will eventually be deprecated, we should figure out how to get Terrastories working with Docker Compose V2.

Upon initial troubleshooting, it seems that Docker is hanging on webpacker.yml where extensions is being defined; although, this seems counter-intuitive, because Docker should not be processing this webpacker yml file. Changing default to x-default in this file did not resolve the issue.

This issue has been identified on Windows but it may also impact other operating systems using Docker Compose V2.

To Reproduce Steps to reproduce the behavior:

  1. Download and set up the latest Docker Desktop
  2. Run docker-compose build or docker compose build in your Terrastories dev dir.
  3. See error service "extensions" has neither an image nor a build context specified: invalid compose project

Expected behavior Terrastories builds as normal when running docker-compose build (or... docker compose build per V2) Desktop (please complete the following information):

sudo-bmitch commented 3 years ago

I'm wondering if the webpacker.yml is a red-herring. Running docker-compose should only be looking at the docker-compose.yml absent other settings. I'd be interested in checking the environment for any docker variables, on Linux that would involve: env | grep ^DOCKER, on Windows, maybe set and looking for anything that starts with DOCKER would be helpful.

Also we could include the docker-compose.yml file here, in case it differs from what's committed to the repo.

sudo-bmitch commented 3 years ago

The other thing to try is removing the x-web-common section from the compose file, and in-lining that definition into the web services. There may be some weird interaction between the yaml templates and variable expansion happening. A previous bug with the variable expansion was some weirdness happening when there was a variable in a comment (I believe they fixed that a while back).

rudokemper commented 3 years ago

Thanks @sudo-bmitch. Just now would like to confirm that the issue is being encountered (by at least two different people) with the same docker-compose file as in the repo.

rudokemper commented 3 years ago

On my Windows machine, set only shows the following for Docker:

Path=C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin; (among other non-Docker paths)

sudo-bmitch commented 3 years ago

Just pulled down the latest docker compose v2 to my Linux box to test and I was able to reproduce. The issue is the x-web-common, probably needs a bug report upstream. But in the mean time, here's my working compose file (at least to run the build command):

version: "3.7"
services:
  db:
    image: postgres:11
    ports:
      - 5432:5432
    environment:
      POSTGRES_PASSWORD: ${DB_USER_PASSWORD}
    volumes:
      - "postgres_data:/var/lib/postgresql/data"

  # webpacker:
  #   image: ${DOCKER_IMAGE_NAME-terrastories}
  #   command: ["./scripts/start_webpack_dev.sh"]
  #   volumes:
  #     - ./rails:/opt/terrastories:cached
  #   ports:
  #     - 3035:3035

  # x-web-common: &x-web-common
  #   image: ${DOCKER_IMAGE_NAME:-terrastories}
  #   build:
  #     context: ./rails
  #     args:
  #       precompileassets: "not"
  #   env_file:
  #     - .env

  web:
    image: ${DOCKER_IMAGE_NAME:-terrastories}
    build:
      context: ./rails
      args:
        precompileassets: "not"
    env_file:
      - .env
    command: scripts/server
    ports:
      - 3000:3000
    depends_on:
      - db
    volumes:
      - ./rails:/opt/terrastories:cached
      - ./data/media:/media
      - ./data/import/media:/opt/terrastories/import/media

  web-test:
    image: ${DOCKER_IMAGE_NAME:-terrastories}
    build:
      context: ./rails
      args:
        precompileassets: "not"
    env_file:
      - .env
    environment:
      RAILS_ENV: test
    command: scripts/test-server
    ports:
      - 3001:3000
    depends_on:
      - db
    volumes:
      - ./rails:/opt/terrastories:cached

  selenium:
    # Debug version enables VNC ability
    image: selenium/standalone-chrome-debug:3.0.1-germanium
    # Bind selenium port & VNC port
    ports: ['4444:4444', '5900:5900']
    logging:
      # Disable noisy logs.
      driver: none
    # bump this number up if pages are crashing
    shm_size: '256mb'

  e2e:
    build:
      context: ./e2e
    volumes:
      - ./e2e:/opt/terrastories_e2e:cached
    environment:
      TEST_APP_HOST: web-test
      TEST_APP_PORT: 3000
      SELENIUM_HOST: selenium
      SELENIUM_PORT: 4444
    depends_on:
      - web-test
      - selenium

volumes:
  postgres_data:
  mbtiles:
sudo-bmitch commented 3 years ago

PR incoming, x-* fields need to be at the top level. This one is an easy fix.