Compare commits

...

92 Commits

Author SHA1 Message Date
David Bomba
0d93596cde Update README.md 2021-03-05 20:44:54 +11:00
=
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
David Bomba
e35653fe59 Merge pull request #284 from danielgroen/dotenv_improvements
got all the vars onto the dotenv file
2021-02-09 22:48:47 +11:00
danielgroen
4d7cc8e464 got all the vars onto the dotenv file 2021-02-09 11:35:45 +01:00
David Bomba
c6e122b81f Merge pull request #282 from turbo124/master
Remove redis queue worker from defaults
2021-02-03 09:32:29 +11:00
David Bomba
421a1f10e6 Remove redis queue worker from defaults 2021-02-03 09:31:14 +11:00
David Bomba
84db77cde8 Merge pull request #281 from turbo124/master
Improve supervisor configuration
2021-02-01 08:31:32 +11:00
David Bomba
e8706de11c Improve supervisor configuration 2021-02-01 08:30:50 +11:00
David Bomba
960a85d8a7 Merge pull request #278 from turbo124/master
fix for defaults of supervisor
2021-01-28 21:03:28 +11:00
David Bomba
6cd85f48cd fix for defaults of supervisor 2021-01-28 21:03:09 +11:00
David Bomba
eca3af3da5 Merge pull request #277 from turbo124/master
Adjustments for supervisor
2021-01-28 20:38:28 +11:00
David Bomba
b141cfe449 Adjustments for supervisor 2021-01-28 20:38:03 +11:00
David Bomba
3104ec0be9 Merge pull request #276 from turbo124/master
Adjustments for supervisor
2021-01-28 20:18:21 +11:00
David Bomba
acd778f815 Adjustments for supervisor 2021-01-28 20:18:03 +11:00
David Bomba
0641860c3f Merge pull request #275 from turbo124/master
Adjustments for supervisor
2021-01-28 20:09:27 +11:00
David Bomba
f6564ffb14 Adjustments for supervisor 2021-01-28 20:09:11 +11:00
David Bomba
d751217d9a Merge pull request #274 from turbo124/master
Adjustments for supervisor
2021-01-28 19:59:24 +11:00
David Bomba
9bd40b98df Adjustments for supervisor 2021-01-28 19:59:07 +11:00
David Bomba
54f789d5a1 Merge pull request #273 from turbo124/master
Add supervisor to DockerFile
2021-01-28 19:55:39 +11:00
David Bomba
a6644abaa2 Add supervisor to DockerFile 2021-01-28 19:55:20 +11:00
David Bomba
d42e333248 Merge pull request #272 from turbo124/master
Change from queue:listen to queue:work.
2021-01-28 19:36:01 +11:00
David Bomba
2e4ccb920b Adjustments for supervisor 2021-01-28 19:35:29 +11:00
David Bomba
ebe353ca52 Adjustments for supervisor 2021-01-28 19:34:48 +11:00
David Bomba
1af91f451d Merge pull request #271 from turbo124/master
Remove cron container
2021-01-28 19:31:52 +11:00
David Bomba
386f6ed8c1 Remove cron container 2021-01-28 19:31:20 +11:00
David Bomba
73e88f6042 Merge pull request #270 from tms0/supervisor_v5
Add example to run php-fpm, scheduler and queue worker in the same container with supervisor
2021-01-28 19:30:25 +11:00
Valentin Day
758709a796 Change supervisord logging options 2021-01-28 09:05:50 +01:00
Valentin Day
a67de32b6e Move supervisor example into an examples folder 2021-01-27 15:43:45 +01:00
Valentin Day
49d3e562de Add example to run php-fpm, scheduler and queue worker in the same container with supervisor 2021-01-27 15:30:14 +01:00
David Bomba
7d4afadbb5 Merge pull request #268 from turbo124/master
Add mysql-client back in
2021-01-26 17:13:07 +11:00
David Bomba
3709355309 Add mysql-client back in 2021-01-26 17:12:52 +11:00
David Bomba
4b63e1f76d Merge pull request #265 from lwj5/php
Added install-php-extensions
2021-01-21 13:55:48 +11:00
Lee Ween Jiann
5118eac0ea Added install-php-extensions 2021-01-20 22:56:32 +08:00
David Bomba
486d38d6e1 Merge pull request #263 from turbo124/master
Remove sys_admin, add application variable
2021-01-19 07:39:15 +11:00
David Bomba
89ae36315d Remove sys_admin, add application variable 2021-01-19 07:38:54 +11:00
David Bomba
0c3237d3b9 Merge pull request #258 from lwj5/dockerfile
Enhancement and Fixes for Dockerfile
2021-01-11 16:11:52 +11:00
Lee Ween Jiann
e29f786b34 Revert 'git' dependency comment 2021-01-11 11:01:52 +08:00
Lee Ween Jiann
bfc5625687 Update entrypoint.sh to use ENV username 2021-01-10 22:34:49 +08:00
Lee Ween Jiann
4b5abbbd5e Add public missing folder condition for quick move 2021-01-10 22:16:34 +08:00
Lee Ween Jiann
a12f18836a Use uid to allow running in k8s with non-root PSP 2021-01-10 21:34:53 +08:00
Lee Ween Jiann
d59d534ac5 Update entrypoint.sh to use ENV paths + cleanup 2021-01-10 21:32:59 +08:00
Lee Ween Jiann
35d9ee80b7 Update Dockerfiles to use ENV for BAK paths 2021-01-10 21:31:05 +08:00
Lee Ween Jiann
115b997cab Move BAK to after npm run prod 2021-01-10 21:29:56 +08:00
Lee Ween Jiann
8ca8e459be Update cron to depend on app
- prevents race to copy files
2021-01-10 21:18:30 +08:00
David Bomba
15625f41f9 Merge pull request #257 from lwj5/patch-2
Remove node_modules and clean up
2021-01-10 09:17:18 +11:00
Ween Jiann
9dc1fec1fb Reinsert fonts 2021-01-08 22:13:06 +08:00
Ween Jiann
2342fd8cbb Remove node_modules and clean up 2021-01-08 21:28:43 +08:00
David Bomba
ae1f8fcecb Merge pull request #251 from turbo124/master
fixes for cron
2021-01-05 22:48:50 +11:00
David Bomba
6528ef7162 fixes for cron 2021-01-05 22:48:27 +11:00
David Bomba
2f6b5ea55e Minor fix 2021-01-05 22:45:29 +11:00
David Bomba
7c1ef82a09 Merge pull request #250 from turbo124/master
Update V4 container
2021-01-05 17:15:55 +11:00
David Bomba
98846729e6 update maintainer 2021-01-05 17:15:33 +11:00
David Bomba
f03860d8ea Fixes for V4 container 2021-01-05 17:14:49 +11:00
David Bomba
c624f6ed40 Fixes for V4 2021-01-05 16:20:27 +11:00
David Bomba
c94145edca Merge pull request #249 from turbo124/master
Fixes for Readme.
2021-01-05 12:09:01 +11:00
David Bomba
ff2c813355 Fixes for readme 2021-01-05 12:08:07 +11:00
David Bomba
e0cf941736 Typo 2021-01-05 11:56:49 +11:00
David Bomba
b1d65a8ac9 Typo 2021-01-05 11:56:21 +11:00
David Bomba
e6ad0c58ee Typo 2021-01-05 11:55:00 +11:00
David Bomba
11b99e7970 Typo 2021-01-05 11:54:19 +11:00
David Bomba
5fa605cba4 Typo 2021-01-05 11:53:36 +11:00
David Bomba
388f1a75b9 Merge pull request #248 from turbo124/master
Refactor DockerFiles
2021-01-05 11:52:28 +11:00
David Bomba
253c3339cf Fixes for ReadMe 2021-01-05 11:51:50 +11:00
David Bomba
d67fa3059a fixes for entrypoint 2021-01-05 11:09:56 +11:00
David Bomba
98e41ad73b Rework crons 2021-01-05 11:02:57 +11:00
David Bomba
14c597312e Fixes for formatting 2021-01-05 10:47:59 +11:00
David Bomba
af77440555 changes for README 2021-01-05 10:46:55 +11:00
David Bomba
9377777f62 Create .keep 2021-01-04 20:15:19 +11:00
David Bomba
ac7c520620 Create .keep 2021-01-04 20:15:03 +11:00
David Bomba
1ae79cde4f Merge pull request #247 from turbo124/master
Fixes for docker file
2021-01-04 20:12:35 +11:00
David Bomba
a58b89c55d Fixes for docker file" 2021-01-04 20:11:50 +11:00
David Bomba
89e6cffa90 Merge pull request #246 from turbo124/master
Fixes for crons and folder permissions
2021-01-03 21:34:27 +11:00
David Bomba
a82d60b4f5 Fixes for crons and folder permissions 2021-01-03 21:34:04 +11:00
David Bomba
32c93eb4d7 Merge pull request #241 from beganovich/v5-skip-snappdf-download
(v5) Add environment variable to skip downloading Chromium (snappdf)
2020-12-30 09:26:34 +11:00
=
9e603ba79f Fixes for crontab 2020-12-30 07:33:50 +11:00
Benjamin Beganović
d9889fcfaa Add variable to skip Chromium download 2020-12-28 14:25:16 +01:00
David Bomba
a89e145bf9 Merge pull request #239 from beganovich/v5-transition-to-snappdf
(v5) Support for snappdf
2020-12-24 09:25:32 +11:00
Benjamin Beganović
85d46e8968 support for snappdf 2020-12-23 18:06:31 +01:00
David Bomba
0fb5fa73e0 Merge pull request #233 from turbo124/master
fixes for docker file
2020-12-05 20:14:39 +11:00
David Bomba
de3a2e4278 fixes for docker file 2020-12-05 20:14:19 +11:00
David Bomba
bb514e8d06 Merge pull request #232 from turbo124/master
Remove storage:link from image build
2020-11-30 10:00:27 +11:00
David Bomba
2034c6ebff Remove storage:link from image build 2020-11-30 09:56:30 +11:00
David Bomba
65e36505a3 Merge pull request #231 from turbo124/master
Minor fixes
2020-11-28 18:07:34 +11:00
David Bomba
03c1e32123 Minor fixes 2020-11-28 18:07:16 +11:00
David Bomba
3612c87323 Merge pull request #230 from turbo124/master
Default to puppeteer PDF generation
2020-11-28 17:51:04 +11:00
David Bomba
4e9731a23e Default to puppeteer PDF generation 2020-11-28 17:50:46 +11:00
David Bomba
dea442c442 Merge pull request #229 from turbo124/master
Install libonig-dev with apk
2020-11-28 17:26:33 +11:00
David Bomba
a24c1b98a3 Install libonig-dev with apk 2020-11-28 17:26:13 +11:00
18 changed files with 396 additions and 233 deletions

