Compare commits

...

4 Commits

Author SHA1 Message Date
Thibaut De Muynck
62b1d8cb94 Added MariaDB to Docker compose for ARM64 (#315)
* Added option to use MariaDB instead of MySQL

* Moved MYSQL environment variables to env file
2021-04-06 09:29:04 +08:00
Ween Jiann
4cd773700e Update .gitignore 2021-04-05 17:31:27 +08:00
Ween Jiann
9f6e086633 Added Redis to Chart (#312)
* Added redis to chart

* Add snappdf config

* Updated configmap

* Updated appVersion
2021-03-29 22:20:33 +08:00
Ween Jiann
8df49feaf8 Update README.md 2021-03-29 00:54:57 +08:00
13 changed files with 307 additions and 50 deletions

5
.gitignore vendored
View File

@@ -8,4 +8,7 @@ ehthumbs.db
Thumbs.db
# Helm
charts/**/charts/
charts/**/charts/
# Compose filesystem
/docker

View File

@@ -2,7 +2,7 @@
[![Docker image, latest](https://img.shields.io/docker/image-size/invoiceninja/invoiceninja/latest?label=latest)](https://hub.docker.com/r/invoiceninja/invoiceninja)
[![Docker image, alpine](https://img.shields.io/docker/image-size/invoiceninja/invoiceninja/alpine?label=alpine)](https://hub.docker.com/r/invoiceninja/invoiceninja)
# Docker for [Invoice Ninja](https://www.invoiceninja.com/)
# Docker for [Invoice Ninja](https://www.invoiceninja.com/)
:crown: **Features**
@@ -13,18 +13,18 @@
## You want some Kubernetes + Helm with that?
[Helm Chat](https://github.com/Saddamus/invoiceninja-helm) by @Saddamus
[Kubernetes](https://github.com/invoiceninja/dockerfiles/issues/94) by @spacepluk
[Kubernetes](https://github.com/invoiceninja/dockerfiles/issues/94) by @spacepluk
## Quickstart V5 Launch
The dockerfile has been revamped to make is easier to get started, by default the base image selected in 5 which will pull in the latest v5 stable image.
The dockerfile has been revamped to make it easier to get started, by default the base image selected is 5 which will pull in the latest v5 stable image.
```bash
git clone https://github.com/invoiceninja/dockerfiles.git
cd dockerfiles
```
Instead of defining our environment variables inside our docker-compose.yml file we now define this in the ```env``` file, open this file up and insert your APP_URL and your APP_KEY
Instead of defining our environment variables inside our docker-compose.yml file we now define this in the `env` file, open this file up and insert your `APP_URL` and your `APP_KEY`
```
APP_URL=http://in.localhost:8003/
@@ -39,32 +39,23 @@ DB_DATABASE1=ninja
PHANTOMJS_PDF_GENERATION=false
```
The ```APP_KEY``` can be generated by running
The `APP_KEY` can be generated by running
```
```bash
docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
```
Copy the entire string and insert in the env file at ```APP_KEY=base64....```
Copy the entire string and insert in the env file at `APP_KEY=base64....`
To ensure folder permissions are correct when the container comes up for the first time it is important that you set the correct folder permissions on the ```docker``` folder.
To ensure folder permissions are correct when the container comes up for the first time it is important that you set the correct folder permissions on the `docker` folder.
From the terminal run
```sudo chown -R 1500:1500 docker/app```
## Updating the image when using `docker-compose`
As `docker-compose` does not support any form of version control, this git provide updates to `docker-compose.yml` directly.
To upgrade to a newer release image, please make sure to update the `docker-compose.yml` first by running
```bash
git pull
chmod 755 docker/app/public
sudo chown -R 1500:1500 docker/app
```
You may need to manually merge any changes that cannot be merged automatically by git.
### Note for people running the container locally on their PC ###
If you are running the container locally, then the container will need to resolve the host, to support this you will want to insert your LAN IP address and the host name in the hosts file located in ```config/hosts```
@@ -74,7 +65,7 @@ For example, lets say your APP_URL is ```http://in5.test:8000``` and your LAN IP
```192.168.0.124 in5.test```
**Please note that PDF generation using local host your domain name MUST end in .test for your PDFs to generate correctly, this is a DNS resolver issue with chromium.
**Please note that for PDF generation using local host, your domain name MUST end in .test for your PDFs to generate correctly, this is a DNS resolver issue with chromium.
All that is left to do now is bring up the container
@@ -84,6 +75,22 @@ All that is left to do now is bring up the container
**Note: When performing the setup, the Database host is ```db```
### Running on ARM64 (Raspberry Pi 4)
When deploying on an ARM64 system, you need to comment out the `image: mysql:5` line and uncomment `image: mariadb:10.4` in the `docker-compose.yml` file.
## Updating the Image when using `docker-compose`
As `docker-compose` does not support any form of version control, this git provide updates to `docker-compose.yml` directly.
To upgrade to a newer release image, please make sure to update the `docker-compose.yml` first by running
```bash
git pull
```
You may need to manually merge any changes that cannot be merged automatically by git.
## Support
If you discover a bug, please create and issue, if you query is general in nature please visit us on our [Forum ](https://forum.invoiceninja.com/)

View File

@@ -1,12 +1,15 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 1.4.1
version: 1.4.2
- name: nginx
repository: https://charts.bitnami.com/bitnami
version: 8.8.0
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 9.3.5
digest: sha256:d809702ee601a8a0019defb9ee3fc5a5b5332968e1038cca8b44d5332b14a275
generated: "2021-03-23T00:33:02.690189+08:00"
version: 9.3.6
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 12.9.0
digest: sha256:008659600506cbc8dd5c9b8e96ce81430e4d8582368646469aa17a37441f5bbc
generated: "2021-03-29T18:41:17.978475+08:00"

View File

@@ -13,11 +13,11 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 5.1.30
appVersion: 5.1.32
keywords:
- invoiceninja
home: https://github.com/lwj5/invoiceninja-chart
@@ -37,6 +37,10 @@ dependencies:
name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 9.3.x
- condition: redis.enabled
name: redis
repository: https://charts.bitnami.com/bitnami
version: 12.9.x
maintainers:
- email: lwj5@hotmail.com
name: lwj5

View File

@@ -78,6 +78,12 @@ The following table shows the configuration options for the Invoiceninja helm ch
| `serviceAccountName` | Name of a service account for the Invoiceninja pods | `default` |
| `debug` | Turn on debug mode on Invoiceninja | `false` |
| `appKey` | Laravel Application Key | _random 32 character alphanumeric string_ |
| `logChannel` | Name of log channel to use | `nil` |
| `broadcastDriver` | Name of broadcast driver to use | `nil` |
| `cacheDriver` | Name of cache driver to use | `nil` |
| `sessionDriver` | Name of session driver to use | `nil` |
| `queueConnection` | Name of queue connection to use | `nil` |
| `snappdf` | Use snappdf instead of Phantom JS PDF generation | `true` |
| `extraEnvVars` | Extra environment variables to be set on Invoiceninja container | `{}` |
| `extraEnvVarsCM` | Name of existing ConfigMap containing extra env vars | `nil` |
| `extraEnvVarsSecret` | Name of existing Secret containing extra env vars | `nil` |
@@ -150,15 +156,36 @@ The following table shows the configuration options for the Invoiceninja helm ch
| `persistence.storage.size` | PVC Storage Request | `5Gi` |
| `persistence.storage.dataSource` | PVC data source | `{}` |
### Redis parameters
| Parameter | Description | Default |
| --------------------------------- | -------------------------------------------- | ------- |
| `redis.enabled` | If external redis is used, set it to `false` | `true` |
| `redis.password` | Redis password | `nil` |
| `redis.usePassword` | Use redis password | `false` |
| `externalRedis.host` | Host of the external redis | `nil` |
| `externalRedis.port` | Port of the external redis | `6379` |
| `externalRedis.password` | Password for the external redis | `nil` |
| `externalRedis.databases.default` | Database to use by default | `0` |
| `externalRedis.databases.cache` | Database to use by cache | `1` |
> See [Dependencies](#dependencies) for more.
### Database parameters
| Parameter | Description | Default |
| --------------------------- | ------------------------------------ | ----------------------------------------- |
| `mariadb.enabled` | Deploy MariaDB container(s) | `true` |
| `mariadb.auth.rootPassword` | Password for the MariaDB `root` user | _random 10 character alphanumeric string_ |
| `mariadb.auth.database` | Database name to create | `invoiceninja` |
| `mariadb.auth.username` | Database user to create | `invoiceninja` |
| `mariadb.auth.password` | Password for the database | _random 10 character alphanumeric string_ |
| Parameter | Description | Default |
| --------------------------------- | ------------------------------------------- | ----------------------------------------- |
| `mariadb.enabled` | Deploy MariaDB container(s) | `true` |
| `mariadb.auth.rootPassword` | Password for the MariaDB `root` user | _random 10 character alphanumeric string_ |
| `mariadb.auth.database` | Database name to create | `invoiceninja` |
| `mariadb.auth.username` | Database user to create | `invoiceninja` |
| `mariadb.auth.password` | Password for the database | _random 10 character alphanumeric string_ |
| `externalDatabase.host` | Host of the external database | `nil` |
| `externalDatabase.user` | Existing username in the external db | `invoiceninja` |
| `externalDatabase.password` | Password for the above username | `nil` |
| `externalDatabase.database` | Name of the existing database | `invoiceninja` |
| `externalDatabase.port` | Database port number | `3306` |
| `externalDatabase.existingSecret` | Name of the database existing Secret Object | `nil` |
> See [Dependencies](#dependencies) for more.

View File

@@ -28,6 +28,15 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name "nginx" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "invoiceninja.redis.fullname" -}}
{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
@@ -125,3 +134,58 @@ Return the MariaDB Secret Name
{{- printf "%s" (include "invoiceninja.mariadb.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the Redis Hostname
*/}}
{{- define "invoiceninja.redisHost" -}}
{{- if .Values.redis.enabled }}
{{- printf "%s-%s" (include "invoiceninja.redis.fullname" .) "master" | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s" .Values.externalRedis.host -}}
{{- end -}}
{{- end -}}
{{/*
Return the Redis Port
*/}}
{{- define "invoiceninja.redisPort" -}}
{{- if .Values.redis.enabled }}
{{- printf "6379" -}}
{{- else -}}
{{- printf "%d" (.Values.externalRedis.port | int ) -}}
{{- end -}}
{{- end -}}
{{/*
Return the Redis Database
*/}}
{{- define "invoiceninja.redisDatabase" -}}
{{- if .Values.redis.enabled }}
{{- printf "0" -}}
{{- else -}}
{{- printf "%s" .Values.externalRedis.databases.default -}}
{{- end -}}
{{- end -}}
{{/*
Return the Redis Database
*/}}
{{- define "invoiceninja.redisCacheDatabase" -}}
{{- if .Values.redis.enabled }}
{{- printf "1" -}}
{{- else -}}
{{- printf "%s" .Values.externalRedis.databases.cache -}}
{{- end -}}
{{- end -}}
{{/*
Return the Redis Secret Name
*/}}
{{- define "invoiceninja.redisSecretName" -}}
{{- if .Values.externalRedis.existingSecret -}}
{{- printf "%s" .Values.externalRedis.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "invoiceninja.redis.fullname" .) -}}
{{- end -}}
{{- end -}}

View File

@@ -12,10 +12,41 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- if .Values.nginx.ingress.enabled }}
APP_URL: "http://{{ .Values.nginx.ingress.hostname }}/"
{{- else }}
APP_URL: "http://{{ include "common.names.fullname" . }}/"
{{- end }}
APP_DEBUG: {{ .Values.debug | quote }}
MULTI_DB_ENABLED: "false"
DB_HOST1: {{ include "invoiceninja.databaseHost" . | quote }}
DB_PORT1: {{ include "invoiceninja.databasePort" . | quote }}
DB_USERNAME1: {{ include "invoiceninja.databaseUser" . | quote }}
DB_DATABASE1: {{ include "invoiceninja.databaseName" . | quote }}
{{- if not (empty .Values.logChannel) }}
LOG_CHANNEL: {{ .Values.logChannel | quote }}
{{- end }}
{{- if not (empty .Values.broadcastDriver) }}
BROADCAST_DRIVER: {{ .Values.broadcastDriver | quote }}
{{- else if or .Values.redis.enabled (not (empty .Values.externalRedis.host)) }}
BROADCAST_DRIVER: redis
{{- end }}
{{- if not (empty .Values.cacheDriver) }}
CACHE_DRIVER: {{ .Values.cacheDriver | quote }}
{{- else if or .Values.redis.enabled (not (empty .Values.externalRedis.host)) }}
CACHE_DRIVER: redis
{{- end }}
{{- if not (empty .Values.sessionDriver) }}
SESSION_DRIVER: {{ .Values.sessionDriver | quote }}
{{- else if or .Values.redis.enabled (not (empty .Values.externalRedis.host)) }}
SESSION_DRIVER: redis
{{- end }}
{{- if not (empty .Values.queueConnection) }}
QUEUE_CONNECTION: {{ .Values.queueConnection | quote }}
{{- else if or .Values.redis.enabled (not (empty .Values.externalRedis.host)) }}
QUEUE_CONNECTION: redis
{{- end }}
PHANTOMJS_PDF_GENERATION: {{ not .Values.snappdf | quote}}
REDIS_HOST: {{ include "invoiceninja.redisHost" . | quote }}
REDIS_PORT: {{ include "invoiceninja.redisPort" . | quote }}
REDIS_DB: {{ include "invoiceninja.redisDatabase" . | quote }}
REDIS_CACHE_DB: {{ include "invoiceninja.redisCacheDatabase" . | quote }}

View File

@@ -54,6 +54,36 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: wait-db
image: {{ include "invoiceninja.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/sh
- -cx
- |
COUNTER=0;
while [ $COUNTER -lt 120 ]; do
if mysqladmin ping -h "$DB_HOST1" -P $DB_PORT1 --silent; then
exit 0;
fi;
let COUNTER=COUNTER+1;
echo "Waiting for DB ($DB_HOST1:$DB_PORT1)"
sleep 2;
done;
echo "Did NOT see a database after 240 secs!";
exit 1;
securityContext:
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "common.names.fullname" . }}
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
@@ -98,13 +128,18 @@ spec:
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
{{- end }}
env:
- name: IS_DOCKER
value: "true"
- name: DB_PASSWORD1
valueFrom:
secretKeyRef:
name: {{ include "invoiceninja.databaseSecretName" . }}
key: mariadb-password
{{- if not (and .Values.redis.enabled (not .Values.redis.usePassword)) }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "invoiceninja.redisSecretName" . }}
key: redis-password
{{- end }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}

View File

@@ -16,6 +16,27 @@ type: Opaque
data:
mariadb-password: {{ .Values.externalDatabase.password | b64enc | quote }}
{{- end }}
---
{{- if not (or .Values.redis.enabled .Values.externalDatabase.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "invoiceninja.redis.fullname" . }}
labels:
{{- include "common.labels.standard" $ | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
redis-password: {{ .Values.externalRedis.password | b64enc | quote }}
{{- end }}
---
apiVersion: v1
kind: Secret

View File

@@ -18,7 +18,7 @@
image:
registry: docker.io
repository: invoiceninja/invoiceninja
tag: 5.1.31
tag: 5.1.32
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
@@ -38,6 +38,30 @@ debug: false
##
appKey: ""
## Name of log channel to use
##
logChannel: ""
## Name of broadcast driver to use
##
broadcastDriver: ""
## Name of cache driver to use
##
cacheDriver: ""
## Name of session driver to use
##
sessionDriver: ""
## Name of queue connection to use
##
queueConnection: ""
## Use local or Phantom JS PDF generation
##
snappdf: true
## String to partially override fullname template (will maintain the release name)
##
# nameOverride:
@@ -306,6 +330,40 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
## Redis chart configuration
## ref: https://github.com/bitnami/charts/blob/master/bitnami/redis/values.yaml
##
redis:
enabled: true
usePassword: false
cluster:
enabled: false
## External Redis Configuration
##
## All of these values are only used when redis.enabled is set to false
##
externalRedis:
## Redis host
##
host: ""
## Redis port number
##
port: 6379
## Redis password
##
password: ""
## Use existing secret (ignores previous password)
## must contain key `redis-password`
## NOTE: When it's set, the `externalRedis.password` parameter is ignored
##
# existingSecret:
## Redis databases
##
databases:
default: "0"
cache: "1"
## MariaDB chart configuration
## ref: https://github.com/bitnami/charts/blob/master/bitnami/mariadb/values.yaml
##
@@ -333,7 +391,7 @@ mariadb:
externalDatabase:
## Database host
##
host: localhost
host: ""
## non-root Username for Invoiceninja Database
##
user: invoiceninja

View File

@@ -1,4 +1,6 @@
FROM mysql:5
# When running on ARM64 use MariaDB instead of MySQL
#FROM mariadb:10.4
ENV force_color_prompt yes
RUN apt-get update;
@@ -7,4 +9,4 @@ RUN apt-get install -y cron;
ENTRYPOINT \
service cron start; \
printenv | grep -v "no_proxy" >> /etc/environment; \
docker-entrypoint.sh mysqld
docker-entrypoint.sh mysqld

View File

@@ -14,7 +14,7 @@ services:
- app
# Run webserver nginx on port 80
# Feel free to modify depending what port is already occupied
ports:
ports:
- "80:80"
#- "443:443"
networks:
@@ -32,24 +32,22 @@ services:
- ./docker/app/storage:/var/www/app/storage:rw,delegated
depends_on:
- db
networks:
- invoiceninja
networks:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
db:
image: mysql:5
# When running on ARM64 use MariaDB instead of MySQL
# image: mariadb:10.4
# For auto DB backups comment out image and use the build block below
# build:
# context: ./config/mysql
ports:
- "3305:3306"
restart: always
environment:
- MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
- MYSQL_USER=ninja
- MYSQL_PASSWORD=ninja
- MYSQL_DATABASE=ninja
env_file: env
volumes:
- ./docker/mysql/data:/var/lib/mysql:rw,delegated
@@ -82,7 +80,7 @@ services:
# EOF'
# networks:
# - invoiceninja
#
#
networks:
invoiceninja:
invoiceninja:

4
env
View File

@@ -7,6 +7,10 @@ DB_PORT1=3306
DB_USERNAME1=ninja
DB_PASSWORD1=ninja
DB_DATABASE1=ninja
MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
MYSQL_USER=ninja
MYSQL_PASSWORD=ninja
MYSQL_DATABASE=ninja
#this is a system variable please do not remove
IS_DOCKER=true