├── .dockerignore ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── main.yml │ └── manual.yml ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── examples ├── .gitkeep └── docker-compose.yml └── install ├── assets ├── defaults │ └── 30-yourls └── functions │ └── 30-yourls └── etc ├── cont-init.d └── 30-yourls └── nginx └── sites.available └── yourls.conf /.dockerignore: -------------------------------------------------------------------------------- 1 | examples/ 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [tiredofit] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: "build_image" 2 | 3 | on: 4 | push: 5 | paths: 6 | - "**" 7 | - "!README.md" 8 | 9 | jobs: 10 | build: 11 | uses: tiredofit/github_actions/.github/workflows/default_amd64.yml@main 12 | #uses: tiredofit/github_actions/.github/workflows/default_amd64.yml@main 13 | #uses: tiredofit/github_actions/.github/workflows/default_amd64_armv7_arm64.yml@main 14 | #uses: tiredofit/github_actions/.github/workflows/default_amd64_arm64.yml@main 15 | secrets: inherit 16 | -------------------------------------------------------------------------------- /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | name: "manual_build_image" 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | Manual Build: 7 | description: 'Manual Build' 8 | required: false 9 | 10 | jobs: 11 | build: 12 | uses: tiredofit/github_actions/.github/workflows/default_amd64.yml@main 13 | #uses: tiredofit/github_actions/.github/workflows/default_amd64.yml@main 14 | #uses: tiredofit/github_actions/.github/workflows/default_amd64_armv7_arm64.yml@main 15 | #uses: tiredofit/github_actions/.github/workflows/default_amd64_arm64.yml@main 16 | secrets: inherit 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 3.0.8 2025-04-27 2 | 3 | ### Added 4 | - PHP 8.3 Base 5 | - YOURLS 1.10.1 6 | 7 | 8 | ## 3.0.7 2024-07-17 9 | 10 | ### Changed 11 | - Fix issue with time zone offset 12 | 13 | 14 | ## 3.0.6 2023-03-05 15 | 16 | ### Added 17 | - YOURLS 1.9.2 18 | - PHP 8.2 19 | - Dockerfile modernization 20 | 21 | 22 | ## 3.0.5 2022-10-05 23 | 24 | ### Changed 25 | - Migrate legacy nginx configuration 26 | 27 | 28 | ## 3.0.4 2022-08-06 29 | 30 | ### Added 31 | - Start using custom_scripts and custom_files functions from base 32 | 33 | 34 | ## 3.0.3 2022-06-23 35 | 36 | ### Added 37 | - Support tiredofit/nginx:6.0.0 and tiredofit/nginx-php-fpm:7.0.0 changes 38 | 39 | 40 | ## 3.0.2 2022-05-29 41 | 42 | ### Added 43 | - YOURLs 1.9.1 44 | 45 | 46 | ## 3.0.1 2022-04-23 47 | 48 | ### Added 49 | - YOURLS 1.9 50 | 51 | 52 | ## 3.0.0 2021-03-20 53 | 54 | ### Added 55 | - YOURLS 1.8.1 56 | - PHP 8.0 57 | - Image rewritten to support seperate data folder for volatile information (themes/plugins/config) allowing for easy upgrades 58 | 59 | 60 | ## 2.5.1 2020-01-06 61 | 62 | ### Changed 63 | - Refactor to support new tiredofit/alpine base image 64 | 65 | 66 | ## 2.5.0 2019-12-04 67 | 68 | ### Added 69 | - Refactor Image to support new tiredofit/nginx-php-fpm base image 70 | 71 | 72 | ## 2.4 2018-02-01 2.4 73 | 74 | * Fix for blank SITE_URL 75 | 76 | ## 2.3 2018-02-01 2.3 77 | 78 | * Rebase 79 | 80 | ## 2.2 2017-07-03 2.2 81 | 82 | * Added PHP Timeout 83 | 84 | ## 2.1 2017-07-02 85 | 86 | * Sanity Check for Init Scripts 87 | 88 | ## 2.0 2017-06-23 89 | 90 | * Rebase with nginx-php-fpm:7.0 w/ s6.d 91 | 92 | ## 1.1 2017-02-09 93 | 94 | * Rebase with SD Alpine w/ Zabbix 95 | 96 | ## 1.0 2017-01-28 97 | 98 | * Working Copy - Make sure to activate plugins and read configuration settings - Edit config.php! 99 | 100 | ## 0.1 2017-01-28 101 | 102 | * Initial Release 103 | * Alpine:edge 104 | * PHP7 105 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_BASE=8.3 2 | ARG DISTRO="alpine" 3 | 4 | FROM docker.io/tiredofit/nginx-php-fpm:${PHP_BASE}-${DISTRO} 5 | LABEL maintainer="Dave Conroy (github.com/tiredofit)" 6 | ENV YOURLS_VERSION=1.10.1 \ 7 | 8 | PHP_ENABLE_CREATE_SAMPLE_PHP=FALSE \ 9 | PHP_ENABLE_CURL=TRUE \ 10 | PHP_ENABLE_LDAP=TRUE \ 11 | PHP_ENABLE_MYSQLI=TRUE \ 12 | NGINX_WEBROOT="/www/yourls" \ 13 | NGINX_SITE_ENABLED="yourls" \ 14 | IMAGE_NAME="tiredofit/yourls" \ 15 | IMAGE_REPO_URL="https://github.com/tiredofit/docker-yourls/" 16 | 17 | ### Dependency Installation 18 | RUN source /assets/functions/00-container && \ 19 | set -x && \ 20 | package update && \ 21 | package upgrade && \ 22 | package install .yourls-run-deps \ 23 | openldap-clients \ 24 | sed \ 25 | && \ 26 | \ 27 | mkdir -p /assets/install && \ 28 | curl -ssL https://github.com/YOURLS/YOURLS/archive/refs/tags/${YOURLS_VERSION}.tar.gz | tar xvfz - --strip 1 -C /assets/install/ && \ 29 | package cleanup 30 | 31 | COPY install/ / 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Dave Conroy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github.com/tiredofit/docker-yourls 2 | 3 | ## About 4 | 5 | This will build a container for YOURLS, a URL Link shortener. 6 | 7 | This image needs manual configuration to get configuration running, it is not fully dynamic specifically if you add plugins!. Please see invidividual plugin documentation and manually edit the `data/config` file for these additions. 8 | 9 | This Container uses Alpine:3.13 as a base. 10 | 11 | [Changelog](CHANGELOG.md) 12 | 13 | ## Maintainer 14 | 15 | - [Dave Conroy](dave at tiredofit dot ca) 16 | 17 | ## Table of Contents 18 | 19 | - [Introduction](#introduction) 20 | - [Authors](#authors) 21 | - [Table of Contents](#table-of-contents) 22 | - [Prerequisites](#prerequisites) 23 | - [Installation](#installation) 24 | - [Quick Start](#quick-start) 25 | - [Configuration](#configuration) 26 | - [Data-Volumes](#data-volumes) 27 | - [Environment Variables](#environment-variables) 28 | - [Networking](#networking) 29 | - [Maintenance](#maintenance) 30 | - [Shell Access](#shell-access) 31 | - [References](#references) 32 | 33 | ## Prerequisites and Assumptions 34 | 35 | This container requires the use of an external MariaDB database container. 36 | 37 | 38 | ## Installation 39 | 40 | Automated builds of the image are available on [Docker Hub](https://hub.docker.com/r/tiredofit/yourls) 41 | 42 | 43 | ```bash 44 | docker pull hub.docker.com/r/tiredofit/yourls 45 | ``` 46 | 47 | ### Quick Start 48 | 49 | * The quickest way to get started is using [docker-compose](https://docs.docker.com/compose/). See the examples folder for a working [docker-compose.yml](examples/docker-compose.yml) that can be modified for development or production use. 50 | 51 | * Set various [environment variables](#environment-variables) to understand the capabiltiies of this image. 52 | * Map [persistent storage](#data-volumes) for access to configuration and data files for backup. 53 | 54 | 55 | 56 | ## Configuration 57 | 58 | ### Persistent Storage 59 | 60 | The following directories are used for configuration and can be mapped for persistent storage. 61 | 62 | | Directory | Description | 63 | | --------- | ------------------------------ | 64 | | /www/logs | PHP and NginX Logs | 65 | | /data/ | Plugins and Configuration Data | 66 | 67 | 68 | 69 | ### Environment Variables 70 | 71 | Below is the complete list of available options that can be used to customize your installation. 72 | 73 | | Parameter | Description | Default | 74 | | ------------ | ------------------------------------------------ | ------- | 75 | | `DB_HOST` | External MariaDB Container (e.g. yourls-db) | | 76 | | `DB_NAME` | Database Name (e.g. yourls) | | 77 | | `DB_USER` | User with Database Permissions (e.g. yourls) | | 78 | | `DB_PASS` | Password for above user (e.g. userpassword) | | 79 | | `ADMIN_USER` | Administrative User (e.g. admin) | | 80 | | `ADMIN_PASS` | Password for Administrative User (e.g. password) | | 81 | | `SITE_NAME` | Site Name | | 82 | | `SITE_URL` | Site URL | | 83 | | `DEBUG` | Set application to Debug Mode to Display Queries | `FALSE` | 84 | 85 | 86 | ### Networking 87 | 88 | The following ports are exposed. 89 | 90 | | Port | Description | 91 | | ---- | ----------- | 92 | | 80 | HTTP | 93 | 94 | ## Maintenance 95 | ### Shell Access 96 | 97 | For debugging and maintenance purposes you may want access the containers shell. 98 | 99 | ```bash 100 | docker exec -it (whatever your container name is e.g. yourls) bash 101 | ``` 102 | 103 | ## References 104 | 105 | * https://yourls.org 106 | 107 | -------------------------------------------------------------------------------- /examples/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiredofit/docker-yourls/87eab2e81966cfc94caec13464db70c7223e2bb2/examples/.gitkeep -------------------------------------------------------------------------------- /examples/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.4' 2 | services: 3 | 4 | yourls-app: 5 | image: tiredofit/yourls:latest 6 | container_name: yourls-app 7 | links: 8 | - yourls-db 9 | labels: 10 | - traefik.enable=true 11 | - traefik.frontend.rule=Host:yourls.hostname.com 12 | - traefik.port=80 13 | - traefik.protocol=http 14 | - traefik.docker.network=proxy 15 | - traefik.backend=yourls-app 16 | volumes: 17 | - ./logs/:/www/logs 18 | environment: 19 | - VIRTUAL_HOST=yourls.hostname.com 20 | - VIRTUAL_NETWORK=proxy 21 | - VIRTUAL_PORT=80 22 | - LETSENCRYPT_HOST=yourls.hostname.com 23 | - LETSENCRYPT_EMAIL=user@hostname.com 24 | 25 | - DB_HOST=yourls-db 26 | - DB_NAME=yourls 27 | - DB_USER=yourls 28 | - DB_PASS=userpassword 29 | 30 | - SITE_NAME=sitename.com 31 | - ADMIN_USER=admin 32 | - ADMIN_PASS=yourls 33 | 34 | - DEBUG=false 35 | networks: 36 | - proxy 37 | - services 38 | restart: always 39 | 40 | yourls-db: 41 | image: tiredofit/mariadb:latest 42 | container_name: yourls-db 43 | volumes: 44 | - ./db:/var/lib/mysql 45 | environment: 46 | - ROOT_PASS=password 47 | - DB_NAME=yourls 48 | - DB_USER=yourls 49 | - DB_PASS=userpassword 50 | networks: 51 | - services 52 | restart: always 53 | 54 | yourls-db-backup: 55 | image: tiredofit/db-backup:latest 56 | container_name: yourls-db-backup 57 | links: 58 | - yourls-db 59 | volumes: 60 | - ./dbbackup:/backup 61 | environment: 62 | - DB_HOST=yourls-db 63 | - DB_NAME=yourls 64 | - DB_USER=yourls 65 | - DB_PASS=userpassword 66 | - DB_TYPE=mariadb 67 | - DB01_BACKUP_INTERVAL=1440 68 | - DB01_BACKUP_BEGIN=0000 69 | - DB_CLEANUP_TIME=8640 70 | networks: 71 | - services 72 | restart: always 73 | 74 | networks: 75 | proxy: 76 | external: true 77 | services: 78 | external: true 79 | 80 | -------------------------------------------------------------------------------- /install/assets/defaults/30-yourls: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | DEBUG=${DEBUG:-"false"} 4 | DB_PREFIX=${DB_PREFIX:-"yourls_"} 5 | SITE_NAME=${SITE_NAME:-"https://${SITE_URL}"} 6 | -------------------------------------------------------------------------------- /install/assets/functions/30-yourls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiredofit/docker-yourls/87eab2e81966cfc94caec13464db70c7223e2bb2/install/assets/functions/30-yourls -------------------------------------------------------------------------------- /install/etc/cont-init.d/30-yourls: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | 3 | source /assets/functions/00-container 4 | prepare_service 5 | PROCESS_NAME="yourls" 6 | 7 | sanity_db mariadb 8 | sanity_var SITE_URL "Site URL" 9 | sanity_var ADMIN_USER "Admin User" 10 | sanity_var ADMIN_PASS "Admin Password" 11 | 12 | db_ready mariadb 13 | 14 | ### Check to see if this is a new install, if yes download Wordpress and other pieces... 15 | if [ ! -f ${NGINX_WEBROOT}/yourls-loader.php ] ; then 16 | print_info "Potential New/Non Volatile Installation - Please wait while we setup.." 17 | cp -R /assets/install/* "${NGINX_WEBROOT}/" 18 | chown -R "${NGINX_USER}":"${NGINX_GROUP}" "${NGINX_WEBROOT}" 19 | fi 20 | 21 | ### If running with /www/html or NGINX_WEBROOT mapped, then create persistent storage 22 | ### Storage redirection 23 | if [ -d "/data" ]; then 24 | print_warn "Detected /data directory. Persistently saving config/uploads/themes/etc" 25 | config_file="/data/config" 26 | ln -sf "${config_file}" "${NGINX_WEBROOT}"/user/config.php 27 | if [ ! -d "/data/plugins" ]; then 28 | cp -R "${NGINX_WEBROOT}"/user/plugins /data 29 | fi 30 | rm -rf "${NGINX_WEBROOT}"/user/plugins 31 | ln -s /data/plugins "${NGINX_WEBROOT}"/user/plugins 32 | chown -R "${NGINX_USER}":"${NGINX_GROUP}" /data 33 | else 34 | config_file="${NGINX_WEBROOT}/user/config.php" 35 | fi 36 | 37 | if [ ! -f "${config_file}" ] ; then 38 | cat < '${ADMIN_PASS}', 52 | ); 53 | define( 'YOURLS_DEBUG', ${DEBUG} ); 54 | define( 'YOURLS_URL_CONVERT', 36 ); 55 | \$yourls_reserved_URL = array( 56 | 'reserved', 57 | ); 58 | EOL 59 | else 60 | sudo -u "${NGINX_USER}" sed -i --follow-symlinks \ 61 | -e "/YOURLS_DB_USER/ c\define( 'YOURLS_DB_USER', '$DB_USER' );" \ 62 | -e "/YOURLS_DB_PASS/ c\define( 'YOURLS_DB_PASS', '$DB_PASS' );" \ 63 | -e "/YOURLS_DB_NAME/ c\define( 'YOURLS_DB_NAME', '$DB_NAME' );" \ 64 | -e "/YOURLS_DB_HOST/ c\define( 'YOURLS_DB_HOST', '$DB_HOST' );" \ 65 | -e "/YOURLS_DEBUG/ c\define( 'YOURLS_DEBUG', $DEBUG );" \ 66 | -e "/YOURLS_SITE/ c\define( 'YOURLS_SITE', '$SITE_NAME' );" \ 67 | "${config_file}" 68 | fi 69 | 70 | custom_files "${CONTAINER_CUSTOM_PATH}" "${NGINX_WEBROOT}" "${NGINX_USER}" "${NGINX_GROUP}" 71 | custom_scripts 72 | 73 | ### Force Reset Permissions for Security 74 | chown -R "${NGINX_USER}":"${NGINX_GROUP}" "${NGINX_WEBROOT}" 75 | print_info "YOURLS ${YOURLS_VERSION} is ready to be accessed!" 76 | 77 | liftoff 78 | -------------------------------------------------------------------------------- /install/etc/nginx/sites.available/yourls.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen {{NGINX_LISTEN_PORT}}; 3 | root {{NGINX_WEBROOT}}; 4 | index index.php; 5 | 6 | location / { 7 | try_files $uri $uri/ /yourls-loader.php$is_args$args; 8 | } 9 | 10 | location ~ \.php$ { 11 | include /etc/nginx/snippets/php-fpm.conf; 12 | try_files $uri =404; 13 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 14 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 15 | fastcgi_index index.php; 16 | include fastcgi_params; 17 | } 18 | 19 | ### Don't edit past here 20 | include /etc/nginx/snippets/site_optimization.conf; 21 | include /etc/nginx/snippets/exploit_protection.conf; 22 | } --------------------------------------------------------------------------------