Running identical docker container offline

Viewed 126

I am running a docker container online under a subdomain (docker.domain.com)

I am having problems updating my container to the newer version and want to create an identical container offline to tun on local host to see if I can debug the issue

The problem I have is that I have set up base urls and api urls un the docker-compose.yaml and .env files I am not sure how to translate these urls over to 127.0.0.1 localhost

Update: docker-compose.yaml file

version: '3.5'

services:
  db:
    image: percona:8.0
    restart: on-failure
    environment:
      # To be picked up by percona image when creating the database
      # Must match with DB_DSN settings inside .env
      MYSQL_DATABASE:      database
      MYSQL_USER:          user
      MYSQL_PASSWORD:      sqlpass
      MYSQL_ROOT_PASSWORD: rootpass
    # healthcheck: { test: ["CMD", "mysqladmin" ,"ping", "-h", "77.68.90.188"], timeout: 20s, retries: 10 }
    # Uncomment to use local fs for data persistence
    volumes: [ "./data/db:/var/lib/mysql" ]
    networks: [ internal ]

  server:
    image: cortezaproject/corteza-server:latest
    restart: on-failure
    env_file: [ .env ]
    environment:
      # Informing Corredor where it he contact us
      CORREDOR_ADDR:                   "corredor:80"
      VIRTUAL_HOST:                    "https://subdomain.domain.tld"      
    depends_on: [ db, corredor ]
    volumes: [ "./data/server:/data" ]
    healthcheck: { test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"], timeout: 20s, retries: 10 }
    ports: [ "127.0.0.1:30500:80" ]
    networks: [ internal ]

  corredor:
    image: cortezaproject/corteza-server-corredor:latest
    restart: on-failure
    env_file: [ .env ]
    environment:
      # Informing Corredor where it he contact us
      CORREDOR_ADDR:                   "corredor:80"
    # Binds internal port to port LOCAL_DEMO_CRD_PORT on localhost
    networks: [ internal ]
    volumes: [ "./corredor:/corredor/usr" ]

  webapp:
    image: cortezaproject/corteza-webapp:latest
    restart: on-failure
    depends_on: [ server ]
    environment:
      # Monolith server in the backend, all services can be found under one base URL
      MONOLITH_API: 1
      # Configure web application with API location
      API_BASEURL:  "api-subdomain.domain.tld"
      VIRTUAL_HOST: subdomain.domain.tld
    ports: [ "127.0.0.1:30501:80" ]

networks:
  internal: {}

The YAML file uses a subdomain of my website URL Ideally I would like to keep the exact same set up but run it locally via WAMP to debug the upgrade issue

I am currently running it locally and the update works fine but I think I mauy have changed too much in my local YAML file

update2 docker-compose.override.yaml

Version: '3.5'

server:
environment:
  VIRTUAL_HOST:                    "localhost"   

 webapp:
environment:
  API_BASEURL:  "localhost/api"
  VIRTUAL_HOST: localhost
1 Answers

In your situation I would recommend using a docker-compose.override.yml. This allows you to keep your production file untouched but set specific directives for your local environment.

For example:

docker-compose.override.yml

services:
  webapp:
    environment:
      API_BASEURL: "localhost/api"

Reference:

https://docs.docker.com/compose/extends/#multiple-compose-files

As a recommendation I would also avoid splitting your environment variables between your docker-compose.yml and a separate .env file. Pick one and stick with it. Often, you add variables over time and it becomes unwieldy to do it within YAML, so move them all to a separate file at once.

Related