Compare commits

...

5 Commits

Author SHA1 Message Date
=
10aaf3fb6e Set auto DB backups to optin by default 2021-03-03 16:48:54 +11:00
David Bomba
8117d0c5bd Merge pull request #291 from danielgroen/master
auto db backup script
2021-03-03 16:46:13 +11:00
danielgroen
fef92891cb auto db backup script 2021-03-02 13:05:12 +01:00
David Bomba
7f415803fb Merge pull request #286 from invoiceninja/revert-284-dotenv_improvements
Revert "got all the vars onto the dotenv file"
2021-02-11 16:04:19 +11:00
David Bomba
1caa8c7e70 Revert "got all the vars onto the dotenv file" 2021-02-11 16:04:11 +11:00
5 changed files with 70 additions and 36 deletions

5
.gitignore vendored
View File

@@ -1,5 +0,0 @@
*.sql
# docker/*
.env
!.env.example

10
config/mysql/Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM mysql:5
ENV force_color_prompt yes
RUN apt-get update;
RUN apt-get install -y cron;
ENTRYPOINT \
service cron start; \
printenv | grep -v "no_proxy" >> /etc/environment; \
docker-entrypoint.sh mysqld

View File

@@ -0,0 +1,28 @@
#!/bin/sh
FREQUENTY=`basename "$0"`
TIMESTAMP=$(date +"%Y-%m-%d")
case $FREQUENTY in
daily)
DAYS=6
;;
weekly)
DAYS=30
find /backups -type f -name $TIMESTAMP-daily.sql.gz -delete
;;
monthly)
DAYS=122
find /backups -type f -name $TIMESTAMP-weekly.sql.gz -delete
;;
esac
mysqldump -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} | gzip > /backups/$TIMESTAMP-$FREQUENTY.sql.gz
# Remove old backups
find /backups -mtime +${DAYS} -type f -name *-$FREQUENTY.sql.gz -delete
exit 0;

View File

@@ -1,10 +1,10 @@
version: "3.7" version: '3.7'
services: services:
server: server:
image: nginx image: nginx
restart: always restart: always
env_file: .env env_file: env
volumes: volumes:
# Vhost configuration # Vhost configuration
#- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
@@ -15,17 +15,17 @@ services:
- app - app
# Run webserver nginx on port 80 # Run webserver nginx on port 80
# Feel free to modify depending what port is already occupied # Feel free to modify depending what port is already occupied
ports: ports:
- ${PORT}:80 - "80:80"
#- "443:443" #- "443:443"
networks: networks:
- invoiceninja - invoiceninja
extra_hosts: extra_hosts:
- "${CNAME}:192.168.0.124 " #host and ip - "in5.localhost:192.168.0.124 " #host and ip
app: app:
image: invoiceninja/invoiceninja:5 image: invoiceninja/invoiceninja:5
env_file: .env env_file: env
restart: always restart: always
volumes: volumes:
- ./config/hosts:/etc/hosts:ro - ./config/hosts:/etc/hosts:ro
@@ -34,40 +34,44 @@ services:
- ./docker/app/storage:/var/www/app/storage:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated
depends_on: depends_on:
- db - db
networks: networks:
- invoiceninja - invoiceninja
extra_hosts: extra_hosts:
- "${CNAME}:192.168.0.124 " #host and ip - "in5.localhost:192.168.0.124 " #host and ip
db: db:
image: mysql:5 image: mysql:5
env_file: .env # For auto DB backups comment out image and use the build block below
# build:
# context: ./config/mysql
ports: ports:
- "3305:3306" - "3305:3306"
restart: always restart: always
environment: environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD1} # config for 5 - MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
- MYSQL_USER=${DB_USERNAME1} - MYSQL_USER=ninja
- MYSQL_PASSWORD=${DB_PASSWORD1} - MYSQL_PASSWORD=ninja
- MYSQL_DATABASE=${DB_DATABASE1} - MYSQL_DATABASE=ninja
# - MYSQL_ROOT_PASSWORD=${DB_PASSWORD} # config for 4
# - MYSQL_USER=${DB_USERNAME}
# - MYSQL_PASSWORD=${DB_PASSWORD}
# - MYSQL_DATABASE=${DB_DATABASE}
volumes: volumes:
- ./docker/mysql/data:/var/lib/mysql:rw,delegated - ./docker/mysql/data:/var/lib/mysql:rw,delegated
# remove comments for next 4 lines if you want auto sql backups
#- ./docker/mysql/bak:/backups:rw
#- ./config/mysql/backup-script:/etc/cron.daily/daily:ro
#- ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro
#- ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro
networks: networks:
- invoiceninja - invoiceninja
extra_hosts: extra_hosts:
- "${CNAME}:192.168.0.124 " #host and ip - "in5.localhost:192.168.0.124 " #host and ip
# THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5. # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
# cron: # cron:
# image: invoiceninja/invoiceninja:alpine-4 # image: invoiceninja/invoiceninja:alpine-4
# volumes: # volumes:
# - ./docker/app/public:/var/www/app/public:rw,delegated # - ./docker/app/public:/var/www/app/public:rw,delegated
# - ./docker/app/storage:/var/www/app/storage:rw,delegated # - ./docker/app/storage:/var/www/app/storage:rw,delegated
# - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated # - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated
# entrypoint: | # entrypoint: |
# /bin/sh -c 'sh -s <<EOF # /bin/sh -c 'sh -s <<EOF
# trap "break;exit" SIGHUP SIGINT SIGTERM # trap "break;exit" SIGHUP SIGINT SIGTERM
@@ -80,7 +84,7 @@ services:
# EOF' # EOF'
# networks: # networks:
# - invoiceninja # - invoiceninja
# #
networks: networks:
invoiceninja: invoiceninja:

View File

@@ -1,7 +1,4 @@
APP_URL=http://${CNAME}:${port} APP_URL=http://in.localhost:8003/
PORT=8003
CNAME=in.localhost
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 MULTI_DB_ENABLED=false
@@ -19,4 +16,4 @@ DB_HOST=db
DB_DATABASE=ninja DB_DATABASE=ninja
DB_USERNAME=ninja DB_USERNAME=ninja
DB_PASSWORD=ninja DB_PASSWORD=ninja
APP_CIPHER=AES-256-CBC APP_CIPHER=AES-256-CBC