intri-in/manage-my-damn-life-nextjs

Unable to use docker image

dashrandom opened this issue · 4 comments

I'm getting the following error when using the docker image

"Error connecting to database. Check your database settings. Here's some more information:

{"code":"ER_ACCESS_DENIED_ERROR","errno":1045,"sqlState":"28000","sqlMessage":"Access denied for user 'mmdm_user'@'172.22.0.3' (using password: YES)"}"

I'm not sure why this error is occuring, considering that mmdm_user is not the user specified in the docker compose file or the .env file I'm using...

image

My docker compose is follows:

version: "2.6"
services:
  app:
    container_name: mmdl_app
    image: intriin/mmdl:latest
    ports:
      - 3001:3000
    depends_on:
      - db
    networks:
      - web
      - internal
    restart: unless-stopped
    environment:
      DB_HOST: db
#    env_file:
#      - .env.local
    extra_hosts:
    - "host.docker.internal:host-gateway"
  db:
    container_name: mmdl_db
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    ports:
      - 3306
    networks:
#      - web
      - internal
    environment:
    ############################################################
    ## The following variables NEED to be set before execution.
    ############################################################
      #DB_NAME and MYSQL_DATABASE must be the same.
      MYSQL_DATABASE: mmdl
      # This is the user name and password of your mysql user that will be created. These values must be used in DB_USER and DB_PASS variables in the .env file that you will create.
      MYSQL_USER: mmdl
      MYSQL_PASSWORD: password
      # This defines the root password of mysql in the container. You can use the root user too. 
      MYSQL_ROOT_PASSWORD: password
    ############################################################
    ## The following variables are advanced settings,
    ## and must be only changed in case you're trying something
    ## specific.
    ############################################################
#      MYSQL_ALLOW_EMPTY_PASSWORD: ok
#      MYSQL_ROOT_HOST: '%'
    volumes:
      - ./mysql:/var/lib/mysql

networks:
  web:
    external: true
  internal:
    external: false

You've commented out these lines:

env_file:
- .env.local

This directive passes a .env to MMDL container. You'd need to setup a .env file as well.

You can use this guide:

https://manage-my-damn-life-nextjs.readthedocs.io/en/latest/install/Configuration/WithoutDocker/

In case you're wondering where the "mmdm_user" is coming from, it's from an old version of default .env file that probably got used during the build process of the docker image (when I uploaded it to the docker hub).

Hi, sorry, I should've mentioned that I've indeed set up a .env file, just that I defaulted it to .env so I commented out the lines

#    env_file:
#      - .env.local

My .env is as follows:

############################################################
## The following variables NEED to be set before execution.
############################################################


## Database variables.
DB_HOST=db
DB_USER=root
DB_PASS=password
DB_PORT="3306"
DB_NAME=mmdl
DB_CHARSET="utf8mb4"
DB_COLLATE="utf8mb4_0900_ai_ci"

## AES Encryption Password
## This is used to encrypt CalDAV passwords in the database.

AES_PASSWORD=password

############################################################
## The following variables aren't required for basic functionality,
## but might be required to be set for some additional features.
############################################################

## SMTP Settings
#SMTP_HOST=host
#SMTP_USERNAME=username
#SMTP_PASSWORD=password
#SMTP_FROMEMAIL=test@example.com
#SMTP_PORT=25
#SMTP_USESECURE=false 

## Enable NextAuth.js for third party authentication. It's highly recommended that you use a third party authentication service. Please note that third party authentication will eventually become the default option in the future versions of MMDL (probably by v1.0.0).

# The following variable's name has changed in v0.4.1
USE_NEXT_AUTH=false

# This is a variable used by NextAuth.js. This must be same as NEXT_PUBLIC_BASE_URL.
NEXTAUTH_URL="http://localhost:3001"

# This is a variable used by NextAuth.js. Must be generated.
# https://next-auth.js.org/configuration/options#nextauth_secret
NEXTAUTH_SECRET="secret"

##  Refer to docs for guide to set following variables. Ignore if NEXT_PUBLIC_USE_NEXT_AUTH is set to false. Uncomment as required.

# KEYCLOAK_ISSUER_URL="http://localhost:8080/realms/MMDL"
# KEYCLOAK_CLIENT_ID="mmdl-front-end"
# KEYCLOAK_CLIENT_SECRET="SAMPLE_CLIENT_SECRET"

# GOOGLE_CLIENT_ID=""
# GOOGLE_CLIENT_SECRET=""

# AUTHENTIK_CLIENT_ID=""
# AUTHENTIK_CLIENT_SECRET=""
# AUTHENTIK_ISSUER=""



############################################################
## The following variables aren't required to be set,
## but affect behaviour that you might want to customise.
############################################################

# User Config
NEXT_PUBLIC_DISABLE_USER_REGISTRATION=false

# After this value, old ssid will be deleted.
MAX_CONCURRENT_LOGINS_ALLOWED=3

# Maxium length of OTP validity, in seconds.
MAX_OTP_VALIDITY=1800

# Maximum length of a login session in seconds.
MAX_SESSION_LENGTH=2592000

# Enforce max length of session.
ENFORCE_SESSION_TIMEOUT=true

############################################################
## The following variables are advanced settings,
## and must be only changed in case you're trying something
## specific.
############################################################

#Whether user is running install from a docker image.
DOCKER_INSTALL="true"

## General Config
NEXT_PUBLIC_API_URL="http://localhost:3001/api"

## Debug Mode
NEXT_PUBLIC_DEBUG_MODE=true

#Max number of recursions for finding subtasks. Included so the recursive function doesn't go haywire.
#If subtasks are not being rendered properly, try increasing the value.
NEXT_PUBLIC_SUBTASK_RECURSION_CONTROL_VAR=100

## Test Mode
NEXT_PUBLIC_TEST_MODE=false

I defaulted it to .env so I commented out the lines

I tested it, and it seems like without the env_file directive, the environment variables aren't passed to the MMDL container.
Could you try still passing the .env file by uncommenting those lines, like so:

env_file:
  - .env

@intri-in Can confirm this is the case and it works now! Thanks! Seems weird though, because docker run or docker compose should automatically parse .env files if nothing is specified.

Might want to add a warning to the docker-compose.yml about the env_file option.