diff --git a/.github/workflows/image-dev.yml b/.github/workflows/image-dev.yml index 68fe7dc..40b0269 100644 --- a/.github/workflows/image-dev.yml +++ b/.github/workflows/image-dev.yml @@ -21,5 +21,5 @@ jobs: uses: docker/build-push-action@v6 with: push: true - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/386,linux/arm64,linux/arm/v8,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x tags: mhzawadi/invoiceplane:dev diff --git a/Dockerfile b/Dockerfile index e7b237f..0303bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ RUN cd /tmp && \ WORKDIR /var/www/html -VOLUME /var/www/html/uploads +VOLUME /var/www/html/uploads /var/www/html/assets/core/css /var/www/html/application/views EXPOSE 80 ENTRYPOINT ["/config/start.sh"] CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md index f301543..25e7667 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ ## How to use this Docker image +This image will export 3 directories, if you dont setup a volume for them Docker will. + +- /var/www/html/uploads (Uploaded images) +- /var/www/html/assets/core/css (custom styles) +- /var/www/html/application/views (Customized templates) + ### Mysql Run a MySQL database, dedicated to invoiceplane @@ -31,7 +37,12 @@ This does take some time, so dont try to get invoiceplane setup too quick ### InvoicePlane ```bash -docker run -ti -d -p 80:80 --name invoiceplane --link invoiceplane-mysql:mysql mhzawadi/invoiceplane +docker run -ti -d -p 80:80 --name invoiceplane \ +--link invoiceplane-mysql:mysql \ +--volume "/your/path/to/invoiceplane/uploads:/var/www/html/uploads" \ +--volume "/your/path/to/invoiceplane/assets:/var/www/html/assets/core/css" \ +--volume "/your/path/to/invoiceplane/views:/var/www/html/application/views" \ +mhzawadi/invoiceplane ``` We are linking the two containers and expose the HTTP port, once MySQL is up and running setup of invoiceplane should be quick. @@ -60,15 +71,45 @@ if you run docker swarm, you can add your config to docker swarm config and have Mount your config to `/var/www/html/ipconfig.php` +Or you can pass all the config via environment variables, see below for some of the basics. +Once you have your instance setup, you will want to collect the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER`. As that is used to store passwords. + +The below commands will display the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER` + +``` +ID=$(docker ps | grep 'mhzawadi/invoiceplane' | awk '{print $1}'); +docker exec -it "$ID" /bin/cat ipconfig.php | grep ENCRYPTION_KEY; +docker exec -it "$ID" /bin/cat ipconfig.php | grep ENCRYPTION_CIPHER; +``` + +Update your docker-compose file with them, also add `SETUP_COMPLETED=true`. + +the `environment` section of your `docker-compose.yml` should have some like the below + +``` + - TZ=utc + - MYSQL_HOST=mariadb_10_4 + - MYSQL_USER=InvoicePlane + - MYSQL_PASSWORD=invoiceplane + - MYSQL_DB=InvoicePlane + - IP_URL=http://invoiceplane.docker.local + - DISABLE_SETUP=true + - SETUP_COMPLETED=true + - ENCRYPTION_CIPHER=base64:LgrA+4Df/kJvZIx+GBech8PRTYuO+lbIoF5CgJ59iJM= + - ENCRYPTION_CIPHER=AES-256 +``` + ### Environment variables summary - TZ: the timezone for PHP +- IP_URL: This is the host that you will access the site on +- REMOVE_INDEXPHP: To remove index.php from the URL + - the bundled nginx has the config to work with this set to `true` - MYSQL_HOST: the MySQL server - MYSQL_USER: the username for MySQL - MYSQL_PASSWORD: the password for MySQL - MYSQL_DB: the MySQL database - MYSQL_PORT: the MySQL port, if not 3306 -- IP_URL: This is the host that you will access the site on - DISABLE_SETUP: Have you run setup? ## Docker hub tags diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index cb97761..6ec1a35 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -24,7 +24,6 @@ services: image: mhzawadi/invoiceplane:dev-code volumes: - invoiceplane_data:/var/www/html/uploads - - /Users/matt/git/code-InvoicePlane:/var/www/html environment: - TZ=utc - MYSQL_HOST=mariadb_10_4 diff --git a/docker-compose.yml b/docker-compose.yml index 44f25e9..6f6a4a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,9 @@ version: '3.5' # docker stack deploy --compose-file stack-invoiceplane.yml invoiceplane volumes: - invoiceplane_data: + invoiceplane_uploads: + invoiceplane_css: + invoiceplane_views: mariadb_10_4: services: @@ -23,14 +25,17 @@ services: invoiceplane: image: mhzawadi/invoiceplane volumes: - - invoiceplane_data:/var/www/html/uploads + - invoiceplane_uploads:/var/www/html/uploads + - invoiceplane_css:/var/www/html/assets/core/css + - invoiceplane_views:/var/www/html/application/views environment: - TZ=utc - MYSQL_HOST=mariadb_10_4 - - MYSQL_USER=InvoicePlane + - MYSQL_USER=invoiceplane - MYSQL_PASSWORD=invoiceplane - - MYSQL_DB=InvoicePlane + - MYSQL_DB=invoiceplane - IP_URL=http://invoiceplane.docker.local + - REMOVE_INDEXPHP=true - DISABLE_SETUP=false labels: - "traefik.http.routers.invoiceplane.rule=Host(`invoiceplane.docker.local`)" diff --git a/setup/start.sh b/setup/start.sh index 33c46ae..109b06c 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -4,20 +4,39 @@ ln -s /dev/stdout /var/log/php81/error.log ln -s /dev/stdout /var/log/nginx/access.log ln -s /dev/stdout /var/log/nginx/error.log -if [ ! -f "/var/www/html/ipconfig.php" ]; then - sed \ - -e "s/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/" \ - -e "s/DB_USERNAME=/DB_USERNAME=${MYSQL_USER}/" \ - -e "s/DB_PASSWORD=/DB_PASSWORD=${MYSQL_PASSWORD}/" \ - -e "s/DB_DATABASE=/DB_DATABASE=${MYSQL_DB}/" \ - -e "s/DB_PORT=/DB_PORT=${MYSQL_PORT}/" \ - -e "s!IP_URL=!IP_URL=${IP_URL}!" \ - -e "s/DISABLE_SETUP=false/DISABLE_SETUP=${DISABLE_SETUP}/" \ - /var/www/html/ipconfig.php.example > /var/www/html/ipconfig.php; +if [ ! -f "/var/www/html/ipconfig.php" ] +then + cp /var/www/html/ipconfig.php.example /var/www/html/ipconfig.php +fi + +[ -n "$IP_URL" ] && sed -i -e "s!IP_URL=!IP_URL=${IP_URL}!" /var/www/html/ipconfig.php +[ -n "$ENABLE_DEBUG" ] && sed -i -e "s/ENABLE_DEBUG=.*/ENABLE_DEBUG=${ENABLE_DEBUG}/" /var/www/html/ipconfig.php +[ -n "$DISABLE_SETUP" ] && sed -i -e "s/DISABLE_SETUP=.*/DISABLE_SETUP=${DISABLE_SETUP}/" /var/www/html/ipconfig.php +[ -n "$REMOVE_INDEXPHP" ] && sed -i -e "s/REMOVE_INDEXPHP=.*/REMOVE_INDEXPHP=${REMOVE_INDEXPHP}/" /var/www/html/ipconfig.php + +[ -n "$MYSQL_HOST" ] && sed -i -e "s/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/" /var/www/html/ipconfig.php +[ -n "$MYSQL_USER" ] && sed -i -e "s/DB_USERNAME=/DB_USERNAME=${MYSQL_USER}/" /var/www/html/ipconfig.php +[ -n "$MYSQL_PASSWORD" ] && sed -i -e "s/DB_PASSWORD=/DB_PASSWORD=${MYSQL_PASSWORD}/" /var/www/html/ipconfig.php +[ -n "$MYSQL_DB" ] && sed -i -e "s/DB_DATABASE=/DB_DATABASE=${MYSQL_DB}/" /var/www/html/ipconfig.php +[ -n "$MYSQL_PORT" ] && sed -i -e "s/DB_PORT=/DB_PORT=${MYSQL_PORT}/" /var/www/html/ipconfig.php + +[ -n "$SESS_EXPIRATION" ] && sed -i -e "s/SESS_EXPIRATION=/SESS_EXPIRATION=${SESS_EXPIRATION}/" /var/www/html/ipconfig.php +[ -n "$SESS_MATCH_IP" ] && sed -i -e "s/SESS_MATCH_IP=/SESS_MATCH_IP=${SESS_MATCH_IP}/" /var/www/html/ipconfig.php +[ -n "$ENABLE_INVOICE_DELETION" ] && sed -i -e "s/ENABLE_INVOICE_DELETION=/ENABLE_INVOICE_DELETION=${ENABLE_INVOICE_DELETION}/" /var/www/html/ipconfig.php +[ -n "$DISABLE_READ_ONLY" ] && sed -i -e "s/DISABLE_READ_ONLY=/DISABLE_READ_ONLY=${DISABLE_READ_ONLY}/" /var/www/html/ipconfig.php + +### CRITICAL +if [ -n "$SETUP_COMPLETED" ]; then + [ -n "$ENCRYPTION_KEY" ] && sed -i -e "s/ENCRYPTION_KEY=.*/ENCRYPTION_KEY=${ENCRYPTION_KEY}/" /var/www/html/ipconfig.php + [ -n "$ENCRYPTION_CIPHER" ] && sed -i -e "s/ENCRYPTION_CIPHER=.*/ENCRYPTION_CIPHER=${ENCRYPTION_CIPHER}/" /var/www/html/ipconfig.php + sed -i -e "s/SETUP_COMPLETED=.*/SETUP_COMPLETED=${SETUP_COMPLETED}/" /var/www/html/ipconfig.php fi chown nobody:nginx /var/www/html/ipconfig.php; +chown -R nobody:nginx /var/www/html/uploads; +chown -R nobody:nginx /var/www/html/assets/core/css; +chown -R nobody:nginx /var/www/html/application/views; php-fpm81