Skip to content

OPL-update doesn't use correct db connection info #999

@jerrac

Description

@jerrac

On my local machine, I've added the environment variables to the docker-compose.yml file. If I docker-compose run app bash and then check env, the WEBWORK_DB_* variables are set to what I put in the docker-compose file.

mysql -u root -h mysql -p is able to connect just fine from inside the app container.

Unfortunately, when I do a simple docker-compose up, the frontend (webwork2) app exits with an error:

webwork_frontend | DBI connect('webwork:db:3306','root',...) failed: Unknown MySQL server host 'db' (0) at ./OPL-update line 94.
webwork_frontend exited with code 255

It looks like the OPL-update script is still trying to use the default connection values for MySQL.

Is there something I'm missing?

I am using a different project structure than what the example docker-compose.yml file provides:

  • Project Root
    • webwork2/ (this repo)
    • opl/ (The opl repo)
    • pg/ (the pg repo)
    • data/courses/
    • docker-compose.yml
version: '3.3'
networks:
  webwknet:
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: webwknet
  dbnet:
    external:
      name: localdbs_dbnet

services:
  app:
    build: webwork2
    image: webwork:dev
    container_name: webwork_frontend
    depends_on:
      - r
    volumes:
      - "./webwork2:/opt/webwork/webwork2"

      # OLD approach put the courses tree under webwork2/.data/courses
      #- "./.data/courses:/opt/webwork/courses"
      # NEW appoach puts the courses tree in a separate tree outside of webwork2/
      - "./data/courses:/opt/webwork/courses"

      # Uncomment the line below to use local OPL for development
      - "./opl:/opt/webwork/libraries/webwork-open-problem-library"
      # Uncomment the line below to use local PG for development
      - "./pg:/opt/webwork/pg"
    ports:
      - "3080:80"
    environment:
      DEV: 0
      WEBWORK_DB_HOST: mysql
      WEBWORK_DB_PORT: 3306
      WEBWORK_DB_NAME: webwork
      WEBWORK_DB_USER: root
      WEBWORK_DB_PASSWORD: password
    networks:
      - dbnet
      - webwknet
  r:
    image: ubcctlt/rserve
    container_name: webwork_rserve
    ports:
      - "6311:6311"
    networks:
      - dbnet
      - webwknet

For testing I have a small docker instance of mysql running on the dbnet network. So I removed the db service from the file. I also adjusted where the bind mounds are sourced.

webwork2 is checked out to the WeBWorK-2.14 tag.
pg is checked out to the PG-2.14 tag.
opl is on the master branch of https://github.com/openwebwork/webwork-open-problem-library

In production I will be using a dedicated MySQL server. We're at the very first stages of implementing Docker and an Orchestration tool (maybe Kube) so I do prefer to use Docker, rather than install it directly.

Any suggestions?

Thanks!

Oh, and I was initially going to post this to the forum, but registering an account on the wiki failed. Incorrect or missing confirmation code. Shouldn't be caused by the captcha, 28 - 1 isn't exactly difficult....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions