Compare commits

...

32 Commits

Author SHA1 Message Date
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
11 changed files with 164 additions and 87 deletions

View File

@@ -4,17 +4,72 @@
# 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
## 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

@@ -2,7 +2,7 @@ ARG PHP_VERSION=7.2
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
@@ -24,8 +24,8 @@ RUN set -eux; \
libzip-dev
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) \
docker-php-ext-configure zip --with-libzip; \
docker-php-ext-install -j$(nproc) \
iconv \
gd \
gmp \
@@ -41,8 +41,8 @@ COPY ./config/php/php-cli.ini /usr/local/etc/php/php-cli.ini
# Separate user
ENV IN_USER=invoiceninja
RUN addgroup -S "$IN_USER" && \
adduser \
RUN addgroup --gid=1500 -S "$IN_USER" && \
adduser --uid=1500 \
--disabled-password \
--gecos "" \
--home "$(pwd)" \
@@ -63,7 +63,6 @@ RUN curl -s -o /tmp/ninja.zip -SL https://download.invoiceninja.com/ninja-v${INV
&& mv /var/www/app/storage /var/www/app/docker-backup-storage \
&& mv /var/www/app/public /var/www/app/docker-backup-public \
&& 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

@@ -6,13 +6,11 @@ ARG INVOICENINJA_VERSION
RUN set -eux; \
apk add --no-cache \
curl \
mysql-client \
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 \
&& mkdir -p /var/www/app \
&& tar --strip-components=1 -xf /tmp/ninja.tar.gz -C /var/www/app/ \
&& 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 \
@@ -26,14 +24,16 @@ FROM node:12-alpine as frontend
COPY --from=base /var/www/app /var/www/app
WORKDIR /var/www/app/
RUN npm install
RUN npm install --production \
&& npm run production \
&& rm -rf node_modules
# Prepare php image
FROM php:${PHP_VERSION}-fpm-alpine
ARG INVOICENINJA_VERSION
ENV INVOICENINJA_VERSION=$INVOICENINJA_VERSION
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
@@ -43,8 +43,6 @@ RUN chmod +x /usr/local/bin/docker-entrypoint
RUN set -eux; \
apk add --no-cache \
nodejs \
npm \
mysql-client \
freetype-dev \
gmp-dev \
@@ -53,9 +51,13 @@ RUN set -eux; \
libzip-dev \
oniguruma-dev \
git \
zip; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j$(nproc) \
busybox-suid \
zip \
chromium \
harfbuzz \
ttf-freefont \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
bcmath \
exif \
gd \
@@ -70,40 +72,24 @@ RUN set -eux; \
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
## Separate user
ENV INVOICENINJA_USER=invoiceninja
RUN addgroup -S "$INVOICENINJA_USER" && \
adduser \
RUN addgroup --gid=1500 -S "$INVOICENINJA_USER" \
&& adduser --uid=1500 \
--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 \
&& chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer;
## 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

16
config/cron.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
echo "Early Entry"
cleanup ()
{
kill -s SIGTERM $!
exit 0
}
trap cleanup SIGINT SIGTERM
while :
do
sleep 60 ; cd /var/www/app/ && php artisan schedule:run;
done

1
config/hosts Normal file
View File

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

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

@@ -2,61 +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
#- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
- ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
# 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
- ./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
- PHANTOMJS_PDF_GENERATION=false
- SNAPPDF_EXECUTABLE_PATH="/usr/bin/chromium-browser"
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
- ./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
ports:
- "3305:3306"
restart: always
environment:
- MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
@@ -64,19 +53,36 @@ 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
networks:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
# THIS IS ONLY A VALID CONFIGURATION FOR IN 5. DO NOT USE FOR IN 4.
cron:
image: invoiceninja/invoiceninja:5
env_file: env
volumes:
- ./config/cron.sh:/usr/local/bin/cron.sh
- ./config/hosts:/etc/hosts:ro
- ./docker/app/public:/var/www/app/public:rw,delegated
- ./docker/app/storage:/var/www/app/storage:rw,delegated
command:
- cron.sh
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
@@ -89,13 +95,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

@@ -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 "$@"

17
env Normal file
View File

@@ -0,0 +1,17 @@
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
#V4 env vars
DB_STRICT=false
DB_HOST=db
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=ninja
APP_CIPHER=AES-256-CBC