Skip to content

Mysql does not work #54

@vlastocom

Description

@vlastocom

I tried to set up this container with mysql database and could not make it work.

My dockerfile:

version: '3.7'
services:
  db:
    image: mysql:${MYSQL_VERSION}
    restart: always
    environment:
      MYSQL_DATABASE: pypi-server
      MYSQL_USER: pypi-user
      MYSQL_PASSWORD: ${DB_USER_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - "pypi-data:/var/lib/mysql:rw"
    ports:
      - 49997:3306
    networks:
      pypi-network: {}
  server:
    image: mosquito/pypi-server:${PYPI_VERSION}
    restart: always
    environment:
      DB: "mysql://pypi-user:${DB_USER_PASSWORD}@db/pypi-server"
      PYPI_SERVER: https://pypi.python.org
    volumes:
      - ./packages:/var/lib/pypi-server
    ports:
      - 49996:80
    networks:
      pypi-network: {}
networks:
  pypi-network:
    driver: bridge
    # Need this to set firewalls on my system
    ipam:
      config:
        - subnet: 192.168.31.0/24
volumes:
  pypi-data:

My .env file for docker-compose looks something like this:

MYSQL_VERSION=8.0.25
PYPI_VERSION=0.4.10
... (the rest of the file removed)

Error I am getting is this:

[I 210720 07:58:38 __init__:52] Database initialized as 'pypi-server'. Checking migrations...
[C 210720 07:58:38 server:204] Exception on main loop:
[E 210720 07:58:38 server:205] MySQLdb or PyMySQL must be installed.
    Traceback (most recent call last):
      File "/usr/share/python/app/lib/python3.7/site-packages/pypi_server/server.py", line 158, in run
        io_loop.run_sync(lambda: init_db(options.database))
      File "/usr/share/python/app/lib/python3.7/site-packages/tornado/ioloop.py", line 458, in run_sync
        return future_cell[0].result()
      File "/usr/share/python/app/lib/python3.7/site-packages/tornado/concurrent.py", line 238, in result
        raise_exc_info(self._exc_info)
      File "<string>", line 4, in raise_exc_info
      File "/usr/share/python/app/lib/python3.7/site-packages/tornado/ioloop.py", line 436, in run
        result = func()
      File "/usr/share/python/app/lib/python3.7/site-packages/pypi_server/server.py", line 158, in <lambda>
        io_loop.run_sync(lambda: init_db(options.database))
      File "/usr/share/python/app/lib/python3.7/site-packages/pypi_server/db/__init__.py", line 90, in init_db
        DB.create_tables([Migrations], safe=True)
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3917, in create_tables
        create_model_tables(models, fail_silently=safe)
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 5356, in create_model_tables
        m.create_table(**create_table_kwargs)
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 5028, in create_table
        if fail_silently and cls.table_exists():
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 5024, in table_exists
        return cls._meta.db_table in cls._meta.database.get_tables(**kwargs)
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 4321, in get_tables
        return [row for row, in self.execute_sql('SHOW TABLES')]
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3828, in execute_sql
        cursor = self.get_cursor()
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3774, in get_cursor
        return self.get_conn().cursor()
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3763, in get_conn
        self.connect()
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3738, in connect
        self._local.conn = self._create_connection()
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 3768, in _create_connection
        return self._connect(self.database, **self.connect_kwargs)
      File "/usr/share/python/app/lib/python3.7/site-packages/peewee.py", line 4310, in _connect
        raise ImproperlyConfigured('MySQLdb or PyMySQL must be installed.')
    peewee.ImproperlyConfigured: MySQLdb or PyMySQL must be installed.

I believe this is caused by the docker container not having all dependencies installed, but am not sure.

P.S.: I also tried to use Postgres configuration, but am consistently getting #45 , basically this container does not seem to be operating well with any of the database systems which I would put close to production.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions