Skip to content

Commit

Permalink
Merge branch 'invoiceplane-1.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sameer Naik committed Oct 22, 2017
2 parents 9d902c6 + 54908c3 commit a394f20
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.tar.*
*.zip
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM sameersbn/ubuntu:14.04.20170123
FROM sameersbn/ubuntu:14.04.20170724
MAINTAINER [email protected]

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 \
Expand All @@ -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}/
Expand All @@ -40,4 +38,4 @@ WORKDIR ${INVOICEPLANE_INSTALL_DIR}
ENTRYPOINT ["/sbin/entrypoint.sh"]
CMD ["app:invoiceplane"]

EXPOSE 9000
EXPOSE 80/tcp 9000/tcp
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.10-2
1.5.4
19 changes: 9 additions & 10 deletions assets/build/install.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -30,10 +26,13 @@ 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}/
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/
70 changes: 0 additions & 70 deletions assets/runtime/config/invoiceplane/database.php

This file was deleted.

47 changes: 47 additions & 0 deletions assets/runtime/config/invoiceplane/ipconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php exit('No direct script access allowed'); ?>
# 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
60 changes: 47 additions & 13 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit a394f20

Please sign in to comment.