diff --git a/.gitignore b/.gitignore index 9881fec..c4c4ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -*.tar.* +*.zip diff --git a/Changelog.md b/Changelog.md index fd231ac..e62133e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +**1.5.4** +- invoiceplane: upgrade to 1.5.4 +- add `INVOICEPLANE_PROXY_IPS` to configure reverse proxy ips + +**1.5.3** +- invoiceplane: upgrade to 1.5.3 + **1.4.10** - invoiceplane: security update to 1.4.10 diff --git a/Dockerfile b/Dockerfile index 318f9e9..652e1d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM sameersbn/ubuntu:14.04.20170123 +FROM sameersbn/ubuntu:14.04.20170724 MAINTAINER sameer@damagehead.com -ENV PHP_VERSION=7.0 \ - INVOICEPLANE_VERSION=1.4.10 \ +ENV PHP_VERSION=7.1 \ + INVOICEPLANE_VERSION=1.5.4 \ INVOICEPLANE_USER=www-data \ INVOICEPLANE_INSTALL_DIR=/var/www/invoiceplane \ INVOICEPLANE_DATA_DIR=/var/lib/invoiceplane \ @@ -23,8 +23,6 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 14AA40EC0831756 mysql-client nginx gettext-base git \ && sed -i 's/^listen = .*/listen = 0.0.0.0:9000/' /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf \ && phpenmod -v ALL mcrypt \ - && wget -nv "https://getcomposer.org/composer.phar" -O /usr/local/bin/composer \ - && chmod +x /usr/local/bin/composer \ && rm -rf /var/lib/apt/lists/* COPY assets/build/ ${INVOICEPLANE_BUILD_DIR}/ @@ -40,4 +38,4 @@ WORKDIR ${INVOICEPLANE_INSTALL_DIR} ENTRYPOINT ["/sbin/entrypoint.sh"] CMD ["app:invoiceplane"] -EXPOSE 9000 +EXPOSE 80/tcp 9000/tcp diff --git a/README.md b/README.md index 6a20022..043ac70 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Docker Repository on Quay.io](https://quay.io/repository/sameersbn/invoiceplane/status "Docker Repository on Quay.io")](https://quay.io/repository/sameersbn/invoiceplane) -# sameersbn/invoiceplane:1.4.10-2 +# sameersbn/invoiceplane:1.5.4 - [Introduction](#introduction) - [Contributing](#contributing) @@ -50,7 +50,7 @@ Automated builds of the image are available on [Dockerhub](https://hub.docker.co > **Note**: Builds are also available on [Quay.io](https://quay.io/repository/sameersbn/invoiceplane) ```bash -docker pull sameersbn/invoiceplane:1.4.10-2 +docker pull sameersbn/invoiceplane:1.5.4 ``` Alternatively you can build the image yourself. @@ -93,7 +93,7 @@ docker run --name invoiceplane -itd --restart=always \ --env 'INVOICEPLANE_FQDN=invoice.example.com' \ --env 'INVOICEPLANE_TIMEZONE=Asia/Kolkata' \ --volume /srv/docker/invoiceplane/invoiceplane:/var/lib/invoiceplane \ - sameersbn/invoiceplane:1.4.10-2 app:invoiceplane + sameersbn/invoiceplane:1.5.4 app:invoiceplane ``` Step 3. Launch a NGINX frontend container @@ -103,7 +103,7 @@ docker run --name invoiceplane-nginx -itd --restart=always \ --link invoiceplane:php-fpm \ --volumes-from invoiceplane \ --publish 10080:80 \ - sameersbn/invoiceplane:1.4.10-2 app:nginx + sameersbn/invoiceplane:1.5.4 app:nginx ``` Point your browser to [http://invoice.example.com:10080/setup](http://invoice.example.com:10080/setup) to complete the setup. @@ -137,7 +137,7 @@ Relaunch the container with the `app:backup:create` argument. ```bash docker run --name invoiceplane -it --rm [OPTIONS] \ - sameersbn/invoiceplane:1.4.10-2 app:backup:create + sameersbn/invoiceplane:1.5.4 app:backup:create ``` The backup will be created in the `backups/` folder of the [Persistent](#persistence) volume. You can change the location using the `INVOICEPLANE_BACKUPS_DIR` configuration parameter. @@ -166,7 +166,7 @@ Relaunch the container with the `app:backup:restore` argument. Ensure you launch ```bash docker run --name invoiceplane -it --rm [OPTIONS] \ - sameersbn/invoiceplane:1.4.10-2 app:backup:restore + sameersbn/invoiceplane:1.5.4 app:backup:restore ``` A list of existing backups will be displayed. Select a backup you wish to restore. @@ -175,7 +175,7 @@ To avoid this interaction you can specify the backup filename using the `BACKUP` ```bash docker run --name invoiceplane -it --rm [OPTIONS] \ - sameersbn/invoiceplane:1.4.10-2 app:backup:restore BACKUP=1417624827_invoiceplane_backup.tar + sameersbn/invoiceplane:1.5.4 app:backup:restore BACKUP=1417624827_invoiceplane_backup.tar ``` ## Upgrading @@ -185,7 +185,7 @@ To upgrade to newer releases: 1. Download the updated Docker image: ```bash - docker pull sameersbn/invoiceplane:1.4.10-2 + docker pull sameersbn/invoiceplane:1.5.4 ``` 2. Stop the currently running image: @@ -205,7 +205,7 @@ To upgrade to newer releases: ```bash docker run -name invoiceplane -itd \ [OPTIONS] \ - sameersbn/invoiceplane:1.4.10-2 + sameersbn/invoiceplane:1.5.4 ``` Point your browser to [http://invoice.example.com:10080/setup](http://invoice.example.com:10080/setup) to complete the upgrade. diff --git a/VERSION b/VERSION index 2b8fc45..94fe62c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.10-2 +1.5.4 diff --git a/assets/build/install.sh b/assets/build/install.sh index a06a7b7..f961caa 100644 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -1,23 +1,19 @@ #!/bin/bash set -e -mkdir -p ${INVOICEPLANE_INSTALL_DIR} - -if [[ ! -f ${INVOICEPLANE_BUILD_DIR}/InvoicePlane-${INVOICEPLANE_VERSION}.tar.gz ]]; then +if [[ ! -f ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip ]]; then echo "Downloading InvoicePlane ${INVOICEPLANE_VERSION}..." - wget -nv "https://github.com/InvoicePlane/InvoicePlane/archive/v${INVOICEPLANE_VERSION}.tar.gz" \ - -O ${INVOICEPLANE_BUILD_DIR}/InvoicePlane-${INVOICEPLANE_VERSION}.tar.gz + wget -nv "https://github.com/InvoicePlane/InvoicePlane/releases/download/v${INVOICEPLANE_VERSION}/v${INVOICEPLANE_VERSION}.zip" \ + -O ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip fi echo "Extracting InvoicePlane ${INVOICEPLANE_VERSION}..." -tar -xf ${INVOICEPLANE_BUILD_DIR}/InvoicePlane-${INVOICEPLANE_VERSION}.tar.gz --strip=1 -C ${INVOICEPLANE_INSTALL_DIR} +unzip ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip +mv ip ${INVOICEPLANE_INSTALL_DIR} + mv ${INVOICEPLANE_INSTALL_DIR}/uploads ${INVOICEPLANE_INSTALL_DIR}/uploads.template rm -rf ${INVOICEPLANE_BUILD_DIR}/InvoicePlane-${INVOICEPLANE_VERSION}.tar.gz -echo "Installing composer dependencies..." -cd ${INVOICEPLANE_INSTALL_DIR} -composer install --prefer-source --no-interaction --no-dev -o - ( echo "default_charset = 'UTF-8'" echo "output_buffering = off" @@ -30,6 +26,7 @@ mkdir -p /run/php/ rm -rf /etc/nginx/sites-enabled/default # set directory permissions +cp ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php.example ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php find ${INVOICEPLANE_INSTALL_DIR}/ -type f -print0 | xargs -0 chmod 0640 find ${INVOICEPLANE_INSTALL_DIR}/ -type d -print0 | xargs -0 chmod 0750 chown -R root:${INVOICEPLANE_USER} ${INVOICEPLANE_INSTALL_DIR}/ @@ -37,3 +34,5 @@ chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_INSTALL_DIR}/application/config/ chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_INSTALL_DIR}/application/logs/ chown root:${INVOICEPLANE_USER} ${INVOICEPLANE_INSTALL_DIR}/.user.ini chmod 0644 ${INVOICEPLANE_INSTALL_DIR}/.user.ini +chmod 0660 ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php +chmod 1777 ${INVOICEPLANE_INSTALL_DIR}/vendor/mpdf/mpdf/tmp/ diff --git a/assets/runtime/config/invoiceplane/database.php b/assets/runtime/config/invoiceplane/database.php deleted file mode 100644 index 287e207..0000000 --- a/assets/runtime/config/invoiceplane/database.php +++ /dev/null @@ -1,70 +0,0 @@ - +# InvoicePlane Configuration File + +# Set your URL without trailing slash here, e.g. http://your-domain.com +# If you use a subdomain, use http://subdomain.your-domain.com +# If you use a subfolder, use http://your-domain.com/subfolder +IP_URL= + +# Having problems? Enable debug by changing the value to 'true' to enable advanced logging +ENABLE_DEBUG=false + +# Set this setting to 'true' if you want to disable the setup for security purposes +DISABLE_SETUP=false + +# To remove index.php from the URL, set this setting to 'true'. +# Please notice the additional instructions in the htaccess file! +REMOVE_INDEXPHP=false + +# These database settings are set during the initial setup +DB_HOSTNAME= +DB_USERNAME= +DB_PASSWORD= +DB_DATABASE= +DB_PORT= + +# If you want to be logged out after closing your browser window, set this setting to 0 (ZERO). +# The number represents the amount of minutes after that IP will automatically log out users, +# the default is 10 days. +SESS_EXPIRATION=864000 + +# Enable the deletion of invoices +ENABLE_INVOICE_DELETION=false + +# Disable the read-only mode for invoices +DISABLE_READ_ONLY=false + +## +## DO NOT CHANGE ANY CONFIGURATION VALUES BELOW THIS LINE! +## ======================================================= +## + +# This key is automatically set after the first setup. Do not change it manually! +ENCRYPTION_KEY= +ENCRYPTION_CIPHER=AES-256 + +# Set to true after the initial setup +SETUP_COMPLETED=false diff --git a/assets/runtime/functions b/assets/runtime/functions index 01925ed..98e7cda 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -3,7 +3,8 @@ set -e source ${INVOICEPLANE_RUNTIME_DIR}/env-defaults INVOICEPLANE_TEMPLATES_DIR=${INVOICEPLANE_RUNTIME_DIR}/config -INVOICEPLANE_CONFIG=${INVOICEPLANE_INSTALL_DIR}/index.php +INVOICEPLANE_CONFIG=${INVOICEPLANE_DATA_DIR}/ipconfig.php +INVOICEPLANE_CODEIGNITER_CONFIG=${INVOICEPLANE_INSTALL_DIR}/application/config/config.php INVOICEPLANE_DATABASE_CONFIG=${INVOICEPLANE_INSTALL_DIR}/application/config/database.php INVOICEPLANE_NGINX_CONFIG=/etc/nginx/sites-enabled/InvoicePlane.conf @@ -91,9 +92,26 @@ update_template() { rm -f ${tmp_file} } -invoiceplane_get_database_param() { +invoiceplane_get_param() { local key=${1?missing argument} - exec_as_invoiceplane sed -n -e "s/\([ ]*\)\(\$db\['default'\]\['${key}'\] = '\)\([^ ']*\)\(.*\)$/\3/p" ${INVOICEPLANE_DATABASE_CONFIG} + exec_as_invoiceplane sed -n -e "s/^\([ ]*\)\(${key}[ ]*=[ ]*\)\([^ ]*\)\(.*\)$/\3/p" ${INVOICEPLANE_CONFIG} +} + +invoiceplane_set_param() { + local key=${1?missing argument} + local value=${2?missing argument} + local hide=${3} + if [[ -n ${value} ]]; then + local current=$(invoiceplane_get_param ${key}) + if [[ "${current}" != "${value}" ]]; then + case ${hide} in + true) echo "‣ Setting ipconfig.php parameter: ${key}" ;; + *) echo "‣ Setting ipconfig.php parameter: ${key} = '${value}'" ;; + esac + value="$(echo "${value}" | sed 's|[&]|\\&|g')" + exec_as_invoiceplane sed -i "s|^${key}=.*|${key}=${value}|" ${INVOICEPLANE_CONFIG} + fi + fi } invoiceplane_finalize_database_parameters() { @@ -166,22 +184,33 @@ invoiceplane_finalize_php_fpm_parameters() { INVOICEPLANE_PHP_FPM_PORT=${INVOICEPLANE_PHP_FPM_PORT:-9000} } +invoiceplane_configure_debugging() { + echo "Configuring InvoicePlane::Debugging" + case $DEBUG in + true) invoiceplane_set_param "ENABLE_DEBUG" "true" ;; + *) invoiceplane_set_param "ENABLE_DEBUG" "false" ;; + esac +} + invoiceplane_configure_url() { echo "Configuring InvoicePlane::URL" - sed -i "s|^define('IP_URL', '.*');|define('IP_URL', '"${INVOICEPLANE_URL}"');|" ${INVOICEPLANE_CONFIG} + invoiceplane_set_param "IP_URL" "${INVOICEPLANE_URL}" +} + +invoiceplane_configure_proxy_ips() { + echo "Configuring InvoicePlane::Proxy IPS" + sed -i "s|^\$config\['proxy_ips'\][ ]*=.*;|\$config\['proxy_ips'\] = '"$INVOICEPLANE_PROXY_IPS"';|" ${INVOICEPLANE_CODEIGNITER_CONFIG} } invoiceplane_configure_database() { echo -n "Configuring InvoicePlane::database" invoiceplane_finalize_database_parameters invoiceplane_check_database_connection - - update_template ${INVOICEPLANE_DATABASE_CONFIG} \ - DB_HOST \ - DB_PORT \ - DB_USER \ - DB_PASS \ - DB_NAME + invoiceplane_set_param "DB_HOSTNAME" "${DB_HOST}" + invoiceplane_set_param "DB_PORT" "${DB_PORT}" + invoiceplane_set_param "DB_USERNAME" "${DB_USER}" + invoiceplane_set_param "DB_PASSWORD" "${DB_PASS}" "true" + invoiceplane_set_param "DB_DATABASE" "${DB_NAME}" } invoiceplane_configure_timezone() { @@ -220,7 +249,7 @@ backup_dump_information() { ( echo "info:" echo " invoiceplane_version: ${INVOICEPLANE_VERSION}" - echo " database_adapter: $(invoiceplane_get_database_param dbdriver)" + echo " database_adapter: mysqli" echo " created_at: $(date)" ) > ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml chown ${INVOICEPLANE_USER}: ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml @@ -340,7 +369,10 @@ initialize_datadir() { install_configuration_templates() { echo "Installing configuration templates..." - install_template ${INVOICEPLANE_USER}: invoiceplane/database.php ${INVOICEPLANE_DATABASE_CONFIG} 0640 + if [[ ! -f ${INVOICEPLANE_CONFIG} ]]; then + install_template ${INVOICEPLANE_USER}: invoiceplane/ipconfig.php ${INVOICEPLANE_CONFIG} 0640 + fi + ln -sf ${INVOICEPLANE_CONFIG} ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php if [[ -d /etc/nginx/sites-enabled && ! -f ${INVOICEPLANE_NGINX_CONFIG} ]]; then install_template root: nginx/InvoicePlane.conf ${INVOICEPLANE_NGINX_CONFIG} 0644 @@ -355,7 +387,9 @@ initialize_system() { configure_invoiceplane() { echo "Configuring InvoicePlane..." + invoiceplane_configure_debugging invoiceplane_configure_url + invoiceplane_configure_proxy_ips invoiceplane_configure_database invoiceplane_configure_timezone } diff --git a/docker-compose.yml b/docker-compose.yml index 53cd121..42366df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: invoiceplane: restart: always - image: sameersbn/invoiceplane:1.4.10-2 + image: sameersbn/invoiceplane:1.5.4 command: app:invoiceplane environment: - DEBUG=false @@ -25,7 +25,8 @@ services: - DB_PASS=password - DB_NAME=invoiceplane_db - - INVOICEPLANE_URL=http://invoice.example.com:10080 + - INVOICEPLANE_URL=http://localhost:10080 + - INVOICEPLANE_PROXY_IPS= - INVOICEPLANE_BACKUPS_EXPIRY=0 depends_on: - mysql @@ -34,7 +35,7 @@ services: nginx: restart: always - image: sameersbn/invoiceplane:1.4.10-2 + image: sameersbn/invoiceplane:1.5.4 command: app:nginx environment: - INVOICEPLANE_PHP_FPM_HOST=invoiceplane diff --git a/entrypoint.sh b/entrypoint.sh index 30e61ef..c04b3d0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,7 +12,7 @@ case ${1} in case ${1} in app:invoiceplane) configure_invoiceplane - echo "Starting InvoicePlane php5-fpm..." + echo "Starting InvoicePlane php"${PHP_VERSION}"-fpm..." exec $(which php-fpm${PHP_VERSION}) -F ;; app:nginx)