mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2026-01-01 03:57:25 +01:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
805e526fc9 | ||
|
|
cdc35aff2f | ||
|
|
1de16ab390 | ||
|
|
b9ab50800d | ||
|
|
d2d03b9b18 | ||
|
|
ea0f3fa981 | ||
|
|
1d9a8681b2 | ||
|
|
f98b3915bd | ||
|
|
8762276c6f | ||
|
|
afcd9389ed | ||
|
|
591c799864 | ||
|
|
4c9c5ddd95 | ||
|
|
994d75a07e | ||
|
|
3348a2beb6 | ||
|
|
c30cae4a99 | ||
|
|
1ed95cdcec | ||
|
|
94126385e2 | ||
|
|
e64dd79cfc | ||
|
|
5942c1c362 | ||
|
|
78b5e59cd5 | ||
|
|
d1a8922f7d | ||
|
|
d87e5948bf | ||
|
|
f4cade9fac | ||
|
|
49f4266418 | ||
|
|
e7f6ef4c35 |
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at contact@invoiceninja.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
169
README.md
169
README.md
@@ -14,172 +14,7 @@ If you feel your question is directly related to a code change or you want to se
|
||||
:pencil: Adjustable to your needs via environment variable
|
||||
|
||||
|
||||
## Prerequisites
|
||||
## Documentation
|
||||
|
||||
### Generate an application key
|
||||
Please see our [wiki](https://github.com/invoiceninja/dockerfiles/wiki) for further guidance.
|
||||
|
||||
Before starting Invoice Ninja via Docker make sure you generate a valid application key. If you are not sure what an application key is, please visit [this blog post](https://tighten.co/blog/app-key-and-you/).
|
||||
|
||||
To generate an application key just run
|
||||
|
||||
```shell
|
||||
docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
|
||||
```
|
||||
|
||||
This will generate an application key for you which you need later.
|
||||
|
||||
### Create folders for data persistence
|
||||
|
||||
To make your data persistent, you have to mount `public` and `storage` from your host to your containers.
|
||||
|
||||
1. Create two folder on your host, e. g. `/var/invoiceninja/public` and `/var/invoiceninja/storage`
|
||||
2. Mount these folders into your container - see [usage](#usage)
|
||||
|
||||
You can create these folders wherever you want on your host system.
|
||||
|
||||
:warning: When using host mounted folder for persistence, make sure they are owned by the proper user and group. As we run Invoice Ninja without `root` , we use a separate user, the folders on the host system need to be owned by uid `1000` and a gid `101`.
|
||||
|
||||
Run this on your host system
|
||||
|
||||
```shell
|
||||
chown -R 1000:101 /var/invoiceninja/public /var/invoiceninja/storage
|
||||
```
|
||||
|
||||
to apply the proper permission to the folders. This also applies to the `docker-compose` setup when using [bind-mounted host directories](https://github.com/invoiceninja/dockerfiles/blob/master/docker-compose.yml#L17).
|
||||
|
||||
|
||||
### PhantomJS key
|
||||
|
||||
The PhantomJS key is set to `a-demo-key-with-low-quota-per-ip-address`. This demo key is limited to 100 requests per day.
|
||||
|
||||
To set a different key feel free to add `-e PHANTOMJS_CLOUD_KEY='<INSERT YOUR PHANTOMJS KEY HERE>'` to thee docker command below.
|
||||
|
||||
For further configuration and toubleshotting regarding PhantomJS and Invoice Ninja [see documentation here](https://docs.invoiceninja.com/configure.html?#phantomjs).
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
:warning: The `latest` tag contains the new version 5 of Invoice Ninja which is still in alpha state. To stick to the version 4 please use `alpine-4` tag.
|
||||
|
||||
To run it:
|
||||
|
||||
```shell
|
||||
docker run -d \
|
||||
-v /var/invoiceninja/public:/var/app/public \
|
||||
-v /var/invoiceninja/storage:/var/app/storage \
|
||||
-e APP_URL='http://ninja.dev' \
|
||||
-e APP_KEY='<INSERT THE GENERATED APPLICATION KEY HERE>' \
|
||||
-e DB_HOST='localhost' \
|
||||
-e DB_DATABASE='ninja' \
|
||||
-e DB_USERNAME='ninja' \
|
||||
-e DB_PASSWORD='ninja' \
|
||||
-p '9000:9000' \
|
||||
--name invoiceninja \
|
||||
invoiceninja/invoiceninja:alpine-4
|
||||
```
|
||||
A list of environment variables can be found [here](https://github.com/invoiceninja/invoiceninja/blob/master/.env.example).
|
||||
|
||||
|
||||
### With docker-compose
|
||||
|
||||
Running Invoice Ninja with docker-compose gives you everything to quickly start. Before starting please make sure you configured your setup correctly. You can do so by opening the `docker-compose.yml` and may change the follwing items.
|
||||
|
||||
:warning: The `docker-compose.yml` runs the new version 5 of Invoice Ninja which is still in alpha state. To stick to the version 4 please use `alpine-4` tag.
|
||||
|
||||
**Port**
|
||||
|
||||
_default: 80_
|
||||
|
||||
This is the port where your Invoice Ninja is reachable, when you type in `http://<your-domain.com>`. If it should be different than `80` make sure to call your installation `http://<your-domain.com>:<YOUR-PORT>`, e. g. `http://<your-domain.com>:8080`.
|
||||
|
||||
```yml
|
||||
ports:
|
||||
- "8080:80" # To run it on port 8080
|
||||
```
|
||||
|
||||
:warning: Make sure the port set is available and not occupied by another service on your host system.
|
||||
|
||||
**URL and application key**
|
||||
|
||||
_default: https://localhost_
|
||||
|
||||
For generating a proper application key see [generate an application key](#generate-an-application-key). Change the value where your Invoice Ninja installation should be reachable.
|
||||
|
||||
```yml
|
||||
environment:
|
||||
- APP_URL=http://localhost
|
||||
````
|
||||
|
||||
**MYSQL root password**
|
||||
|
||||
_default: ninjaAdm1nPassword_
|
||||
|
||||
The mysql database server comes with two users: one for accessing the Invoice Ninja database and the `root` user. Please change the default password for `root` to something more special :wink:
|
||||
|
||||
**Volumes and directories**
|
||||
|
||||
_default: volumes_
|
||||
|
||||
This is the place where your uploaded files are stored. Normally this is a so called _volume_ which can be reused by different docker containers. One might prefer to store the files directly on the host system - for this the config section is prepared with what is called _bind-mounted host directory_. Just adjust the paths and Invoice Ninja stores the user files on the host system.
|
||||
|
||||
```yml
|
||||
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
|
||||
```
|
||||
|
||||
The sample above stores the files on the post at `./docker/app/public` and `./docker/app/storage`.
|
||||
|
||||
:warning: If using bind-mounted host directories make sure they exists and have proper rights. See [here](#create-folders-for-data-persistence) for details.
|
||||
|
||||
## Docker secrets
|
||||
|
||||
:information_source: This feature is borrowed from [mariadb docker image](https://hub.docker.com/_/mariadb).
|
||||
|
||||
As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to the below listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in _/run/secrets/<secret_name>_ files.
|
||||
|
||||
Supported are these variables:
|
||||
`APP_KEY`, `API_SECRET`, `CLOUDFLARE_API_KEY`, `DB_USERNAME`, `DB_PASSWORD`, `MAIL_USERNAME`, `MAIL_PASSWORD`, `MAILGUN_SECRET`, `S3_KEY`, `S3_SECRET`
|
||||
|
||||
|
||||
## Debugging your Docker setup
|
||||
|
||||
Even when running your Invoice Ninja setup with Docker - errors can occur. Depending on where the error happens - the webserver, Invoice Ninja or the database - different log files can be responsible.
|
||||
|
||||
### Show logs without `docker-compose`
|
||||
|
||||
If you are not running `docker-compose` you first need to find the container id for your php container with `docker ps`. Then you can run
|
||||
|
||||
```shell
|
||||
docker logs -f <CONTAINER NAME>
|
||||
```
|
||||
|
||||
This gives you a constant output of the log files for the php container.
|
||||
|
||||
### Show logs with `docker-compose`
|
||||
|
||||
If you are running the `docker-compose` setup you can output all logs, from all containers, with the following command
|
||||
|
||||
```shell
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
If you better want a physical log file in in your `storage/logs` folder, just add `-e LOG=single` to the [usage](#usage) command.
|
||||
Or add an environment variable
|
||||
|
||||
```yml
|
||||
...
|
||||
environment:
|
||||
LOG: single
|
||||
...
|
||||
```
|
||||
|
||||
to your `docker-compose.yml`.
|
||||
|
||||
This generated log file will only hold Invoice Ninja information.
|
||||
|
||||
@@ -7,6 +7,7 @@ ARG INVOICENINJA_VERSION
|
||||
RUN set -eux; \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
mysql-client \
|
||||
libarchive-tools; \
|
||||
mkdir -p /var/www/app
|
||||
|
||||
@@ -43,6 +44,9 @@ RUN chmod +x /usr/local/bin/docker-entrypoint
|
||||
|
||||
RUN set -eux; \
|
||||
apk add --no-cache \
|
||||
nodejs \
|
||||
npm \
|
||||
mysql-client \
|
||||
freetype-dev \
|
||||
gmp-dev \
|
||||
libjpeg-turbo-dev \
|
||||
@@ -65,6 +69,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
|
||||
|
||||
# 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
|
||||
|
||||
## Separate user
|
||||
ENV INVOICENINJA_USER=invoiceninja
|
||||
|
||||
@@ -80,16 +102,21 @@ RUN addgroup -S "$INVOICENINJA_USER" && \
|
||||
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; \
|
||||
composer global require hirak/prestissimo;
|
||||
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 composer install --no-dev --no-suggest --no-progress
|
||||
RUN composer install --no-dev --no-suggest --no-progress --quiet
|
||||
|
||||
# Override the environment settings from projects .env file
|
||||
ENV APP_ENV production
|
||||
ENV LOG errorlog
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint"]
|
||||
CMD ["php-fpm"]
|
||||
CMD ["php-fpm"]
|
||||
|
||||
3
config/cron/cronjob_v5.sh
Executable file
3
config/cron/cronjob_v5.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
cd /var/www/app; php artisan schedule:run >> /dev/null 2>&1
|
||||
25
config/nginx/in-vhost.conf
Normal file
25
config/nginx/in-vhost.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name in.localhost;
|
||||
|
||||
root /var/www/app/public/;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_intercept_errors off;
|
||||
fastcgi_buffer_size 16k;
|
||||
fastcgi_buffers 4 16k;
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,16 @@ services:
|
||||
app:
|
||||
image: invoiceninja/invoiceninja:5
|
||||
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
|
||||
@@ -55,7 +60,7 @@ services:
|
||||
- MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
|
||||
- MYSQL_USER=ninja
|
||||
- MYSQL_PASSWORD=ninja
|
||||
- MYSQL_DATABASE=db-ninja-01
|
||||
- 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!
|
||||
@@ -63,15 +68,15 @@ services:
|
||||
networks:
|
||||
- invoiceninja
|
||||
|
||||
|
||||
# THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
|
||||
# cron:
|
||||
# image: invoiceninja/invoiceninja
|
||||
# image: invoiceninja/invoiceninja:alpine-4
|
||||
# volumes:
|
||||
# - storage:/var/www/app/storage
|
||||
# - logo:/var/www/app/public/logo
|
||||
# - public:/var/www/app/public
|
||||
# entrypoint: |
|
||||
# bash -c 'bash -s <<EOF
|
||||
# /bin/sh -c 'sh -s <<EOF
|
||||
# trap "break;exit" SIGHUP SIGINT SIGTERM
|
||||
# sleep 300s
|
||||
# while /bin/true; do
|
||||
@@ -87,6 +92,8 @@ volumes:
|
||||
mysql-data:
|
||||
public:
|
||||
storage:
|
||||
# This is needed for letting th cron run correctly
|
||||
# logo:
|
||||
|
||||
networks:
|
||||
invoiceninja:
|
||||
invoiceninja:
|
||||
|
||||
@@ -41,6 +41,7 @@ file_env() {
|
||||
unset "$fileVar"
|
||||
}
|
||||
|
||||
|
||||
# first arg is `-f` or `--some-option`
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- php-fpm "$@"
|
||||
@@ -89,7 +90,11 @@ file_env 'APP_KEY'
|
||||
file_env 'API_SECRET'
|
||||
file_env 'CLOUDFLARE_API_KEY'
|
||||
file_env 'DB_USERNAME'
|
||||
file_env 'DB_USERNAME1'
|
||||
file_env 'DB_USERNAME2'
|
||||
file_env 'DB_PASSWORD'
|
||||
file_env 'DB_PASSWORD1'
|
||||
file_env 'DB_PASSWORD2'
|
||||
file_env 'MAIL_USERNAME'
|
||||
file_env 'MAIL_PASSWORD'
|
||||
file_env 'MAILGUN_SECRET'
|
||||
|
||||
Reference in New Issue
Block a user