/YOURLS-Run_with_Docker

Run YOURLS with docker (and php-fpm)

Primary LanguagePHPMIT LicenseMIT

- Prerequisite

- YOURLS Environment

Using official docker images:

  1. yourls:1.7.4-fpm-alpine
  2. mysql:8.0.18
  3. nginx:1.17.5-alpine

- HOW-TO

0. Change your database user and password in env-mysql.env and env-yourls.env

1. Run script 0-init.sh to initialize database for YOURLS

  • You should see following 3 kinds of success log
    1. YOURLS init
      YOURLS             | YOURLS init...
      YOURLS             | YOURLS init done!
      YOURLS exited with code 0
    2. MySQL init
      yourls-database    | update db user privileges
      yourls-database    | MySQL init done!
      yourls-database exited with code 0
    3. Finish and shutdown
      Init complete
      Removing YOURLS          ... done
      Removing yourls-database ... done
      Removing network docker_intranet-init-yourls
  • If things failed, try to increase delay time (POSTPONE_FOR_A_WHILE=60s)
    • E.g., set to 90s or longer
    • Note that you have to remove old failed database before retry
  • Set flags in docker-compose-init.yml as needed
    • Set INIT_INSTALL_RECOMMENDED_PLUGINS=true to install plugins recommended (and revise) by me
    • Set INIT_ENABLE_GITLAB_OAUTH_SUPPORT=true to add (GitLab) OAuth support

2. Run script 1-run.sh to start your YOURLS service

  • Now, you can visit http://localhost/admin/index.php to start using YOURLS
  • Remember to change domain setting in both Nginx config and YOURLS
    • Note that config-docker.php will be copied as /docker/deploy/yourls/user/config.php, so change that file after running 0-init.sh rather than modify config-docker.php itself
    • Also remember to replace default user as your own ones; otherwise, it may be dangerous

3. Shutdown (and remove data) using script 2-down.sh

  • Answer Y to Warning!! (Permanently) REMOVE folders for yourls and database? [y/N] if you want to Remove Database and YOURLS
    • This is for removing files when the 0-init.sh script failed
  • Otherwise, answer N or Press Enter to keep data

- Concept

  • The main point is that MySQL chane their policy on authentication method
    • The critical script is cmd-mysql.sh for this project
      • #L15 is the original entrypoint, which will initialize the database
      • #L16 is for command ps and pkill in alpine
      • #L17 is the delay time for former works to get ready
      • #L18 is to kill the original mysqld
      • #L20 is to create a new mysqld_safe with flag --skip-grant-tables
      • #L26-L29 are to enable mysql_native_password for user

- License

This project is licensed under the following 3 licenses, YOURLS, MIT, and EPL

  1. YOURLS: aka Do whatever the hell you want with it
  2. MIT: aka MadeInTaiwan Licence ฅ• ω •ฅ
  3. EPL: aka EPL Public License, where EPL stands for EmbeddedPlatformLab (like GNU or YAML, quite cool, huh?)

Feel free to modify it to your own version as needed
Contact me if having any comments :D