From de4781444ee64edb12abaa3af401b383208817e4 Mon Sep 17 00:00:00 2001 From: guessi Date: Sat, 6 May 2017 00:19:54 +0800 Subject: [PATCH] pure YOURLS v1.7.2 with docker-compose --- .dockerignore | 2 + .gitignore | 2 + .htaccess | 8 ++ Dockerfile | 23 +++++ .../apache2/sites-enabled/000-default.conf | 29 +++++++ conf/opt/yourls/.htaccess | 17 ++++ conf/opt/yourls/index.php | 0 conf/opt/yourls/user/config.php | 87 +++++++++++++++++++ conf/opt/yourls/user/plugins/.PLACEHOLDER | 0 docker-compose.yaml | 28 ++++++ volumes/var/lib/mysql/.PLACEHOLDER | 0 11 files changed, 196 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .htaccess create mode 100644 Dockerfile create mode 100644 conf/etc/apache2/sites-enabled/000-default.conf create mode 100644 conf/opt/yourls/.htaccess create mode 100644 conf/opt/yourls/index.php create mode 100644 conf/opt/yourls/user/config.php create mode 100644 conf/opt/yourls/user/plugins/.PLACEHOLDER create mode 100644 docker-compose.yaml create mode 100644 volumes/var/lib/mysql/.PLACEHOLDER diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3d63b2e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +docker-compose.yaml +volumes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0205b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +volumes/var/lib/mysql/* +!volumes/var/lib/mysql/.PLACEHOLDER diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..99d2cd0 --- /dev/null +++ b/.htaccess @@ -0,0 +1,8 @@ + + RewriteEngine On + RewriteBase / + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^.*$ /yourls-loader.php [L] + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2d05fcf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM php:5.6-apache + +ENV YOURLS_VERSION 1.7.2 +ENV YOURLS_PACKAGE https://github.com/YOURLS/YOURLS/archive/${YOURLS_VERSION}.tar.gz + +RUN docker-php-ext-install pdo_mysql mysqli mbstring && \ + a2enmod rewrite ssl + +RUN mkdir -p /opt/yourls && \ + curl -sSL ${YOURLS_PACKAGE} -o /tmp/yourls.tar.gz && \ + tar xf /tmp/yourls.tar.gz --strip-components=1 --directory=/opt/yourls + +RUN sed -i -e '/ServerTokens/s/^.*$/ServerTokens Prod/g' \ + -e '/ServerSignature/s/^.*$/ServerSignature Off/g' \ + /etc/apache2/conf-available/security.conf + +RUN apt-get update && \ + apt-get install --no-install-recommends -y git-core && \ + apt-get clean + +ADD conf/ / + +WORKDIR /opt/yourls diff --git a/conf/etc/apache2/sites-enabled/000-default.conf b/conf/etc/apache2/sites-enabled/000-default.conf new file mode 100644 index 0000000..f9c68b9 --- /dev/null +++ b/conf/etc/apache2/sites-enabled/000-default.conf @@ -0,0 +1,29 @@ + + ServerName yourls + + ServerAdmin no-reply@localhost + DocumentRoot /opt/yourls + + + DirectoryIndex index.php index.html + Options All + AllowOverride All + Require all granted + + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + diff --git a/conf/opt/yourls/.htaccess b/conf/opt/yourls/.htaccess new file mode 100644 index 0000000..7ade762 --- /dev/null +++ b/conf/opt/yourls/.htaccess @@ -0,0 +1,17 @@ + + RewriteEngine On + RewriteBase / + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^.*$ /yourls-loader.php [L] + + + + Options -Indexes + + + + order allow,deny + deny from all + diff --git a/conf/opt/yourls/index.php b/conf/opt/yourls/index.php new file mode 100644 index 0000000..e69de29 diff --git a/conf/opt/yourls/user/config.php b/conf/opt/yourls/user/config.php new file mode 100644 index 0000000..4b7bfe1 --- /dev/null +++ b/conf/opt/yourls/user/config.php @@ -0,0 +1,87 @@ + 'adminsecretpassword', + // 'username2' => 'password2', + // You can have one or more 'login'=>'password' lines + ); + +/** Debug mode to output some internal information + ** Default is false for live site. Enable when coding or before submitting a new issue */ +define( 'YOURLS_DEBUG', false ); + +/* + ** URL Shortening settings + */ + +/** URL shortening method: 36 or 62 */ +define( 'YOURLS_URL_CONVERT', 36 ); +/* + * 36: generates all lowercase keywords (ie: 13jkm) + * 62: generates mixed case keywords (ie: 13jKm or 13JKm) + * Stick to one setting. It's best not to change after you've started creating links. + */ + +/** +* Reserved keywords (so that generated URLs won't match them) +* Define here negative, unwanted or potentially misleading keywords. +*/ +$yourls_reserved_URL = array( + 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', +); + +/* + ** Personal settings would go after here. + */ diff --git a/conf/opt/yourls/user/plugins/.PLACEHOLDER b/conf/opt/yourls/user/plugins/.PLACEHOLDER new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d3fe190 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,28 @@ +version: '2' + +services: + mysql: + image: mysql + container_name: yourls-mysql + environment: + - MYSQL_ROOT_PASSWORD=rootsecretpassword + - MYSQL_USER=yourls + - MYSQL_PASSWORD=mysecretpassword + - MYSQL_DATABASE=yourls + volumes: + - ./volumes/var/lib/mysql:/var/lib/mysql:rw + privileged: true + + yourls: + build: ./ + container_name: yourls + links: + - mysql:mysql + environment: + - MYSQL_USER=yourls + - MYSQL_PASSWORD=mysecretpassword + - MYSQL_DATABASE=yourls + ports: + - "80:80" + depends_on: + - mysql diff --git a/volumes/var/lib/mysql/.PLACEHOLDER b/volumes/var/lib/mysql/.PLACEHOLDER new file mode 100644 index 0000000..e69de29