View File

@@ -4,17 +4,76 @@
# Docker for [Invoice Ninja](https://www.invoiceninja.com/)
:bulb: Please consider posting your question on [StackOverflow](https://stackoverflow.com/) as this widens the audience that can help you. Just use the tag `invoice-ninja` and we are there to help. This is mostly related to the usage of Invoice Ninja and the docker setup.
If you feel your question is directly related to a code change or you want to sent in a change + PR Github is the right place, of course.
:crown: **Features**
:lock: Automatic HTTPS (:heart: [Caddy](https://caddyserver.com/))
:fire: NGINX webserver support [NGINX](https://nginx.org/)
:hammer: Fully production-ready through docker-compose
:pencil: Adjustable to your needs via environment variable
## 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
## 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.
```
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
```
APP_URL=http://in.localhost:8003/
APP_KEY=<insert your generated key in here>
APP_DEBUG=true
MULTI_DB_ENABLED=false
DB_HOST1=db
DB_USERNAME1=ninja
DB_PASSWORD1=ninja
DB_DATABASE1=ninja
PHANTOMJS_PDF_GENERATION=false
```
The ```APP_KEY``` can be generated by running
```
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....```
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```
### 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```
For example, lets say your APP_URL is ```http://in5.test:8000``` and your LAN IP is 192.168.0.124 the hosts file will have an entry looking like this:
```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.
All that is left to do now is bring up the container
``` docker-compose up -d```
**Note: When performing the setup, the Database host is ```db```
## 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/)
## Documentation
Please see our [wiki](https://github.com/invoiceninja/dockerfiles/wiki) for further guidance.

View File

@@ -1,69 +1,64 @@
ARG PHP_VERSION=7.2
ARG BAK_STORAGE_PATH=/var/www/app/docker-backup-storage/
ARG BAK_PUBLIC_PATH=/var/www/app/docker-backup-public/
FROM php:${PHP_VERSION}-fpm-alpine
LABEL maintainer="Samuel Laulhau <sam@lalop.co>, Holger Lösken <holger.loesken@codedge.de>"
LABEL maintainer="David Bomba <turbo124@gmail.com>"
#####
# SYSTEM REQUIREMENT
#####
ARG INVOICENINJA_VERSION
ARG BAK_STORAGE_PATH
ARG BAK_PUBLIC_PATH
ENV BAK_STORAGE_PATH $BAK_STORAGE_PATH
ENV BAK_PUBLIC_PATH $BAK_PUBLIC_PATH
WORKDIR /var/www/app
COPY entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint \
&& mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN set -eux; \
apk add --no-cache \
gmp-dev \
freetype-dev \
libarchive-tools \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev\
libzip-dev
# Install PHP extensions
# https://hub.docker.com/r/mlocati/php-extension-installer/tags
COPY --from=mlocati/php-extension-installer:1.1.41 /usr/bin/install-php-extensions /usr/local/bin/
RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include --with-webp-dir=/usr/include --with-freetype-dir=/usr/include/; \
docker-php-ext-configure zip --with-libzip; \
docker-php-ext-install -j$(nproc) \
iconv \
gd \
gmp \
mbstring \
opcache \
pdo \
pdo_mysql \
zip
RUN install-php-extensions \
gd \
gmp \
opcache \
pdo_mysql \
zip
COPY ./config/php/php.ini /usr/local/etc/php/php.ini
COPY ./config/php/php-cli.ini /usr/local/etc/php/php-cli.ini
COPY ./config/php/php.ini /usr/local/etc/php/conf.d/in-php.ini
# Separate user
ENV IN_USER=invoiceninja
ENV INVOICENINJA_USER=invoiceninja
RUN addgroup -S "$IN_USER" && \
adduser \
RUN addgroup --gid=1500 -S "$INVOICENINJA_USER" && \
adduser --uid=1500 \
--disabled-password \
--gecos "" \
--home "$(pwd)" \
--ingroup "$IN_USER" \
--ingroup "$INVOICENINJA_USER" \
--no-create-home \
"$IN_USER"; \
addgroup "$IN_USER" www-data; \
chown -R "$IN_USER":"$IN_USER" .
"$INVOICENINJA_USER"; \
addgroup "$INVOICENINJA_USER" www-data; \
chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" .
USER $IN_USER
USER 1500
# Download and install IN
ENV INVOICENINJA_VERSION="${INVOICENINJA_VERSION}"
RUN curl -s -o /tmp/ninja.zip -SL https://download.invoiceninja.com/ninja-v${INVOICENINJA_VERSION}.zip \
&& bsdtar --strip-components=1 -C /var/www/app -xf /tmp/ninja.zip \
&& rm /tmp/ninja.zip \
&& mv /var/www/app/storage /var/www/app/docker-backup-storage \
&& mv /var/www/app/public /var/www/app/docker-backup-public \
RUN curl -o /tmp/ninja.zip -L https://download.invoiceninja.com/ninja-v${INVOICENINJA_VERSION}.zip \
&& unzip -q /tmp/ninja.zip -d /tmp/ \
&& mv /tmp/ninja/* /var/www/app \
&& rm -rf /tmp/ninja* \
&& mv /var/www/app/storage $BAK_STORAGE_PATH \
&& mv /var/www/app/public $BAK_PUBLIC_PATH \
&& mkdir -p /var/www/app/public/logo /var/www/app/storage \
&& cp /var/www/app/.env.example /var/www/app/.env \
&& chmod -R 755 /var/www/app/storage \
&& rm -rf /var/www/app/docs /var/www/app/tests

View File

@@ -1,127 +1,105 @@
ARG PHP_VERSION=7.4
ARG BAK_STORAGE_PATH=/var/www/app/docker-backup-storage/
ARG BAK_PUBLIC_PATH=/var/www/app/docker-backup-public/
# Get Invoice Ninja
FROM alpine:latest as base
# Get Invoice Ninja and install nodejs packages
FROM node:lts-alpine as frontend
ARG INVOICENINJA_VERSION
ARG BAK_STORAGE_PATH
ARG BAK_PUBLIC_PATH
# Install dependencies
RUN set -eux; \
apk add --no-cache \
curl \
mysql-client \
git \
libarchive-tools; \
mkdir -p /var/www/app
curl
RUN curl -o /tmp/ninja.tar.gz -LJ0 https://github.com/invoiceninja/invoiceninja/tarball/v$INVOICENINJA_VERSION \
&& bsdtar --strip-components=1 -C /var/www/app -xf /tmp/ninja.tar.gz \
&& rm /tmp/ninja.tar.gz \
&& cp -R /var/www/app/storage /var/www/app/docker-backup-storage \
&& cp -R /var/www/app/public /var/www/app/docker-backup-public \
# Download Invoice Ninja
RUN curl -o /tmp/ninja.tar.gz -L https://github.com/invoiceninja/invoiceninja/tarball/v$INVOICENINJA_VERSION \
&& mkdir -p /var/www/app \
&& tar --strip-components=1 -xf /tmp/ninja.tar.gz -C /var/www/app/ \
&& mkdir -p /var/www/app/public/logo /var/www/app/storage \
&& cp /var/www/app/.env.example /var/www/app/.env \
&& cp /var/www/app/.env.dusk.example /var/www/app/.env.dusk.local \
&& mv /var/www/app/.env.example /var/www/app/.env \
&& rm -rf /var/www/app/docs /var/www/app/tests
# Install nodejs packages
FROM node:12-alpine as frontend
COPY --from=base /var/www/app /var/www/app
WORKDIR /var/www/app/
RUN npm install
# Install node packages
RUN npm install --production \
&& npm run production \
&& rm -rf node_modules \
&& mv /var/www/app/storage $BAK_STORAGE_PATH \
&& mv /var/www/app/public $BAK_PUBLIC_PATH
# Prepare php image
FROM php:${PHP_VERSION}-fpm-alpine
ARG INVOICENINJA_VERSION
ENV INVOICENINJA_VERSION=$INVOICENINJA_VERSION
ARG BAK_STORAGE_PATH
ARG BAK_PUBLIC_PATH
ENV INVOICENINJA_VERSION $INVOICENINJA_VERSION
ENV BAK_STORAGE_PATH $BAK_STORAGE_PATH
ENV BAK_PUBLIC_PATH $BAK_PUBLIC_PATH
LABEL maintainer="Samuel Laulhau <sam@lalop.co>, Holger Lösken <holger.loesken@codedge.de>"
LABEL maintainer="David Bomba <turbo124@gmail.com>"
WORKDIR /var/www/app
COPY --from=frontend /var/www/app /var/www/app
COPY entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint \
&& mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN apt-get update && apt-get install -y libonig-dev
# Install PHP extensions
# https://hub.docker.com/r/mlocati/php-extension-installer/tags
COPY --from=mlocati/php-extension-installer:1.1.41 /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions \
bcmath \
exif \
gd \
gmp \
mysqli \
opcache \
pdo_mysql \
zip \
@composer
# Install chromium
RUN set -eux; \
apk add --no-cache \
nodejs \
npm \
supervisor \
mysql-client \
freetype-dev \
gmp-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
zip; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j$(nproc) \
bcmath \
exif \
gd \
gmp \
# mbstring \
mysqli \
opcache \
pdo \
pdo_mysql \
zip
git \
chromium \
ttf-freefont
COPY ./config/php/php.ini /usr/local/etc/php/php.ini
COPY ./config/php/php-cli.ini /usr/local/etc/php/php-cli.ini
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
yarn
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Puppeteer v1.19.0 works with Chromium 77.
RUN yarn add puppeteer@1.19.0
COPY ./config/php/php.ini /usr/local/etc/php/conf.d/in-php.ini
COPY ./config/supervisor/supervisord.conf /
## Separate user
ARG UID=1500
ENV INVOICENINJA_USER=invoiceninja
RUN addgroup -S "$INVOICENINJA_USER" && \
adduser \
RUN addgroup --gid=$UID -S "$INVOICENINJA_USER" \
&& adduser --uid=$UID \
--disabled-password \
--gecos "" \
--home "$(pwd)" \
--ingroup "$INVOICENINJA_USER" \
--no-create-home \
"$INVOICENINJA_USER"; \
addgroup "$INVOICENINJA_USER" www-data; \
chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app
"$INVOICENINJA_USER" \
&& addgroup "$INVOICENINJA_USER" www-data \
&& mkdir /var/log/supervisord /var/run/supervisord \
&& chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app \
&& chown $INVOICENINJA_USER:www-data /var/log/supervisord /var/run/supervisord
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer;
USER $UID
## Set up the cronjob and run cron daemon
RUN echo "* * * * * run-parts /etc/periodic/1min" >> /etc/crontabs/root
COPY ./config/cron/cronjob_v5.sh /etc/periodic/1min/invoiceninja_cronjob
RUN chown $INVOICENINJA_USER /etc/periodic/1min/invoiceninja_cronjob && \
crond -l 2 -b
USER $INVOICENINJA_USER
RUN /usr/local/bin/composer install --no-dev --no-suggest --no-progress --quiet
RUN /usr/local/bin/composer install --no-dev --quiet
# Override the environment settings from projects .env file
ENV APP_ENV production
ENV LOG errorlog
RUN php artisan storage:link
ENV SNAPPDF_EXECUTABLE_PATH /usr/bin/chromium-browser
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

1
config/hosts Normal file
View File

@@ -0,0 +1 @@
192.168.0.124 in5.test

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,6 +1,6 @@
server {
listen 80 default_server;
server_name in.localhost;
server_name _;
root /var/www/app/public/;
index index.php;

View File

@@ -1,18 +0,0 @@
session.auto_start = Off
short_open_tag = Off
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
opcache.enable_cli=1
opcache.fast_shutdown=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
# http://symfony.com/doc/current/performance.html
realpath_cache_size = 4096K
realpath_cache_ttl = 600
memory_limit = 2G
post_max_size = 6M
upload_max_filesize = 5M

View File

@@ -1,17 +1,17 @@
session.auto_start = Off
short_open_tag = Off
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
opcache.enable_cli=1
opcache.fast_shutdown=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
;opcache.revalidate_freq=2
opcache.revalidate_freq=60
# http://symfony.com/doc/current/performance.html
realpath_cache_size = 4096K
; Duration of time, in seconds for which to cache realpath information for a given
; file or directory. For systems with rarely changing files, consider increasing this
; value.
; http://php.net/realpath-cache-ttl
;realpath_cache_ttl = 120
realpath_cache_ttl = 600
post_max_size = 6M
upload_max_filesize = 5M
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 8M

8
config/shutdown.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
printf "READY\n";
while read line; do
echo "Processing Event: $line" >&2;
kill -SIGQUIT $PPID
done < /dev/stdin

View File

@@ -0,0 +1,47 @@
[supervisord]
nodaemon=true
user=invoiceninja
pidfile=/var/run/supervisord/supervisord.pid
logfile=/dev/null ; nodaemon will cause logs to go to stdout
logfile_maxbytes=0
loglevel=error
[program:php-fpm]
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=php-fpm
[program:scheduler]
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=php artisan schedule:work
[program:queue-worker]
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
numprocs=2
command=php artisan queue:work --sleep=3 --tries=3 --memory=256
[eventlistener:shutdown]
command=/shutdown.sh
events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View File

@@ -2,59 +2,50 @@ version: '3.7'
services:
server:
image: caddy:alpine
image: nginx
restart: always
environment:
- APP_URL=https://localhost
env_file: env
volumes:
# Vhost configuration
- ./config/caddy/Caddyfile:/etc/caddy/Caddyfile
# Configure your mounted directories, make sure the folder 'public' and 'storage'
# exist, before mounting them
- public:/var/www/app/public
- storage:/var/www/app/storage
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/app/public:/var/www/app/public:rw,delegated
# - ./docker/app/storage:/var/www/app/storage:rw,delegated
#- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
- ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
- ./docker/app/public:/var/www/app/public:rw,delegated
- ./docker/app/storage:/var/www/app/storage:rw,delegated
depends_on:
- app
# Run webserver nginx on port 80
# Feel free to modify depending what port is already occupied
ports:
- "80:80"
- "443:443"
#- "443:443"
networks:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
app:
image: invoiceninja/invoiceninja:5
env_file: env
restart: always
cap_add:
- SYS_ADMIN
environment:
- APP_URL=https://localhost
- APP_KEY=<INSERT THE GENERATED APPLICATION KEY HERE>
- MULTI_DB_ENABLED=false
- DB_HOST1=db
- DB_USERNAME1=ninja
- DB_PASSWORD1=ninja
- DB_DATABASE1=ninja
volumes:
# Configure your mounted directories, make sure the folder 'public' and 'storage'
# exist, before mounting them
- public:/var/www/app/public
- storage:/var/www/app/storage
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/app/public:/var/www/app/public:rw,delegated
# - ./docker/app/storage:/var/www/app/storage:rw,delegated
- ./config/hosts:/etc/hosts:ro
- ./config/shutdown.sh:/usr/local/bin/shutdown.sh
- ./docker/app/public:/var/www/app/public:rw,delegated
- ./docker/app/storage:/var/www/app/storage:rw,delegated
depends_on:
- db
networks:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
db:
image: mysql:5
# 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
@@ -62,19 +53,25 @@ services:
- MYSQL_PASSWORD=ninja
- MYSQL_DATABASE=ninja
volumes:
- mysql-data:/var/lib/mysql:rw
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./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:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
# THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
# cron:
# image: invoiceninja/invoiceninja:alpine-4
# volumes:
# - storage:/var/www/app/storage
# - logo:/var/www/app/public/logo
# - public:/var/www/app/public
# - ./docker/app/public:/var/www/app/public:rw,delegated
# - ./docker/app/storage:/var/www/app/storage:rw,delegated
# - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated
# entrypoint: |
# /bin/sh -c 'sh -s <<EOF
# trap "break;exit" SIGHUP SIGINT SIGTERM
@@ -87,13 +84,7 @@ services:
# EOF'
# networks:
# - invoiceninja
volumes:
mysql-data:
public:
storage:
# This is needed for letting th cron run correctly
# logo:
#
networks:
invoiceninja:
invoiceninja:

1
docker/app/public/.keep Normal file
View File

@@ -0,0 +1 @@

1
docker/app/storage/.keep Normal file
View File

@@ -0,0 +1 @@

View File

@@ -47,43 +47,43 @@ if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
BAK_STORAGE_PATH=/var/www/app/docker-backup-storage/
BAK_LOGO_PATH=/var/www/app/docker-backup-public/logo/
if [ ! -d /var/www/app/storage ]; then
cp -Rp $BAK_STORAGE_PATH /var/www/app/storage
else
if [ -d $BAK_STORAGE_PATH ]; then
IN_STORAGE_BACKUP="$(ls $BAK_STORAGE_PATH)"
for path in $IN_STORAGE_BACKUP; do
if [ ! -e "/var/www/app/storage/$path" ]; then
cp -Rp "$BAK_STORAGE_PATH/$path" "/var/www/app/storage/"
fi
done
fi
# create storage volume
if [ ! -d /var/www/app/storage ] && [ -d "$BAK_STORAGE_PATH" ]; then
mv "$BAK_STORAGE_PATH" /var/www/app/storage
elif [ -d "$BAK_STORAGE_PATH" ]; then
# copy missing folders in storage
IN_STORAGE_BACKUP="$(ls "$BAK_STORAGE_PATH")"
for path in $IN_STORAGE_BACKUP; do
if [ ! -e "/var/www/app/storage/$path" ]; then
cp -Rp "$BAK_STORAGE_PATH/$path" "/var/www/app/storage/"
fi
done
fi
rm -rf "$BAK_STORAGE_PATH"
if [ ! -d /var/www/app/public/logo ] && [ -d $BAK_LOGO_PATH ]; then
cp -Rp $BAK_LOGO_PATH /var/www/app/public/logo
else
if [ -d $BAK_LOGO_PATH ]; then
IN_LOGO_BACKUP="$(ls $BAK_LOGO_PATH)"
for path in $IN_LOGO_BACKUP; do
if [ ! -e "/var/www/app/public/logo/$path" ]; then
cp -Rp "$BAK_LOGO_PATH/$path" "/var/www/app/public/logo/"
fi
done
fi
fi
# compare public volume version with image version
if [ ! -e /var/www/app/public/version ] || [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then
cp -au /var/www/app/docker-backup-public/* /var/www/app/public/
echo $INVOICENINJA_VERSION > /var/www/app/public/version
# create public volume
if [ ! -d /var/www/app/public ] && [ -d "$BAK_PUBLIC_PATH" ]; then
mv "$BAK_PUBLIC_PATH" /var/www/app/public
elif [ ! -e /var/www/app/public/version ] || [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then
# version mismatch, update all
cp -au "$BAK_PUBLIC_PATH/"* /var/www/app/public
echo "$INVOICENINJA_VERSION" > /var/www/app/public/version
elif [ ! -d /var/www/app/public/logo ] && [ -d "$BAK_PUBLIC_PATH/logo" ]; then
# missing logo folder only, copy folder
cp -a "$BAK_PUBLIC_PATH/logo" /var/www/app/public/logo
elif [ -d "$BAK_PUBLIC_PATH/logo" ]; then
# copy missing folders in logo
IN_LOGO_BACKUP="$(ls "$BAK_PUBLIC_PATH/logo")"
for path in $IN_LOGO_BACKUP; do
if [ ! -e "/var/www/app/public/logo/$path" ]; then
cp -a "$BAK_PUBLIC_PATH/logo/$path" "/var/www/app/public/logo/"
fi
done
fi
rm -rf "$BAK_PUBLIC_PATH"
# Set permission for web server to create/update files
chown -R invoiceninja:www-data /var/www/app/storage /var/www/app/public /var/www/app/bootstrap
chown -R "$INVOICENINJA_USER":www-data /var/www/app/storage /var/www/app/public /var/www/app/bootstrap
# Initialize values that might be stored in a file
file_env 'APP_KEY'
@@ -104,5 +104,6 @@ file_env 'S3_SECRET'
# Run Laravel stuff
php artisan config:cache
php artisan optimize
php artisan migrate --force
exec docker-php-entrypoint "$@"

19
env Normal file
View File

@@ -0,0 +1,19 @@
APP_URL=http://in.localhost:8003/
APP_KEY=<insert your generated key in here>
APP_DEBUG=true
MULTI_DB_ENABLED=false
DB_HOST1=db
DB_USERNAME1=ninja
DB_PASSWORD1=ninja
DB_DATABASE1=ninja
#this is a system variable please do not remove
IS_DOCKER=true
#V4 env vars
DB_STRICT=false
DB_HOST=db
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=ninja
APP_CIPHER=AES-256-CBC

View File

@@ -0,0 +1,13 @@
FROM invoiceninja/invoiceninja:5
USER root
RUN apk add --no-cache supervisor \
&& mkdir /var/log/supervisord /var/run/supervisord \
&& chown $INVOICENINJA_USER:www-data /var/log/supervisord /var/run/supervisord
COPY supervisord.conf /
USER $INVOICENINJA_USER
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

View File

@@ -0,0 +1,29 @@
[supervisord]
nodaemon=true
user=invoiceninja
pidfile=/var/run/supervisord/supervisord.pid
logfile=/dev/null ; nodaemon will cause logs to go to stdout
logfile_maxbytes=0
loglevel=error
[program:php-fpm]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=php-fpm
[program:scheduler]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=php artisan schedule:work
[program:queue-worker]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
numprocs=2
command=php artisan queue:work --sleep=3 --tries=1 --memory=1024 --timeout=3600 --daemon