linuxserver / docker-healthchecks

GNU General Public License v3.0
178 stars 38 forks source link

Fixed mariadb/postgresql dependencies #33

Closed lukasmrtvy closed 4 years ago

lukasmrtvy commented 4 years ago

linuxserver.io


We welcome all PR’s though this doesn’t guarantee it will be accepted.

Description:

Benefits of this PR and context:

Working connection to external PostgreSQL and MariaDB

How Has This Been Tested?

---
version: "2"
services:
  healthchecks:
    image: mycustomhealtchsimage
    environment:
      PUID: "1000"
      PGID: "1000"
      TZ: "Europe/Prague"
      SITE_ROOT: "https://healthchecks.example.com"
      SITE_NAME: "healtchecks"
      REGISTRATION_OPEN: "False"
      SUPERUSER_EMAIL: "admin@admin.admin"
      SUPERUSER_PASSWORD: "admin"
      DB: healthchecks
      #DB_HOST: healthchecks-postgres
      DB_HOST: healthchecks-mariadb
      DB_NAME: healtchecks
      DB_USER: healtchecks
      DB_PASSWORD: healtchecks
    networks: 
      - production-network
    restart: unless-stopped
    ports:
      - "8000:8000"
    depends_on:
      - healthchecks-postgres
  healthchecks-postgres:
    image: postgres:12-alpine
    environment:
      POSTGRES_DB: healthchecks
      POSTGRES_USER: healthchecks
      POSTGRES_PASSWORD: healthchecks
      TZ: Europe/Prague
    networks: 
      - production-network
    restart: unless-stopped
  healthchecks-mariadb:
    image: mariadb:10.4.10-bionic
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: yes
      MYSQL_DATABASE: healthchecks
      MYSQL_USER: healthchecks
      MYSQL_PASSWORD: healthchecks
      TZ: Europe/Prague
    networks: 
      - production-network
    restart: unless-stopped

networks:
  production-network:
    ipam:
     driver: default

Source / References:

LinuxServer-CI commented 4 years ago

I am a bot, here are the test results for this PR: https://lsio-ci.ams3.digitaloceanspaces.com/lspipepr/healthchecks/v1.11.0-pkg-8cc055b5-pr-33/index.html https://lsio-ci.ams3.digitaloceanspaces.com/lspipepr/healthchecks/v1.11.0-pkg-8cc055b5-pr-33/shellcheck-result.xml

mlatorre31 commented 4 years ago

Hi, This PR breaks existing setup with mysql database. Works fine with v1.12.0-ls47 tag

Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module> import MySQLdb as Database ModuleNotFoundError:' No module named 'MySQLdb'

Manual install of mysqlclient through pip throws: OSError: mysql_config not found

lukasmrtvy commented 4 years ago

@mlatorre31 can You try it with apk add -U mysql-client ?

mlatorre31 commented 4 years ago

@lukasmrtvy doesn't work. However, apk add -U mariadb-connector-c-dev then pip3 install mysqlclient does the trick (with build-dependencies installed again).

fititnt commented 4 years ago

The step-by-step that worked for me after version v1.12.0-ls48 first running is this:

docker exec -it healthchecks-conteiner-name /bin/bash

apk add -U mariadb-connector-c-dev
apk add -U gcc libc-dev python3-dev
pip3 install --upgrade pip
pip3 install mysqlclient

exit

docker stop healthchecks-conteiner-name
docker start healthchecks-conteiner-name

The final image size get bigger with the building dependencies included, so for sure there is some room for improvement. But for very short term these steps do the job (at least for me).