mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2026-01-22 14:24:05 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2aabd14ac | ||
|
|
07f1e601ab | ||
|
|
13423d38c0 | ||
|
|
e34ac95617 | ||
|
|
6c68882449 |
14
Makefile
14
Makefile
@@ -17,15 +17,15 @@ VERSION=$(shell echo ${TAG} | sed "s/-.*//")
|
|||||||
|
|
||||||
# Building docker images based on alpine.
|
# Building docker images based on alpine.
|
||||||
# Assigned tags:
|
# Assigned tags:
|
||||||
# - :alpine
|
# - :4
|
||||||
# - :alpine-<RELEASE VERSION>
|
# - :<RELEASE VERSION>
|
||||||
.PHONY: build-alpine
|
.PHONY: build-alpine
|
||||||
build-alpine:
|
build-alpine:
|
||||||
ifeq ($(IS_V5),)
|
ifeq ($(IS_V5),)
|
||||||
$(info Make: Building "$(VERSION)" tagged images from alpine.)
|
$(info Make: Building "$(VERSION)" tagged images from alpine.)
|
||||||
@docker build -t ${HUB_NAMESPACE}/${IMAGE}:alpine-${VERSION} --build-arg INVOICENINJA_VERSION=${VERSION} ./alpine/4/
|
@docker build -t ${HUB_NAMESPACE}/${IMAGE}:${VERSION} --build-arg INVOICENINJA_VERSION=${VERSION} ./alpine/4/
|
||||||
# Tag as alpine-4
|
# Tag as 4
|
||||||
@docker tag ${HUB_NAMESPACE}/${IMAGE}:alpine-${VERSION} ${HUB_NAMESPACE}/${IMAGE}:alpine-4
|
@docker tag ${HUB_NAMESPACE}/${IMAGE}:alpine-${VERSION} ${HUB_NAMESPACE}/${IMAGE}:4
|
||||||
$(info Make: Done.)
|
$(info Make: Done.)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ endif
|
|||||||
push-alpine:
|
push-alpine:
|
||||||
ifeq ($(IS_V5),)
|
ifeq ($(IS_V5),)
|
||||||
$(info Make: Pushing tagged images from alpine.)
|
$(info Make: Pushing tagged images from alpine.)
|
||||||
@docker push ${HUB_NAMESPACE}/${IMAGE}:alpine-${VERSION}
|
@docker push ${HUB_NAMESPACE}/${IMAGE}:${VERSION}
|
||||||
@docker push ${HUB_NAMESPACE}/${IMAGE}:alpine-4
|
@docker push ${HUB_NAMESPACE}/${IMAGE}:4
|
||||||
$(info Make: Done.)
|
$(info Make: Done.)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -31,21 +31,19 @@ git clone https://github.com/invoiceninja/dockerfiles.git
|
|||||||
cd dockerfiles
|
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`, `APP_KEY` and update the rest of the variables as required.
|
||||||
|
|
||||||
```
|
```
|
||||||
APP_URL=http://in.localhost:8003/
|
APP_URL=http://in.localhost:8003/
|
||||||
APP_KEY=<insert your generated key in here>
|
APP_KEY=<insert your generated key in here>
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
MULTI_DB_ENABLED=false
|
REQUIRE_HTTPS=false
|
||||||
DB_HOST1=db
|
IN_USER_EMAIL=
|
||||||
DB_PORT1=3306
|
IN_PASSWORD=
|
||||||
DB_USERNAME1=ninja
|
|
||||||
DB_PASSWORD1=ninja
|
|
||||||
DB_DATABASE1=ninja
|
|
||||||
PHANTOMJS_PDF_GENERATION=false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If `IN_USER_EMAIL` and `IN_PASSWORD` is not set the default user email and password is "admin@example.com" and "changeme!" respectively. You will use this for the initial login, thereafter, you can delete this two environment variables.
|
||||||
|
|
||||||
The `APP_KEY` can be generated by running
|
The `APP_KEY` can be generated by running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ fi
|
|||||||
rm -rf "$BAK_PUBLIC_PATH"
|
rm -rf "$BAK_PUBLIC_PATH"
|
||||||
|
|
||||||
# Set permission for web server to create/update files (only <v4)
|
# Set permission for web server to create/update files (only <v4)
|
||||||
chown -R "$INVOICENINJA_USER":www-data /var/www/app/storage /var/www/app/public /var/www/app/bootstrap
|
chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app/storage /var/www/app/public /var/www/app/bootstrap
|
||||||
|
|
||||||
# Initialize values that might be stored in a file
|
# Initialize values that might be stored in a file
|
||||||
file_env 'APP_KEY'
|
file_env 'APP_KEY'
|
||||||
|
|||||||
14
alpine/5/rootfs/docker-entrypoint-init.d/10-init-in.sh
Executable file
14
alpine/5/rootfs/docker-entrypoint-init.d/10-init-in.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
php artisan db:seed --force
|
||||||
|
|
||||||
|
# Build up array of arguments...
|
||||||
|
if [[ ! -z "${IN_USER_EMAIL}" ]]; then
|
||||||
|
email="--email ${IN_USER_EMAIL}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z "${IN_PASSWORD}" ]]; then
|
||||||
|
password="--password ${IN_PASSWORD}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
php artisan ninja:create-account $email $password
|
||||||
@@ -46,43 +46,52 @@ file_env() {
|
|||||||
|
|
||||||
# first arg is `-f` or `--some-option`
|
# first arg is `-f` or `--some-option`
|
||||||
if [ "${1#-}" != "$1" ]; then
|
if [ "${1#-}" != "$1" ]; then
|
||||||
set -- php-fpm "$@"
|
set -- supervisord "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create storage volume
|
# create storage volume
|
||||||
if [ ! -d /var/www/app/storage ] && [ -d "$BAK_STORAGE_PATH" ]; then
|
if [ -d "$BAK_STORAGE_PATH" ]; then
|
||||||
mv "$BAK_STORAGE_PATH" /var/www/app/storage
|
if [ ! -d /var/www/app/storage ]; then
|
||||||
elif [ -d "$BAK_STORAGE_PATH" ]; then
|
mv "$BAK_STORAGE_PATH" /var/www/app/storage
|
||||||
# copy missing folders in storage
|
else
|
||||||
IN_STORAGE_BACKUP="$(ls "$BAK_STORAGE_PATH")"
|
# copy missing folders in storage
|
||||||
for path in $IN_STORAGE_BACKUP; do
|
IN_STORAGE_BACKUP="$(ls "$BAK_STORAGE_PATH")"
|
||||||
if [ ! -e "/var/www/app/storage/$path" ]; then
|
for path in $IN_STORAGE_BACKUP; do
|
||||||
cp -Rp "$BAK_STORAGE_PATH/$path" "/var/www/app/storage/"
|
if [ ! -e "/var/www/app/storage/$path" ]; then
|
||||||
fi
|
cp -Rp "$BAK_STORAGE_PATH/$path" "/var/www/app/storage/"
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
rm -rf "$BAK_STORAGE_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# prevent init scripts from running when upgrading from IN <= 5.1.62
|
||||||
|
if [ -f /var/www/app/public/version ] && [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then
|
||||||
|
touch /var/www/app/storage/.initialized
|
||||||
fi
|
fi
|
||||||
rm -rf "$BAK_STORAGE_PATH"
|
|
||||||
|
|
||||||
# create public volume
|
# create public volume
|
||||||
if [ ! -d /var/www/app/public ] && [ -d "$BAK_PUBLIC_PATH" ]; then
|
if [ -d "$BAK_PUBLIC_PATH" ]; then
|
||||||
mv "$BAK_PUBLIC_PATH" /var/www/app/public
|
if [ ! -d /var/www/app/public ]; then
|
||||||
elif [ ! -e /var/www/app/public/version ] || [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then
|
mv "$BAK_PUBLIC_PATH" /var/www/app/public
|
||||||
# version mismatch, update all
|
elif [ ! -f /var/www/app/public/version ] || [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then
|
||||||
cp -au "$BAK_PUBLIC_PATH/"* /var/www/app/public
|
# version mismatch, update all
|
||||||
echo "$INVOICENINJA_VERSION" >/var/www/app/public/version
|
cp -au "$BAK_PUBLIC_PATH/"* /var/www/app/public
|
||||||
elif [ ! -d /var/www/app/public/logo ] && [ -d "$BAK_PUBLIC_PATH/logo" ]; then
|
echo "$INVOICENINJA_VERSION" >/var/www/app/public/version
|
||||||
# missing logo folder only, copy folder
|
elif [ ! -d /var/www/app/public/logo ] && [ -d "$BAK_PUBLIC_PATH/logo" ]; then
|
||||||
cp -a "$BAK_PUBLIC_PATH/logo" /var/www/app/public/logo
|
# missing logo folder only, copy folder
|
||||||
elif [ -d "$BAK_PUBLIC_PATH/logo" ]; then
|
cp -a "$BAK_PUBLIC_PATH/logo" /var/www/app/public/logo
|
||||||
# copy missing folders in logo
|
elif [ -d "$BAK_PUBLIC_PATH/logo" ]; then
|
||||||
IN_LOGO_BACKUP="$(ls "$BAK_PUBLIC_PATH/logo")"
|
# copy missing folders in logo
|
||||||
for path in $IN_LOGO_BACKUP; do
|
IN_LOGO_BACKUP="$(ls "$BAK_PUBLIC_PATH/logo")"
|
||||||
if [ ! -e "/var/www/app/public/logo/$path" ]; then
|
for path in $IN_LOGO_BACKUP; do
|
||||||
cp -a "$BAK_PUBLIC_PATH/logo/$path" "/var/www/app/public/logo/"
|
if [ ! -e "/var/www/app/public/logo/$path" ]; then
|
||||||
fi
|
cp -a "$BAK_PUBLIC_PATH/logo/$path" "/var/www/app/public/logo/"
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
rm -rf "$BAK_PUBLIC_PATH"
|
||||||
fi
|
fi
|
||||||
rm -rf "$BAK_PUBLIC_PATH"
|
|
||||||
|
|
||||||
# Initialize values that might be stored in a file
|
# Initialize values that might be stored in a file
|
||||||
file_env 'APP_KEY'
|
file_env 'APP_KEY'
|
||||||
@@ -100,10 +109,10 @@ file_env 'MAILGUN_SECRET'
|
|||||||
file_env 'S3_KEY'
|
file_env 'S3_KEY'
|
||||||
file_env 'S3_SECRET'
|
file_env 'S3_SECRET'
|
||||||
|
|
||||||
# Run Laravel stuff
|
# Run IN/Laravel stuff
|
||||||
if [[ "$1" == "supervisord" ]] || [[ "$1" == "php-fpm" ]]; then
|
if [[ "$1" == "supervisord" ]] || [[ "$1" == "php-fpm" ]]; then
|
||||||
echo "Initialising Laravel..."
|
in_log INFO "Initialising Invoice Ninja..."
|
||||||
. laravel-init.sh
|
. invoiceninja-init.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec docker-php-entrypoint "$@"
|
exec docker-php-entrypoint "$@"
|
||||||
|
|||||||
44
alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh
Executable file
44
alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# usage: docker_process_init_files [file [file [...]]]
|
||||||
|
# ie: docker_process_init_files /always-initdb.d/*
|
||||||
|
# process initializer files, based on file extensions
|
||||||
|
docker_process_init_files() {
|
||||||
|
echo
|
||||||
|
local f
|
||||||
|
for f; do
|
||||||
|
case "$f" in
|
||||||
|
*.sh)
|
||||||
|
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
|
||||||
|
# https://github.com/docker-library/postgres/pull/452
|
||||||
|
if [ -x "$f" ]; then
|
||||||
|
in_log INFO "$0: running $f"
|
||||||
|
"$f"
|
||||||
|
else
|
||||||
|
in_log INFO "$0: sourcing $f"
|
||||||
|
. "$f"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) in_log INFO "$0: ignoring $f" ;;
|
||||||
|
esac
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
php artisan config:cache
|
||||||
|
php artisan optimize
|
||||||
|
|
||||||
|
# Check if DB works, if not crash the app.
|
||||||
|
DB_READY=$(php artisan tinker --execute='echo app()->call("App\Utils\SystemHealth@dbCheck")["success"];')
|
||||||
|
if [ "$DB_READY" != "1" ]; then
|
||||||
|
php artisan migrate:status # Print verbose error
|
||||||
|
in_error "Error connecting to DB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
php artisan migrate --force
|
||||||
|
|
||||||
|
# If first IN run, it needs to be initialized
|
||||||
|
if [ ! -f /var/www/app/storage/.initialized ]; then
|
||||||
|
docker_process_init_files /docker-entrypoint-init.d/*
|
||||||
|
touch /var/www/app/storage/.initialized
|
||||||
|
fi
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
php artisan config:cache
|
|
||||||
php artisan optimize
|
|
||||||
php artisan migrate --force
|
|
||||||
@@ -13,7 +13,7 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# 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.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.4.0
|
version: 0.4.2
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# 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
|
# 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.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
|||||||
@@ -236,10 +236,49 @@ The above command sets the number of replicas to 3 for a highly available (HA) s
|
|||||||
|
|
||||||
Alternatively, a YAML file that specifies the values for the parameters can be provided while [installing](https://helm.sh/docs/helm/helm_install/) the chart. For example,
|
Alternatively, a YAML file that specifies the values for the parameters can be provided while [installing](https://helm.sh/docs/helm/helm_install/) the chart. For example,
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# values.yaml
|
||||||
|
appKey: changeit
|
||||||
|
replicaCount: 3
|
||||||
|
nginx:
|
||||||
|
replicaCount: 3
|
||||||
|
redis:
|
||||||
|
cluster:
|
||||||
|
slaveCount: 3
|
||||||
|
password: changeit
|
||||||
|
mariadb:
|
||||||
|
auth:
|
||||||
|
rootPassword: changeit
|
||||||
|
password: changeit
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
helm install invoiceninja -f values.yaml invoiceninja/invoiceninja
|
helm install invoiceninja -f values.yaml invoiceninja/invoiceninja
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Setting Environment Variables
|
||||||
|
|
||||||
|
Should you need to inject any environment variables into the `invoiceninja` container, you can use the `extraEnvVars` option:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ... values.yaml file
|
||||||
|
# In this example, we are forcing REQUIRE_HTTPS to be false
|
||||||
|
extraEnvVars:
|
||||||
|
- name: REQUIRE_HTTPS
|
||||||
|
value: 'false' # all values must be strings, so other types must be surrounded in quotes
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively you can provide the name of an existing `configmap` or `secret` object:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create configmap examplemap --from-literal=REQUIRE_HTTPS='false'
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ... values.yaml file
|
||||||
|
extraEnvVarsCM: examplemap
|
||||||
|
```
|
||||||
|
|
||||||
## Upgrading
|
## Upgrading
|
||||||
|
|
||||||
Nothing yet.
|
Nothing yet.
|
||||||
|
|||||||
@@ -59,14 +59,14 @@ Create the name of the service account to use
|
|||||||
Return the proper Storage Class
|
Return the proper Storage Class
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "invoiceninja.public.storageClass" -}}
|
{{- define "invoiceninja.public.storageClass" -}}
|
||||||
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) -}}
|
{{- include "common.storage.class" (dict "persistence" .Values.persistence.public "global" .Values.global) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Return the proper Storage Class
|
Return the proper Storage Class
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "invoiceninja.storage.storageClass" -}}
|
{{- define "invoiceninja.storage.storageClass" -}}
|
||||||
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) -}}
|
{{- include "common.storage.class" (dict "persistence" .Values.persistence.storage "global" .Values.global) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
data:
|
data:
|
||||||
{{- if .Values.nginx.ingress.enabled }}
|
{{- if .Values.nginx.ingress.enabled }}
|
||||||
|
{{- if .Values.nginx.ingress.tls }}
|
||||||
|
APP_URL: "https://{{ .Values.nginx.ingress.hostname }}"
|
||||||
|
{{- else }}
|
||||||
APP_URL: "http://{{ .Values.nginx.ingress.hostname }}"
|
APP_URL: "http://{{ .Values.nginx.ingress.hostname }}"
|
||||||
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
APP_URL: "http://{{ include "common.names.fullname" . }}"
|
APP_URL: "http://{{ include "common.names.fullname" . }}"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
7
env
7
env
@@ -12,6 +12,13 @@ DB_DATABASE=ninja
|
|||||||
DB_USERNAME=ninja
|
DB_USERNAME=ninja
|
||||||
DB_PASSWORD=ninja
|
DB_PASSWORD=ninja
|
||||||
|
|
||||||
|
# Create initial user
|
||||||
|
# Default to these values if empty
|
||||||
|
# IN_USER_EMAIL=admin@example.com
|
||||||
|
# IN_PASSWORD=changeme!
|
||||||
|
IN_USER_EMAIL=
|
||||||
|
IN_PASSWORD=
|
||||||
|
|
||||||
# Mail options
|
# Mail options
|
||||||
MAIL_MAILER=log
|
MAIL_MAILER=log
|
||||||
MAIL_HOST=smtp.mailtrap.io
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
|
|||||||
Reference in New Issue
Block a user