├── .circleci └── config.yml ├── .dockerignore ├── .gitignore ├── Changelog.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── assets ├── build │ └── install.sh ├── runtime │ ├── config │ │ ├── invoiceplane │ │ │ └── ipconfig.php │ │ └── nginx │ │ │ └── InvoicePlane.conf │ ├── env-defaults │ └── functions └── tools │ └── invoiceplane-backup-create ├── docker-compose.yml └── entrypoint.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: /workdir 5 | docker: 6 | - image: docker:18.03.0-ce-git 7 | environment: 8 | IMAGE_NAME: "sameersbn/invoiceplane" 9 | 10 | steps: 11 | - checkout 12 | 13 | - setup_remote_docker: 14 | version: 18.03.1-ce 15 | 16 | - run: 17 | name: Docker info 18 | command: | 19 | docker version 20 | docker info 21 | 22 | - restore_cache: 23 | keys: 24 | - cache-{{ .Branch }} 25 | paths: 26 | - /cache/layers.tar 27 | 28 | - run: 29 | name: Loading docker cache 30 | command: | 31 | if [[ -f /cache/layers.tar ]]; then 32 | docker load -i /cache/layers.tar 33 | fi 34 | 35 | - run: 36 | name: Build docker image 37 | command: | 38 | docker build --cache-from=${IMAGE_NAME} -t ${IMAGE_NAME} . 39 | 40 | - run: 41 | name: Generate docker build image cache 42 | command: | 43 | mkdir -p /cache 44 | docker save -o /cache/layers.tar ${IMAGE_NAME} 45 | 46 | - save_cache: 47 | key: cache-{{ .Branch }}-{{ epoch }} 48 | paths: 49 | - /cache/layers.tar 50 | 51 | workflows: 52 | version: 2 53 | build-and-test: 54 | jobs: 55 | - build: 56 | filters: 57 | branches: 58 | only: /.*/ 59 | tags: 60 | only: /.*/ 61 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | LICENSE 4 | README.md 5 | Changelog.md 6 | Makefile 7 | docker-compose.yml 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | **1.5.5** 2 | - invoiceplane: upgrade to 1.5.5 3 | 4 | **1.5.4-2** 5 | - fix ownership of configs directory 6 | 7 | **1.5.4** 8 | - invoiceplane: upgrade to 1.5.4 9 | - add `INVOICEPLANE_PROXY_IPS` to configure reverse proxy ips 10 | 11 | **1.5.3** 12 | - invoiceplane: upgrade to 1.5.3 13 | 14 | **1.4.10** 15 | - invoiceplane: security update to 1.4.10 16 | 17 | **1.4.9** 18 | - invoiceplane: upgrade to 1.4.9 19 | 20 | **1.4.8** 21 | - invoiceplane: upgrade to 1.4.8 22 | 23 | **1.4.7** 24 | - invoiceplane: upgrade to 1.4.7 25 | 26 | **1.4.6** 27 | - invoiceplane: upgrade to 1.4.6 28 | 29 | **1.4.5** 30 | - invoiceplane: upgrade to 1.4.5 31 | 32 | **1.4.4-1** 33 | - feature: create backups 34 | - feature: restore backups 35 | - feature: backup expiry 36 | 37 | **1.4.4** 38 | - invoiceplane: upgrade to 1.4.4 39 | 40 | **1.4.3** 41 | - initial creation 42 | 43 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic-20190612 2 | LABEL maintainer="sameer@damagehead.com" 3 | 4 | ENV PHP_VERSION=7.2 \ 5 | INVOICEPLANE_VERSION=1.5.9 \ 6 | INVOICEPLANE_USER=www-data \ 7 | INVOICEPLANE_INSTALL_DIR=/var/www/invoiceplane \ 8 | INVOICEPLANE_DATA_DIR=/var/lib/invoiceplane \ 9 | INVOICEPLANE_CACHE_DIR=/etc/docker-invoiceplane 10 | 11 | ENV INVOICEPLANE_BUILD_DIR=${INVOICEPLANE_CACHE_DIR}/build \ 12 | INVOICEPLANE_RUNTIME_DIR=${INVOICEPLANE_CACHE_DIR}/runtime 13 | 14 | RUN apt-get update \ 15 | && DEBIAN_FRONTEND=noninteractive apt-get install -y wget sudo unzip \ 16 | php${PHP_VERSION}-fpm php${PHP_VERSION}-cli php${PHP_VERSION}-mysql \ 17 | php${PHP_VERSION}-gd php${PHP_VERSION}-json php${PHP_VERSION}-mbstring \ 18 | php${PHP_VERSION}-recode php${PHP_VERSION}-xmlrpc \ 19 | mysql-client nginx gettext-base git \ 20 | && sed -i 's/^listen = .*/listen = 0.0.0.0:9000/' /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf \ 21 | && rm -rf /var/lib/apt/lists/* 22 | 23 | COPY assets/build/ ${INVOICEPLANE_BUILD_DIR}/ 24 | 25 | RUN bash ${INVOICEPLANE_BUILD_DIR}/install.sh 26 | 27 | COPY assets/runtime/ ${INVOICEPLANE_RUNTIME_DIR}/ 28 | 29 | COPY assets/tools/ /usr/bin/ 30 | 31 | COPY entrypoint.sh /sbin/entrypoint.sh 32 | 33 | RUN chmod 755 /sbin/entrypoint.sh 34 | 35 | WORKDIR ${INVOICEPLANE_INSTALL_DIR} 36 | 37 | ENTRYPOINT ["/sbin/entrypoint.sh"] 38 | 39 | CMD ["app:invoiceplane"] 40 | 41 | EXPOSE 80/tcp 9000/tcp 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sameer Naik 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | @docker build --tag=sameersbn/invoiceplane:latest . 5 | 6 | release: build 7 | @docker build --tag=sameersbn/invoiceplane:$(shell cat VERSION) . 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker Repository on Quay.io](https://quay.io/repository/sameersbn/invoiceplane/status "Docker Repository on Quay.io")](https://quay.io/repository/sameersbn/invoiceplane) 2 | 3 | # sameersbn/invoiceplane:1.5.9-3 4 | 5 | - [Introduction](#introduction) 6 | - [Contributing](#contributing) 7 | - [Issues](#issues) 8 | - [Getting started](#getting-started) 9 | - [Installation](#installation) 10 | - [Quickstart](#quickstart) 11 | - [Persistence](#persistence) 12 | - [Maintenance](#maintenance) 13 | - [Creating backups](#creating-backups) 14 | - [Restoring backups](#restoring-backups) 15 | - [Upgrading](#upgrading) 16 | - [Shell Access](#shell-access) 17 | 18 | # Introduction 19 | 20 | `Dockerfile` to create a [Docker](https://www.docker.com/) container image for [InvoicePlane](https://invoiceplane.com/). 21 | 22 | InvoicePlane is a self-hosted open source application for managing your quotes, invoices, clients and payments. 23 | 24 | ## Contributing 25 | 26 | If you find this image useful here's how you can help: 27 | 28 | - Send a pull request with your awesome features and bug fixes 29 | - Help users resolve their [issues](../../issues?q=is%3Aopen+is%3Aissue). 30 | - Support the development of this image with a [donation](http://www.damagehead.com/donate/) 31 | 32 | ## Issues 33 | 34 | Before reporting your issue please try updating Docker to the latest version and check if it resolves the issue. Refer to the Docker [installation guide](https://docs.docker.com/installation) for instructions. 35 | 36 | SELinux users should try disabling SELinux using the command `setenforce 0` to see if it resolves the issue. 37 | 38 | If the above recommendations do not help then [report your issue](../../issues/new) along with the following information: 39 | 40 | - Output of the `docker version` and `docker info` commands 41 | - The `docker run` command or `docker-compose.yml` used to start the image. Mask out the sensitive bits. 42 | - Please state if you are using [Boot2Docker](http://www.boot2docker.io), [VirtualBox](https://www.virtualbox.org), etc. 43 | 44 | # Getting started 45 | 46 | ## Installation 47 | 48 | Automated builds of the image are available on [Dockerhub](https://hub.docker.com/r/sameersbn/invoiceplane) and is the recommended method of installation. 49 | 50 | > **Note**: Builds are also available on [Quay.io](https://quay.io/repository/sameersbn/invoiceplane) 51 | 52 | ```bash 53 | docker pull sameersbn/invoiceplane:1.5.9-3 54 | ``` 55 | 56 | Alternatively you can build the image yourself. 57 | 58 | ```bash 59 | docker build -t sameersbn/invoiceplane github.com/sameersbn/docker-invoiceplane 60 | ``` 61 | 62 | ## Quickstart 63 | 64 | The quickest way to start using this image is with [docker-compose](https://docs.docker.com/compose/). 65 | 66 | ```bash 67 | wget https://raw.githubusercontent.com/sameersbn/docker-invoiceplane/master/docker-compose.yml 68 | ``` 69 | 70 | Update the `INVOICEPLANE_URL` environment variable in the `docker-compose.yml` file with the url from which InvoicePlane will be externally accessible. 71 | 72 | ```bash 73 | docker-compose up 74 | ``` 75 | 76 | Alternatively, you can start InvoicePlane manually using the Docker command line. 77 | 78 | Step 1. Launch a MySQL container 79 | 80 | ```bash 81 | docker run --name invoiceplane-mysql -itd --restart=always \ 82 | --env 'DB_NAME=invoiceplane_db' \ 83 | --env 'DB_USER=invoiceplane' --env 'DB_PASS=password' \ 84 | --volume /srv/docker/invoiceplane/mysql:/var/lib/mysql \ 85 | sameersbn/mysql:5.2.26 86 | ``` 87 | 88 | Step 2. Launch the InvoicePlane php-fpm container 89 | 90 | ```bash 91 | docker run --name invoiceplane -itd --restart=always \ 92 | --link invoiceplane-mysql:mysql \ 93 | --env 'INVOICEPLANE_FQDN=invoice.example.com' \ 94 | --env 'INVOICEPLANE_TIMEZONE=Asia/Kolkata' \ 95 | --volume /srv/docker/invoiceplane/invoiceplane:/var/lib/invoiceplane \ 96 | sameersbn/invoiceplane:1.5.9-3 app:invoiceplane 97 | ``` 98 | 99 | Step 3. Launch a NGINX frontend container 100 | 101 | ```bash 102 | docker run --name invoiceplane-nginx -itd --restart=always \ 103 | --link invoiceplane:php-fpm \ 104 | --volumes-from invoiceplane \ 105 | --publish 10080:80 \ 106 | sameersbn/invoiceplane:1.5.9-3 app:nginx 107 | ``` 108 | 109 | Point your browser to [http://invoice.example.com:10080/setup](http://invoice.example.com:10080/setup) to complete the setup. 110 | 111 | ## Persistence 112 | 113 | For InvoicePlane to preserve its state across container shutdown and startup you should mount a volume at `/var/lib/invoiceplane`. 114 | 115 | > *The [Quickstart](#quickstart) command already mounts a volume for persistence.* 116 | 117 | SELinux users should update the security context of the host mountpoint so that it plays nicely with Docker: 118 | 119 | ```bash 120 | mkdir -p /srv/docker/invoiceplane 121 | chcon -Rt svirt_sandbox_file_t /srv/docker/invoiceplane 122 | ``` 123 | 124 | # Maintenance 125 | 126 | ## Creating backups 127 | 128 | The image allows users to create backups of the InvoicePlane installation using the `app:backup:create` command or the `invoiceplane-backup-create` helper script. The generated backup consists of uploaded files and the sql database. 129 | 130 | Before generating a backup — stop and remove the running instance. 131 | 132 | ```bash 133 | docker stop invoiceplane && docker rm invoiceplane 134 | ``` 135 | 136 | Relaunch the container with the `app:backup:create` argument. 137 | 138 | ```bash 139 | docker run --name invoiceplane -it --rm [OPTIONS] \ 140 | sameersbn/invoiceplane:1.5.9-3 app:backup:create 141 | ``` 142 | 143 | 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. 144 | 145 | > **NOTE** 146 | > 147 | > Backups can also be generated on a running instance using: 148 | > 149 | > ```bash 150 | > docker exec -it invoiceplane invoiceplane-backup-create 151 | > ``` 152 | 153 | By default backups are held indefinitely. Using the `INVOICEPLANE_BACKUPS_EXPIRY` parameter you can configure how long (in seconds) you wish to keep the backups. For example, setting `INVOICEPLANE_BACKUPS_EXPIRY=604800` will remove backups that are older than 7 days. Old backups are only removed when creating a new backup, never automatically. 154 | 155 | ## Restoring Backups 156 | 157 | Backups created using instructions from the [Creating backups](#creating-backups) section can be restored using the `app:backup:restore` argument. 158 | 159 | Before restoring a backup — stop and remove the running instance. 160 | 161 | ```bash 162 | docker stop invoiceplane && docker rm invoiceplane 163 | ``` 164 | 165 | Relaunch the container with the `app:backup:restore` argument. Ensure you launch the container in the interactive mode `-it`. 166 | 167 | ```bash 168 | docker run --name invoiceplane -it --rm [OPTIONS] \ 169 | sameersbn/invoiceplane:1.5.9-3 app:backup:restore 170 | ``` 171 | 172 | A list of existing backups will be displayed. Select a backup you wish to restore. 173 | 174 | To avoid this interaction you can specify the backup filename using the `BACKUP` argument to `app:backup:restore`, eg. 175 | 176 | ```bash 177 | docker run --name invoiceplane -it --rm [OPTIONS] \ 178 | sameersbn/invoiceplane:1.5.9-3 app:backup:restore BACKUP=1417624827_invoiceplane_backup.tar 179 | ``` 180 | 181 | ## Upgrading 182 | 183 | To upgrade to newer releases: 184 | 185 | 1. Download the updated Docker image: 186 | 187 | ```bash 188 | docker pull sameersbn/invoiceplane:1.5.9-3 189 | ``` 190 | 191 | 2. Stop the currently running image: 192 | 193 | ```bash 194 | docker stop invoiceplane 195 | ``` 196 | 197 | 3. Remove the stopped container 198 | 199 | ```bash 200 | docker rm -v invoiceplane 201 | ``` 202 | 203 | 4. Start the updated image 204 | 205 | ```bash 206 | docker run -name invoiceplane -itd \ 207 | [OPTIONS] \ 208 | sameersbn/invoiceplane:1.5.9-3 209 | ``` 210 | 211 | Point your browser to [http://invoice.example.com:10080/setup](http://invoice.example.com:10080/setup) to complete the upgrade. 212 | 213 | ## Shell Access 214 | 215 | For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version `1.3.0` or higher you can access a running containers shell by starting `bash` using `docker exec`: 216 | 217 | ```bash 218 | docker exec -it invoiceplane bash 219 | ``` 220 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.5.9-3 2 | -------------------------------------------------------------------------------- /assets/build/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ ! -f ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip ]]; then 5 | echo "Downloading InvoicePlane ${INVOICEPLANE_VERSION}..." 6 | wget -nv "https://github.com/InvoicePlane/InvoicePlane/releases/download/v${INVOICEPLANE_VERSION}/v${INVOICEPLANE_VERSION}.zip" \ 7 | -O ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip 8 | fi 9 | 10 | echo "Extracting InvoicePlane ${INVOICEPLANE_VERSION}..." 11 | unzip ${INVOICEPLANE_BUILD_DIR}/v${INVOICEPLANE_VERSION}.zip 12 | mv ip ${INVOICEPLANE_INSTALL_DIR} 13 | 14 | mv ${INVOICEPLANE_INSTALL_DIR}/uploads ${INVOICEPLANE_INSTALL_DIR}/uploads.template 15 | rm -rf ${INVOICEPLANE_BUILD_DIR}/InvoicePlane-${INVOICEPLANE_VERSION}.tar.gz 16 | 17 | ( 18 | echo "default_charset = 'UTF-8'" 19 | echo "output_buffering = off" 20 | echo "date.timezone = {{INVOICEPLANE_TIMEZONE}}" 21 | ) > ${INVOICEPLANE_INSTALL_DIR}/.user.ini 22 | 23 | mkdir -p /run/php/ 24 | 25 | # remove default nginx virtualhost 26 | rm -rf /etc/nginx/sites-enabled/default 27 | 28 | # set directory permissions 29 | cp ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php.example ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php 30 | find ${INVOICEPLANE_INSTALL_DIR}/ -type f -print0 | xargs -0 chmod 0640 31 | find ${INVOICEPLANE_INSTALL_DIR}/ -type d -print0 | xargs -0 chmod 0750 32 | chown -R root:${INVOICEPLANE_USER} ${INVOICEPLANE_INSTALL_DIR}/ 33 | chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_INSTALL_DIR}/application/config/ 34 | chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_INSTALL_DIR}/application/logs/ 35 | chown root:${INVOICEPLANE_USER} ${INVOICEPLANE_INSTALL_DIR}/.user.ini 36 | chmod 0644 ${INVOICEPLANE_INSTALL_DIR}/.user.ini 37 | chmod 0660 ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php 38 | chmod 1777 ${INVOICEPLANE_INSTALL_DIR}/vendor/mpdf/mpdf/tmp/ 39 | -------------------------------------------------------------------------------- /assets/runtime/config/invoiceplane/ipconfig.php: -------------------------------------------------------------------------------- 1 | 2 | # InvoicePlane Configuration File 3 | 4 | # Set your URL without trailing slash here, e.g. http://your-domain.com 5 | # If you use a subdomain, use http://subdomain.your-domain.com 6 | # If you use a subfolder, use http://your-domain.com/subfolder 7 | IP_URL= 8 | 9 | # Having problems? Enable debug by changing the value to 'true' to enable advanced logging 10 | ENABLE_DEBUG=false 11 | 12 | # Set this setting to 'true' if you want to disable the setup for security purposes 13 | DISABLE_SETUP=false 14 | 15 | # To remove index.php from the URL, set this setting to 'true'. 16 | # Please notice the additional instructions in the htaccess file! 17 | REMOVE_INDEXPHP=false 18 | 19 | # These database settings are set during the initial setup 20 | DB_HOSTNAME= 21 | DB_USERNAME= 22 | DB_PASSWORD= 23 | DB_DATABASE= 24 | DB_PORT= 25 | 26 | # If you want to be logged out after closing your browser window, set this setting to 0 (ZERO). 27 | # The number represents the amount of minutes after that IP will automatically log out users, 28 | # the default is 10 days. 29 | SESS_EXPIRATION=864000 30 | 31 | # Enable the deletion of invoices 32 | ENABLE_INVOICE_DELETION=false 33 | 34 | # Disable the read-only mode for invoices 35 | DISABLE_READ_ONLY=false 36 | 37 | ## 38 | ## DO NOT CHANGE ANY CONFIGURATION VALUES BELOW THIS LINE! 39 | ## ======================================================= 40 | ## 41 | 42 | # This key is automatically set after the first setup. Do not change it manually! 43 | ENCRYPTION_KEY= 44 | ENCRYPTION_CIPHER=AES-256 45 | 46 | # Set to true after the initial setup 47 | SETUP_COMPLETED=false 48 | -------------------------------------------------------------------------------- /assets/runtime/config/nginx/InvoicePlane.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name {{INVOICEPLANE_FQDN}}; 4 | 5 | root {{INVOICEPLANE_INSTALL_DIR}}; 6 | 7 | client_max_body_size 0; 8 | fastcgi_buffers 64 4K; 9 | 10 | index index.php; 11 | autoindex off; 12 | 13 | error_page 404 /404.html; 14 | 15 | error_page 500 502 503 504 /50x.html; 16 | location = /50x.html { 17 | root /usr/share/nginx/html; 18 | } 19 | 20 | location / { 21 | try_files $uri $uri/ /index.php; 22 | } 23 | 24 | location ~ \.php(?:$|/) { 25 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 26 | include fastcgi_params; 27 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 28 | fastcgi_param PATH_INFO $fastcgi_path_info; 29 | fastcgi_param HTTPS {{INVOICEPLANE_HTTPS}}; 30 | fastcgi_pass {{INVOICEPLANE_PHP_FPM_HOST}}:{{INVOICEPLANE_PHP_FPM_PORT}}; 31 | fastcgi_intercept_errors on; 32 | } 33 | 34 | # Adding the cache control header for js and css files 35 | location ~* \.(?:css|js)$ { 36 | add_header Cache-Control "public, max-age=7200"; 37 | access_log off; 38 | } 39 | 40 | location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { 41 | access_log off; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /assets/runtime/env-defaults: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## DEBUG 4 | DEBUG=${DEBUG:-false} 5 | 6 | ## CORE 7 | INVOICEPLANE_CONFIGS_DIR=${INVOICEPLANE_CONFIGS_DIR:-$INVOICEPLANE_DATA_DIR/configs} 8 | INVOICEPLANE_UPLOADS_DIR=${INVOICEPLANE_UPLOADS_DIR:-$INVOICEPLANE_DATA_DIR/uploads} 9 | INVOICEPLANE_BACKUPS_DIR=${INVOICEPLANE_BACKUPS_DIR:-$INVOICEPLANE_DATA_DIR/backups} 10 | 11 | INVOICEPLANE_URL=${INVOICEPLANE_URL:-$PHP_FPM_ENV_INVOICEPLANE_URL} 12 | INVOICEPLANE_URL=${INVOICEPLANE_URL:-http://localhost} 13 | 14 | # credits: http://stackoverflow.com/a/2506635/4799938 15 | INVOICEPLANE_FQDN=$(sed -e "s/\([^/]*\)\:\/\/\([^@]*@\)\?\([^:/]*\).*/\3/" <<< ${INVOICEPLANE_URL}) 16 | if [[ $(sed -e "s/\([^/]*\)\:\/\/\([^@]*@\)\?\([^:/]*\).*/\1/" <<< ${INVOICEPLANE_URL}) == https ]]; then 17 | INVOICEPLANE_HTTPS=${INVOICEPLANE_HTTPS:-on} 18 | else 19 | INVOICEPLANE_HTTPS=${INVOICEPLANE_HTTPS:-off} 20 | fi 21 | 22 | INVOICEPLANE_TIMEZONE=${INVOICE_PLANE_TIMEZONE:-} # backward compatibility 23 | INVOICEPLANE_TIMEZONE=${INVOICEPLANE_TIMEZONE:-$TZ} 24 | INVOICEPLANE_TIMEZONE=${INVOICEPLANE_TIMEZONE:-UTC} 25 | 26 | ## DATABASE 27 | DB_HOST=${DB_HOST:-} 28 | DB_PORT=${DB_PORT:-} 29 | DB_NAME=${DB_NAME:-} 30 | DB_USER=${DB_USER:-} 31 | DB_PASS=${DB_PASS:-} 32 | 33 | ## PHP_FPM 34 | INVOICEPLANE_PHP_FPM_HOST=${INVOICEPLANE_PHP_FPM_HOST:-} 35 | INVOICEPLANE_PHP_FPM_PORT=${INVOICEPLANE_PHP_FPM_PORT:-} 36 | 37 | ## BACKUPS 38 | INVOICEPLANE_BACKUPS_EXPIRY=${INVOICEPLANE_BACKUPS_EXPIRY:-0} 39 | -------------------------------------------------------------------------------- /assets/runtime/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | source ${INVOICEPLANE_RUNTIME_DIR}/env-defaults 4 | 5 | INVOICEPLANE_TEMPLATES_DIR=${INVOICEPLANE_RUNTIME_DIR}/config 6 | INVOICEPLANE_CONFIG=${INVOICEPLANE_CONFIGS_DIR}/ipconfig.php 7 | INVOICEPLANE_CODEIGNITER_CONFIG=${INVOICEPLANE_INSTALL_DIR}/application/config/config.php 8 | INVOICEPLANE_NGINX_CONFIG=/etc/nginx/sites-enabled/InvoicePlane.conf 9 | 10 | # Compares two version strings `a` and `b` 11 | # Returns 12 | # - negative integer, if `a` is less than `b` 13 | # - 0, if `a` and `b` are equal 14 | # - non-negative integer, if `a` is greater than `b` 15 | vercmp() { 16 | expr '(' "$1" : '\([^.]*\)' ')' '-' '(' "$2" : '\([^.]*\)' ')' '|' \ 17 | '(' "$1.0" : '[^.]*[.]\([^.]*\)' ')' '-' '(' "$2.0" : '[^.]*[.]\([^.]*\)' ')' '|' \ 18 | '(' "$1.0.0" : '[^.]*[.][^.]*[.]\([^.]*\)' ')' '-' '(' "$2.0.0" : '[^.]*[.][^.]*[.]\([^.]*\)' ')' '|' \ 19 | '(' "$1.0.0.0" : '[^.]*[.][^.]*[.][^.]*[.]\([^.]*\)' ')' '-' '(' "$2.0.0.0" : '[^.]*[.][^.]*[.][^.]*[.]\([^.]*\)' ')' 20 | } 21 | 22 | # Read YAML file from Bash script 23 | # Credits: https://gist.github.com/pkuczynski/8665367 24 | parse_yaml() { 25 | local prefix=$2 26 | local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') 27 | sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ 28 | -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | 29 | awk -F$fs '{ 30 | indent = length($1)/2; 31 | vname[indent] = $2; 32 | for (i in vname) {if (i > indent) {delete vname[i]}} 33 | if (length($3) > 0) { 34 | vn=""; for (i=0; i ${VAR} 83 | sed -ri "s/[{]{2}$variable[}]{2}/\${$variable}/g" ${tmp_file} 84 | done 85 | 86 | # Replace placeholders 87 | ( 88 | export ${VARIABLES[@]} 89 | local IFS=":"; sudo -HEu ${USR} envsubst "${VARIABLES[*]/#/$}" < ${tmp_file} > ${FILE} 90 | ) 91 | rm -f ${tmp_file} 92 | } 93 | 94 | invoiceplane_get_param() { 95 | local key=${1?missing argument} 96 | exec_as_invoiceplane sed -n -e "s/^\([ ]*\)\(${key}[ ]*=[ ]*\)\([^ ]*\)\(.*\)$/\3/p" ${INVOICEPLANE_CONFIG} 97 | } 98 | 99 | invoiceplane_set_param() { 100 | local key=${1?missing argument} 101 | local value=${2?missing argument} 102 | local hide=${3} 103 | if [[ -n ${value} ]]; then 104 | local current=$(invoiceplane_get_param ${key}) 105 | if [[ "${current}" != "${value}" ]]; then 106 | case ${hide} in 107 | true) echo "‣ Setting ipconfig.php parameter: ${key}" ;; 108 | *) echo "‣ Setting ipconfig.php parameter: ${key} = '${value}'" ;; 109 | esac 110 | value="$(echo "${value}" | sed 's|[&]|\\&|g')" 111 | exec_as_invoiceplane sed -i "s|^${key}=.*|${key}=${value}|" ${INVOICEPLANE_CONFIG} 112 | fi 113 | fi 114 | } 115 | 116 | invoiceplane_finalize_database_parameters() { 117 | # is a mysql container linked? 118 | if [[ -n ${MYSQL_PORT_3306_TCP_ADDR} ]]; then 119 | DB_TYPE=${DB_TYPE:-mysqli} 120 | DB_HOST=${DB_HOST:-$MYSQL_PORT_3306_TCP_ADDR} 121 | DB_PORT=${DB_PORT:-$MYSQL_PORT_3306_TCP_PORT} 122 | 123 | # support for linked sameersbn/mysql image 124 | DB_USER=${DB_USER:-$MYSQL_ENV_DB_USER} 125 | DB_PASS=${DB_PASS:-$MYSQL_ENV_DB_PASS} 126 | DB_NAME=${DB_NAME:-$MYSQL_ENV_DB_NAME} 127 | 128 | # support for linked orchardup/mysql and enturylink/mysql image 129 | # also supports official mysql image 130 | DB_USER=${DB_USER:-$MYSQL_ENV_MYSQL_USER} 131 | DB_PASS=${DB_PASS:-$MYSQL_ENV_MYSQL_PASSWORD} 132 | DB_NAME=${DB_NAME:-$MYSQL_ENV_MYSQL_DATABASE} 133 | fi 134 | 135 | # set default port, user and database 136 | DB_PORT=${DB_PORT:-3306} 137 | DB_USER=${DB_USER:-root} 138 | DB_NAME=${DB_NAME:-invoiceplane_db} 139 | 140 | if [[ -z ${DB_HOST} ]]; then 141 | echo 142 | echo "ERROR: " 143 | echo " Please configure the database connection." 144 | echo " Cannot continue without a database. Aborting..." 145 | echo 146 | return 1 147 | fi 148 | } 149 | 150 | invoiceplane_check_database_connection() { 151 | prog="mysqladmin -h ${DB_HOST} -P ${DB_PORT} -u ${DB_USER} ${DB_PASS:+-p$DB_PASS} status" 152 | timeout=60 153 | while ! ${prog} >/dev/null 2>&1 154 | do 155 | timeout=$(expr $timeout - 1) 156 | if [[ $timeout -eq 0 ]]; then 157 | echo 158 | echo "Could not connect to database server. Aborting..." 159 | return 1 160 | fi 161 | echo -n "." 162 | sleep 1 163 | done 164 | echo 165 | } 166 | 167 | invoiceplane_finalize_php_fpm_parameters() { 168 | # is a invoiceplane-php-fpm container linked? 169 | if [[ -n ${PHP_FPM_PORT_9000_TCP_ADDR} ]]; then 170 | INVOICEPLANE_PHP_FPM_HOST=${INVOICEPLANE_PHP_FPM_HOST:-$PHP_FPM_PORT_9000_TCP_ADDR} 171 | INVOICEPLANE_PHP_FPM_PORT=${INVOICEPLANE_PHP_FPM_PORT:-$PHP_FPM_PORT_9000_TCP_PORT} 172 | fi 173 | 174 | if [[ -z ${INVOICEPLANE_PHP_FPM_HOST} ]]; then 175 | echo 176 | echo "ERROR: " 177 | echo " Please configure the php-fpm connection. Aborting..." 178 | echo 179 | return 1 180 | fi 181 | 182 | # use default php-fpm port number if it is still not set 183 | INVOICEPLANE_PHP_FPM_PORT=${INVOICEPLANE_PHP_FPM_PORT:-9000} 184 | } 185 | 186 | invoiceplane_configure_debugging() { 187 | echo "Configuring InvoicePlane::Debugging" 188 | case $DEBUG in 189 | true) invoiceplane_set_param "ENABLE_DEBUG" "true" ;; 190 | *) invoiceplane_set_param "ENABLE_DEBUG" "false" ;; 191 | esac 192 | } 193 | 194 | invoiceplane_configure_url() { 195 | echo "Configuring InvoicePlane::URL" 196 | invoiceplane_set_param "IP_URL" "${INVOICEPLANE_URL}" 197 | } 198 | 199 | invoiceplane_configure_proxy_ips() { 200 | echo "Configuring InvoicePlane::Proxy IPS" 201 | sed -i "s|^\$config\['proxy_ips'\][ ]*=.*;|\$config\['proxy_ips'\] = '"$INVOICEPLANE_PROXY_IPS"';|" ${INVOICEPLANE_CODEIGNITER_CONFIG} 202 | } 203 | 204 | invoiceplane_configure_database() { 205 | echo -n "Configuring InvoicePlane::database" 206 | invoiceplane_finalize_database_parameters 207 | invoiceplane_check_database_connection 208 | invoiceplane_set_param "DB_HOSTNAME" "${DB_HOST}" 209 | invoiceplane_set_param "DB_PORT" "${DB_PORT}" 210 | invoiceplane_set_param "DB_USERNAME" "${DB_USER}" 211 | invoiceplane_set_param "DB_PASSWORD" "${DB_PASS}" "true" 212 | invoiceplane_set_param "DB_DATABASE" "${DB_NAME}" 213 | } 214 | 215 | invoiceplane_configure_timezone() { 216 | update_template ${INVOICEPLANE_INSTALL_DIR}/.user.ini INVOICEPLANE_TIMEZONE 217 | } 218 | 219 | nginx_configure_virtualhost() { 220 | echo "Configuring InvoicePlane virtualhost..." 221 | invoiceplane_finalize_php_fpm_parameters 222 | update_template ${INVOICEPLANE_NGINX_CONFIG} \ 223 | INVOICEPLANE_FQDN \ 224 | INVOICEPLANE_HTTPS \ 225 | INVOICEPLANE_PHP_FPM_HOST \ 226 | INVOICEPLANE_PHP_FPM_PORT 227 | } 228 | 229 | backup_dump_database() { 230 | echo "Dumping MySQL database ${DB_NAME}..." 231 | MYSQL_PWD=${DB_PASS} mysqldump --lock-tables --add-drop-table \ 232 | --host ${DB_HOST} --port ${DB_PORT} \ 233 | --user ${DB_USER} ${DB_NAME} > ${INVOICEPLANE_BACKUPS_DIR}/database.sql 234 | chown ${INVOICEPLANE_USER}: ${INVOICEPLANE_BACKUPS_DIR}/database.sql 235 | exec_as_invoiceplane gzip -f ${INVOICEPLANE_BACKUPS_DIR}/database.sql 236 | } 237 | 238 | backup_dump_directory() { 239 | local directory=${1} 240 | local dirname=$(basename ${directory}) 241 | local extension=${2} 242 | 243 | echo "Dumping ${dirname}..." 244 | exec_as_invoiceplane tar -cf ${INVOICEPLANE_BACKUPS_DIR}/${dirname}${extension} -C ${directory} . 245 | } 246 | 247 | backup_dump_information() { 248 | ( 249 | echo "info:" 250 | echo " invoiceplane_version: ${INVOICEPLANE_VERSION}" 251 | echo " database_adapter: mysqli" 252 | echo " created_at: $(date)" 253 | ) > ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml 254 | chown ${INVOICEPLANE_USER}: ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml 255 | } 256 | 257 | backup_create_archive() { 258 | local tar_file="$(date +%s)_invoiceplane_backup.tar" 259 | 260 | echo "Creating backup archive: ${tar_file}..." 261 | exec_as_invoiceplane tar -cf ${INVOICEPLANE_BACKUPS_DIR}/${tar_file} -C ${INVOICEPLANE_BACKUPS_DIR} $@ 262 | exec_as_invoiceplane chmod 0755 ${INVOICEPLANE_BACKUPS_DIR}/${tar_file} 263 | 264 | for f in $@ 265 | do 266 | exec_as_invoiceplane rm -rf ${INVOICEPLANE_BACKUPS_DIR}/${f} 267 | done 268 | } 269 | 270 | backup_purge_expired() { 271 | if [[ ${INVOICEPLANE_BACKUPS_EXPIRY} -gt 0 ]]; then 272 | echo -n "Deleting old backups... " 273 | local removed=0 274 | local now=$(date +%s) 275 | local cutoff=$(expr ${now} - ${INVOICEPLANE_BACKUPS_EXPIRY}) 276 | for backup in $(ls ${INVOICEPLANE_BACKUPS_DIR}/*_invoiceplane_backup.tar) 277 | do 278 | local timestamp=$(stat -c %Y ${backup}) 279 | if [[ ${timestamp} -lt ${cutoff} ]]; then 280 | rm ${backup} 281 | removed=$(expr ${removed} + 1) 282 | fi 283 | done 284 | echo "(${removed} removed)" 285 | fi 286 | } 287 | 288 | backup_restore_unpack() { 289 | local backup=${1} 290 | echo "Unpacking ${backup}..." 291 | tar xf ${INVOICEPLANE_BACKUPS_DIR}/${backup} -C ${INVOICEPLANE_BACKUPS_DIR} 292 | } 293 | 294 | backup_restore_validate() { 295 | eval $(parse_yaml ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml backup_) 296 | 297 | ## version check 298 | if [[ $(vercmp ${INVOICEPLANE_VERSION} ${backup_info_invoiceplane_version}) -lt 0 ]]; then 299 | echo 300 | echo "ERROR: " 301 | echo " Cannot restore backup for version ${backup_info_invoiceplane_version} on a ${INVOICEPLANE_VERSION} instance." 302 | echo " You can only restore backups generated for versions <= ${INVOICEPLANE_VERSION}." 303 | echo " Please use sameersbn/invoiceplane:${backup_info_invoiceplane_version} to restore this backup." 304 | echo " Cannot continue. Aborting!" 305 | echo 306 | return 1 307 | fi 308 | exec_as_invoiceplane rm -rf ${INVOICEPLANE_BACKUPS_DIR}/backup_information.yml 309 | } 310 | 311 | backup_restore_database() { 312 | echo "Restoring MySQL database..." 313 | gzip -dc ${INVOICEPLANE_BACKUPS_DIR}/database.sql.gz | \ 314 | MYSQL_PWD=${DB_PASS} mysql \ 315 | --host ${DB_HOST} --port ${DB_PORT} \ 316 | --user ${DB_USER} ${DB_NAME} 317 | exec_as_invoiceplane rm -rf ${INVOICEPLANE_BACKUPS_DIR}/database.sql.gz 318 | } 319 | 320 | backup_restore_directory() { 321 | local directory=${1} 322 | local dirname=$(basename ${directory}) 323 | local extension=${2} 324 | 325 | echo "Restoring ${dirname}..." 326 | files=($(shopt -s nullglob;shopt -s dotglob;echo ${directory}/*)) 327 | if [[ ${#files[@]} -gt 0 ]]; then 328 | exec_as_invoiceplane mv ${directory} ${directory}.$(date +%s) 329 | else 330 | exec_as_invoiceplane rm -rf ${directory} 331 | fi 332 | exec_as_invoiceplane mkdir -p ${directory} 333 | exec_as_invoiceplane tar -xf ${INVOICEPLANE_BACKUPS_DIR}/${dirname}${extension} -C ${directory} 334 | exec_as_invoiceplane rm -rf ${INVOICEPLANE_BACKUPS_DIR}/${dirname}${extension} 335 | } 336 | 337 | initialize_datadir() { 338 | echo "Initializing datadir..." 339 | chmod 0755 ${INVOICEPLANE_DATA_DIR} 340 | chown ${INVOICEPLANE_USER}: ${INVOICEPLANE_DATA_DIR} 341 | 342 | # initialize configs directory 343 | mkdir -p ${INVOICEPLANE_CONFIGS_DIR} 344 | chmod 0755 ${INVOICEPLANE_CONFIGS_DIR} 345 | chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_CONFIGS_DIR} 346 | 347 | # initialize uploads directory 348 | if [[ ! -d ${INVOICEPLANE_UPLOADS_DIR} ]]; then 349 | cp -a ${INVOICEPLANE_INSTALL_DIR}/uploads.template ${INVOICEPLANE_UPLOADS_DIR} 350 | fi 351 | rm -rf ${INVOICEPLANE_INSTALL_DIR}/uploads 352 | ln -sf ${INVOICEPLANE_UPLOADS_DIR} ${INVOICEPLANE_INSTALL_DIR}/uploads 353 | 354 | mkdir -p ${INVOICEPLANE_UPLOADS_DIR}/customer_files 355 | chmod 0750 ${INVOICEPLANE_UPLOADS_DIR}/customer_files 356 | 357 | mkdir -p ${INVOICEPLANE_UPLOADS_DIR}/temp/mpdf 358 | chmod 0750 ${INVOICEPLANE_UPLOADS_DIR}/temp/mpdf 359 | 360 | chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_UPLOADS_DIR} 361 | 362 | CURRENT_VERSION= 363 | [[ -f ${INVOICEPLANE_DATA_DIR}/VERSION ]] && CURRENT_VERSION=$(cat ${INVOICEPLANE_DATA_DIR}/VERSION) 364 | if [[ ${INVOICEPLANE_VERSION} != ${CURRENT_VERSION} ]]; then 365 | echo -n "${INVOICEPLANE_VERSION}" > ${INVOICEPLANE_DATA_DIR}/VERSION 366 | fi 367 | 368 | # create backups directory 369 | mkdir -p ${INVOICEPLANE_BACKUPS_DIR} 370 | chmod -R 0755 ${INVOICEPLANE_BACKUPS_DIR} 371 | chown -R ${INVOICEPLANE_USER}: ${INVOICEPLANE_BACKUPS_DIR} 372 | } 373 | 374 | install_configuration_templates() { 375 | echo "Installing configuration templates..." 376 | if [[ ! -f ${INVOICEPLANE_CONFIG} ]]; then 377 | if [[ -f ${INVOICEPLANE_DATA_DIR}/ipconfig.php ]]; then 378 | # backward compatibility == 1.5.4 379 | mv ${INVOICEPLANE_DATA_DIR}/ipconfig.php ${INVOICEPLANE_CONFIG} 380 | else 381 | install_template ${INVOICEPLANE_USER}: invoiceplane/ipconfig.php ${INVOICEPLANE_CONFIG} 0640 382 | fi 383 | fi 384 | ln -sf ${INVOICEPLANE_CONFIG} ${INVOICEPLANE_INSTALL_DIR}/ipconfig.php 385 | 386 | if [[ -d /etc/nginx/sites-enabled && ! -f ${INVOICEPLANE_NGINX_CONFIG} ]]; then 387 | install_template root: nginx/InvoicePlane.conf ${INVOICEPLANE_NGINX_CONFIG} 0644 388 | update_template ${INVOICEPLANE_NGINX_CONFIG} INVOICEPLANE_INSTALL_DIR 389 | fi 390 | } 391 | 392 | initialize_system() { 393 | initialize_datadir 394 | install_configuration_templates 395 | } 396 | 397 | configure_invoiceplane() { 398 | echo "Configuring InvoicePlane..." 399 | invoiceplane_configure_debugging 400 | invoiceplane_configure_url 401 | invoiceplane_configure_proxy_ips 402 | invoiceplane_configure_database 403 | invoiceplane_configure_timezone 404 | } 405 | 406 | configure_nginx() { 407 | echo "Configuring nginx..." 408 | nginx_configure_virtualhost 409 | } 410 | 411 | backup_create() { 412 | echo -n "Checking database connection" 413 | invoiceplane_finalize_database_parameters 414 | invoiceplane_check_database_connection 415 | 416 | backup_dump_database 417 | backup_dump_directory ${INVOICEPLANE_CONFIGS_DIR} .tar.gz 418 | backup_dump_directory ${INVOICEPLANE_UPLOADS_DIR} .tar.gz 419 | backup_dump_information 420 | backup_create_archive backup_information.yml database.sql.gz configs.tar.gz uploads.tar.gz 421 | backup_purge_expired 422 | } 423 | 424 | backup_restore() { 425 | local tar_file= 426 | local interactive=true 427 | for arg in $@ 428 | do 429 | if [[ $arg == BACKUP=* ]]; then 430 | tar_file=${arg##BACKUP=} 431 | interactive=false 432 | break 433 | fi 434 | done 435 | 436 | # user needs to select the backup to restore 437 | if [[ $interactive == true ]]; then 438 | num_backups=$(ls ${INVOICEPLANE_BACKUPS_DIR}/*_invoiceplane_backup.tar | wc -l) 439 | if [[ $num_backups -eq 0 ]]; then 440 | echo "No backups exist at ${INVOICEPLANE_BACKUPS_DIR}. Cannot continue." 441 | return 1 442 | fi 443 | 444 | echo 445 | for b in $(ls ${INVOICEPLANE_BACKUPS_DIR} | grep _invoiceplane_backup.tar | sort -r) 446 | do 447 | echo "‣ $b (created at $(date --date="@${b%%_invoiceplane_backup.tar}" +'%d %b, %G - %H:%M:%S %Z'))" 448 | done 449 | echo 450 | 451 | read -p "Select a backup to restore: " tar_file 452 | 453 | if [[ -z ${tar_file} ]]; then 454 | echo "Backup not specified. Exiting..." 455 | return 1 456 | fi 457 | fi 458 | 459 | if [[ ! -f ${INVOICEPLANE_BACKUPS_DIR}/${tar_file} ]]; then 460 | echo "Specified backup does not exist. Aborting..." 461 | return 1 462 | fi 463 | 464 | echo -n "Checking database connection" 465 | invoiceplane_finalize_database_parameters 466 | invoiceplane_check_database_connection 467 | 468 | backup_restore_unpack ${tar_file} 469 | backup_restore_validate 470 | backup_restore_database 471 | backup_restore_directory ${INVOICEPLANE_CONFIGS_DIR} .tar.gz 472 | backup_restore_directory ${INVOICEPLANE_UPLOADS_DIR} .tar.gz 473 | } 474 | -------------------------------------------------------------------------------- /assets/tools/invoiceplane-backup-create: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## Script to generate backup of a running InvoicePlane instance from the BASH shell 3 | 4 | set -e 5 | source ${INVOICEPLANE_RUNTIME_DIR}/functions 6 | 7 | backup_create $@ 8 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | mysql: 5 | restart: always 6 | image: sameersbn/mysql:5.2.26 7 | environment: 8 | - DB_USER=invoiceplane 9 | - DB_PASS=password 10 | - DB_NAME=invoiceplane_db 11 | volumes: 12 | - /srv/docker/invoiceplane/mysql:/var/lib/mysql 13 | 14 | invoiceplane: 15 | restart: always 16 | image: sameersbn/invoiceplane:1.5.9-3 17 | command: app:invoiceplane 18 | environment: 19 | - DEBUG=false 20 | - TZ=Asia/Kolkata 21 | 22 | - DB_TYPE=mysqli 23 | - DB_HOST=mysql 24 | - DB_USER=invoiceplane 25 | - DB_PASS=password 26 | - DB_NAME=invoiceplane_db 27 | 28 | - INVOICEPLANE_URL=http://localhost:10080 29 | - INVOICEPLANE_PROXY_IPS= 30 | - INVOICEPLANE_BACKUPS_EXPIRY=0 31 | depends_on: 32 | - mysql 33 | volumes: 34 | - /srv/docker/invoiceplane/invoiceplane:/var/lib/invoiceplane 35 | 36 | nginx: 37 | restart: always 38 | image: sameersbn/invoiceplane:1.5.9-3 39 | command: app:nginx 40 | environment: 41 | - INVOICEPLANE_PHP_FPM_HOST=invoiceplane 42 | - INVOICEPLANE_PHP_FPM_PORT=9000 43 | depends_on: 44 | - invoiceplane 45 | ports: 46 | - "10080:80" 47 | volumes_from: 48 | - invoiceplane 49 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | source ${INVOICEPLANE_RUNTIME_DIR}/functions 4 | 5 | [[ $DEBUG == true ]] && set -x 6 | 7 | case ${1} in 8 | app:invoiceplane|app:nginx|app:backup:create|app:backup:restore) 9 | 10 | initialize_system 11 | 12 | case ${1} in 13 | app:invoiceplane) 14 | configure_invoiceplane 15 | echo "Starting InvoicePlane php"${PHP_VERSION}"-fpm..." 16 | exec $(which php-fpm${PHP_VERSION}) -F 17 | ;; 18 | app:nginx) 19 | configure_nginx 20 | echo "Starting nginx..." 21 | exec $(which nginx) -c /etc/nginx/nginx.conf -g "daemon off;" 22 | ;; 23 | app:backup:create) 24 | shift 1 25 | backup_create 26 | ;; 27 | app:backup:restore) 28 | shift 1 29 | backup_restore $@ 30 | ;; 31 | esac 32 | ;; 33 | app:help) 34 | echo "Available options:" 35 | echo " app:invoiceplane - Starts the InvoicePlane php5-fpm server (default)" 36 | echo " app:nginx - Starts the nginx server" 37 | echo " app:backup:create - Create a backup" 38 | echo " app:backup:restore - Restore an existing backup" 39 | echo " app:help - Displays the help" 40 | echo " [command] - Execute the specified command, eg. bash." 41 | ;; 42 | *) 43 | exec "$@" 44 | ;; 45 | esac 46 | --------------------------------------------------------------------------------