From fdffc333a44676dda50813f6b86f289101077228 Mon Sep 17 00:00:00 2001 From: Matthew Horwood Date: Wed, 27 Dec 2023 21:09:55 +0000 Subject: [PATCH 1/5] feat: new architectures --- .github/workflows/image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-dev.yml b/.github/workflows/image-dev.yml index 1a9246f..b5cdab9 100644 --- a/.github/workflows/image-dev.yml +++ b/.github/workflows/image-dev.yml @@ -21,5 +21,5 @@ jobs: uses: docker/build-push-action@v5 with: push: true - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/arm/v7 tags: mhzawadi/invoiceplane:dev From eae0e5d1c9d791eb8acf30020a57a11beceec223 Mon Sep 17 00:00:00 2001 From: Matthew Horwood Date: Wed, 27 Dec 2023 21:12:08 +0000 Subject: [PATCH 2/5] chor: more of the same --- .github/workflows/image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-dev.yml b/.github/workflows/image-dev.yml index b5cdab9..48c8190 100644 --- a/.github/workflows/image-dev.yml +++ b/.github/workflows/image-dev.yml @@ -21,5 +21,5 @@ jobs: uses: docker/build-push-action@v5 with: push: true - platforms: linux/amd64,linux/amd64/v2,linux/amd64/v3,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,linux/riscv64 tags: mhzawadi/invoiceplane:dev From 356ec85676ebb0978b6eb5b0a033cb7b4ec7ae29 Mon Sep 17 00:00:00 2001 From: Matthew Horwood Date: Wed, 27 Dec 2023 21:13:15 +0000 Subject: [PATCH 3/5] bug: not that --- .github/workflows/image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-dev.yml b/.github/workflows/image-dev.yml index 48c8190..99723a1 100644 --- a/.github/workflows/image-dev.yml +++ b/.github/workflows/image-dev.yml @@ -21,5 +21,5 @@ jobs: uses: docker/build-push-action@v5 with: push: true - 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,linux/riscv64 + 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 From b6fe191c97f250542f0d1b07daec3f746ea595b1 Mon Sep 17 00:00:00 2001 From: Matthew Horwood Date: Wed, 24 Jan 2024 21:06:01 +0000 Subject: [PATCH 4/5] feat: allow setting all config in environment chor: update compose doc: update readme --- Dockerfile | 2 +- README.md | 45 ++++++++++++++++++++++++++++++++++++++++-- docker-compose-dev.yml | 1 - docker-compose.yml | 8 ++++++-- setup/start.sh | 39 +++++++++++++++++++++++++++--------- 5 files changed, 80 insertions(+), 15 deletions(-) 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..71139a9 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 collect the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER` and + +``` +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 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..0752c90 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,7 +25,9 @@ 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 diff --git a/setup/start.sh b/setup/start.sh index 33c46ae..d5877a6 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -4,20 +4,41 @@ 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; + /var/www/html/ipconfig.php.example > /var/www/html/ipconfig.php + +else + + [ -n "$IP_URL" ] && sed -i 's/IP_URL=/IP_URL=${IP_URL}/' /var/www/html/ipconfig.php + [ -n "$ENABLE_DEBUG" ] && sed -i 's/ENABLE_DEBUG=/ENABLE_DEBUG=${ENABLE_DEBUG}/' /var/www/html/ipconfig.php + [ -n "$DISABLE_SETUP" ] && sed -i 's/DISABLE_SETUP=/DISABLE_SETUP=${DISABLE_SETUP}/' /var/www/html/ipconfig.php + [ -n "$REMOVE_INDEXPHP" ] && sed -i 's/REMOVE_INDEXPHP=/REMOVE_INDEXPHP=${REMOVE_INDEXPHP}/' /var/www/html/ipconfig.php + + [ -n "$DB_HOSTNAME" ] && sed -i 's/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/' /var/www/html/ipconfig.php + [ -n "$DB_USERNAME" ] && sed -i 's/DB_USERNAME=/DB_USERNAME=${DB_USERNAME}/' /var/www/html/ipconfig.php + [ -n "$DB_PASSWORD" ] && sed -i 's/DB_PASSWORD=/DB_PASSWORD=${DB_PASSWORD}/' /var/www/html/ipconfig.php + [ -n "$DB_DATABASE" ] && sed -i 's/DB_DATABASE=/DB_DATABASE=${DB_DATABASE}/' /var/www/html/ipconfig.php + [ -n "$DB_PORT" ] && sed -i 's/DB_PORT=/DB_PORT=${DB_PORT}/' /var/www/html/ipconfig.php + + [ -n "$SESS_EXPIRATION" ] && sed -i 's/SESS_EXPIRATION=/SESS_EXPIRATION=${SESS_EXPIRATION}/' /var/www/html/ipconfig.php + [ -n "$SESS_MATCH_IP" ] && sed -i 's/SESS_MATCH_IP=/SESS_MATCH_IP=${SESS_MATCH_IP}/' /var/www/html/ipconfig.php + [ -n "$ENABLE_INVOICE_DELETION" ] && sed -i 's/ENABLE_INVOICE_DELETION=/ENABLE_INVOICE_DELETION=${ENABLE_INVOICE_DELETION}/' /var/www/html/ipconfig.php + [ -n "$DISABLE_READ_ONLY" ] && sed -i '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 's/ENCRYPTION_KEY=/ENCRYPTION_KEY=${ENCRYPTION_KEY}/' /var/www/html/ipconfig.php + [ -n "$ENCRYPTION_CIPHER" ] && sed -i 's/ENCRYPTION_CIPHER=/ENCRYPTION_CIPHER=${ENCRYPTION_CIPHER}/' /var/www/html/ipconfig.php + sed -i 's/SETUP_COMPLETED=/SETUP_COMPLETED=${SETUP_COMPLETED}/' /var/www/html/ipconfig.php + fi 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 From 2cf46b560e2bdd12ebb2906388dc55e8acddcd1a Mon Sep 17 00:00:00 2001 From: Matthew Horwood Date: Wed, 24 Jan 2024 21:36:17 +0000 Subject: [PATCH 5/5] bug: fix setup config bug: fix cerds --- README.md | 4 ++-- docker-compose.yml | 5 +++-- setup/start.sh | 54 ++++++++++++++++++++++------------------------ 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 71139a9..25e7667 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ 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 collect the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER` and +The below commands will display the `ENCRYPTION_KEY` & `ENCRYPTION_CIPHER` ``` ID=$(docker ps | grep 'mhzawadi/invoiceplane' | awk '{print $1}'); @@ -84,7 +84,7 @@ 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 should have some like the below +the `environment` section of your `docker-compose.yml` should have some like the below ``` - TZ=utc diff --git a/docker-compose.yml b/docker-compose.yml index 0752c90..6f6a4a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,10 +31,11 @@ services: 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 d5877a6..109b06c 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -5,34 +5,32 @@ 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 - - /var/www/html/ipconfig.php.example > /var/www/html/ipconfig.php - -else - - [ -n "$IP_URL" ] && sed -i 's/IP_URL=/IP_URL=${IP_URL}/' /var/www/html/ipconfig.php - [ -n "$ENABLE_DEBUG" ] && sed -i 's/ENABLE_DEBUG=/ENABLE_DEBUG=${ENABLE_DEBUG}/' /var/www/html/ipconfig.php - [ -n "$DISABLE_SETUP" ] && sed -i 's/DISABLE_SETUP=/DISABLE_SETUP=${DISABLE_SETUP}/' /var/www/html/ipconfig.php - [ -n "$REMOVE_INDEXPHP" ] && sed -i 's/REMOVE_INDEXPHP=/REMOVE_INDEXPHP=${REMOVE_INDEXPHP}/' /var/www/html/ipconfig.php - - [ -n "$DB_HOSTNAME" ] && sed -i 's/DB_HOSTNAME=/DB_HOSTNAME=${MYSQL_HOST}/' /var/www/html/ipconfig.php - [ -n "$DB_USERNAME" ] && sed -i 's/DB_USERNAME=/DB_USERNAME=${DB_USERNAME}/' /var/www/html/ipconfig.php - [ -n "$DB_PASSWORD" ] && sed -i 's/DB_PASSWORD=/DB_PASSWORD=${DB_PASSWORD}/' /var/www/html/ipconfig.php - [ -n "$DB_DATABASE" ] && sed -i 's/DB_DATABASE=/DB_DATABASE=${DB_DATABASE}/' /var/www/html/ipconfig.php - [ -n "$DB_PORT" ] && sed -i 's/DB_PORT=/DB_PORT=${DB_PORT}/' /var/www/html/ipconfig.php - - [ -n "$SESS_EXPIRATION" ] && sed -i 's/SESS_EXPIRATION=/SESS_EXPIRATION=${SESS_EXPIRATION}/' /var/www/html/ipconfig.php - [ -n "$SESS_MATCH_IP" ] && sed -i 's/SESS_MATCH_IP=/SESS_MATCH_IP=${SESS_MATCH_IP}/' /var/www/html/ipconfig.php - [ -n "$ENABLE_INVOICE_DELETION" ] && sed -i 's/ENABLE_INVOICE_DELETION=/ENABLE_INVOICE_DELETION=${ENABLE_INVOICE_DELETION}/' /var/www/html/ipconfig.php - [ -n "$DISABLE_READ_ONLY" ] && sed -i '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 's/ENCRYPTION_KEY=/ENCRYPTION_KEY=${ENCRYPTION_KEY}/' /var/www/html/ipconfig.php - [ -n "$ENCRYPTION_CIPHER" ] && sed -i 's/ENCRYPTION_CIPHER=/ENCRYPTION_CIPHER=${ENCRYPTION_CIPHER}/' /var/www/html/ipconfig.php - sed -i 's/SETUP_COMPLETED=/SETUP_COMPLETED=${SETUP_COMPLETED}/' /var/www/html/ipconfig.php - fi +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;