Add new ways to explore containerized Akaunting!

This commit is contained in:
Mohammed Al-Mahdawi 2021-03-22 10:11:25 +03:00
parent 70f0a4e53e
commit b7d7379e17
12 changed files with 2486 additions and 0 deletions

View File

@ -94,6 +94,20 @@ A robust TLS termination and load-balancing setup should outperform, and be easi
Right now, the only built language is US English. If you would like more supported locales to be built into the container image, please [open an issue](https://github.com/akaunting/docker/issues). Right now, the only built language is US English. If you would like more supported locales to be built into the container image, please [open an issue](https://github.com/akaunting/docker/issues).
## Extra ways to explore containerized Akaunting!
This repository contains extra compose and other files that allows you to run Akaunting in different setups like using FPM and NGINX and here is the most important commands that you may need:
```shell
# Run Akaunting with FPM on Debian and use Nginx as external proxy
AKAUNTING_SETUP=true docker-compose -f fpm-docker-compose.yml up --build
# Run Akaunting using FPM on Alpine and using Nginx as external proxy
AKAUNTING_SETUP=true docker-compose -f fpm-docker-compose.yml -f fpm-alpine-docker-compose.yml up --build
# Run Akaunting using FPM on Alpine and using Nginx as internal proxy
AKAUNTING_SETUP=true docker-compose -f fpm-alpine-nginx-docker-compose.yml up --build
```
## License ## License
Akaunting is released under the [GPLv3 license](LICENSE.txt). Akaunting is released under the [GPLv3 license](LICENSE.txt).

View File

@ -0,0 +1,62 @@
#!/bin/bash -e
do_start=
do_shell=
do_setup=
while [ $# -gt 0 ]; do
case "$1" in
--start)
do_start=true
;;
--shell)
do_start=false
do_shell=true
;;
--setup)
do_setup=true
do_start=true
;;
esac
shift
done
mkdir -p storage/framework/{sessions,views,cache}
mkdir -p storage/app/uploads
if [ "$do_setup" -o "$AKAUNTING_SETUP" == "true" ]; then
retry_for=30
retry_interval=5
while sleep $retry_interval; do
if php artisan install \
--db-host=$DB_HOST \
--db-name=$DB_DATABASE \
--db-username=$DB_USERNAME \
"--db-password=$DB_PASSWORD" \
--db-prefix=$DB_PREFIX \
"--company-name=$COMPANY_NAME" \
"--company-email=$COMPANY_EMAIL" \
"--admin-email=$ADMIN_EMAIL" \
"--admin-password=$ADMIN_PASSWORD" \
"--locale=$LOCALE" --no-interaction; then break
else
if [ $retry_for -le 0 ]; then
echo "Unable to find database!" >&2
exit 1
fi
(( retry_for -= retry_interval ))
fi
done
else
unset COMPANY_NAME COMPANY_EMAIL ADMIN_EMAIL ADMIN_PASSWORD
fi
chmod -R u=rwX,g=rX,o=rX /var/www/html
chown -R www-data:root /var/www/html
if [ "$do_start" ]; then
php-fpm -D
nginx -g "daemon off;"
elif [ "$do_shell" ]; then
exec /bin/bash -li
fi

61
files/akaunting-php-fpm.sh Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash -e
do_start=
do_shell=
do_setup=
while [ $# -gt 0 ]; do
case "$1" in
--start)
do_start=true
;;
--shell)
do_start=false
do_shell=true
;;
--setup)
do_setup=true
do_start=true
;;
esac
shift
done
mkdir -p storage/framework/{sessions,views,cache}
mkdir -p storage/app/uploads
if [ "$do_setup" -o "$AKAUNTING_SETUP" == "true" ]; then
retry_for=30
retry_interval=5
while sleep $retry_interval; do
if php artisan install \
--db-host=$DB_HOST \
--db-name=$DB_DATABASE \
--db-username=$DB_USERNAME \
"--db-password=$DB_PASSWORD" \
--db-prefix=$DB_PREFIX \
"--company-name=$COMPANY_NAME" \
"--company-email=$COMPANY_EMAIL" \
"--admin-email=$ADMIN_EMAIL" \
"--admin-password=$ADMIN_PASSWORD" \
"--locale=$LOCALE" --no-interaction; then break
else
if [ $retry_for -le 0 ]; then
echo "Unable to find database!" >&2
exit 1
fi
(( retry_for -= retry_interval ))
fi
done
else
unset COMPANY_NAME COMPANY_EMAIL ADMIN_EMAIL ADMIN_PASSWORD
fi
chmod -R u=rwX,g=rX,o=rX /var/www/html
chown -R www-data:root /var/www/html
if [ "$do_start" ]; then
exec docker-php-entrypoint php-fpm
elif [ "$do_shell" ]; then
exec /bin/bash -li
fi

1950
files/php.ini Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
version: '3.7'
services:
akaunting:
build:
dockerfile: fpm-alpine.Dockerfile
context: .
akaunting-proxy:
image: nginx:1.19.0-alpine

View File

@ -0,0 +1,34 @@
version: '3.7'
services:
akaunting:
image: docker.io/akaunting/akaunting:latest
build:
dockerfile: fpm-alpine-nginx.Dockerfile
context: .
volumes:
- akaunting-data:/var/www/html
- ./files/php.ini:/usr/local/etc/php/php.ini
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
restart: unless-stopped
ports:
- 8080:80
env_file:
- env/run.env
environment:
- AKAUNTING_SETUP
depends_on:
- akaunting-db
akaunting-db:
image: mariadb
volumes:
- akaunting-db:/var/lib/mysql
restart: unless-stopped
env_file:
- env/db.env
volumes:
akaunting-data:
akaunting-db:

View File

@ -0,0 +1,42 @@
FROM php:7.4-fpm-alpine3.12
# Arguments defined in docker-compose.yml
ARG AKAUNTING_DOCKERFILE_VERSION=0.1
ARG SUPPORTED_LOCALES="en_US.UTF-8"
# Add Repositories
RUN rm -f /etc/apk/repositories &&\
echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories
# Add Dependencies
RUN apk add --update --no-cache \
nano \
bash \
nginx
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install PHP Extensions
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions gd zip intl imap xsl pgsql opcache bcmath mysqli pdo_mysql
# Configure Extension
RUN docker-php-ext-configure \
opcache --enable-opcache
# Download Akaunting application
RUN mkdir -p /var/www/akaunting \
&& curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers' \
&& unzip /tmp/akaunting.zip -d /var/www/html \
&& rm -f /tmp/akaunting.zip
COPY files/akaunting-php-fpm-nginx.sh /usr/local/bin/akaunting-php-fpm-nginx.sh
COPY files/html /var/www/html
# Setup Working Dir
WORKDIR /var/www/html
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/akaunting-php-fpm-nginx.sh"]
CMD ["--start"]

67
fpm-alpine.Dockerfile Normal file
View File

@ -0,0 +1,67 @@
FROM php:7.4-fpm-alpine3.12
# Arguments defined in docker-compose.yml
ARG AKAUNTING_DOCKERFILE_VERSION=0.1
ARG SUPPORTED_LOCALES="en_US.UTF-8"
# Add Repositories
RUN rm -f /etc/apk/repositories &&\
echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories
# Add Build Dependencies
RUN apk add --no-cache --virtual .build-deps \
zlib-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \
bzip2-dev \
zip \
libzip-dev
# Add Production Dependencies
RUN apk add --update --no-cache \
jpegoptim \
pngquant \
optipng \
supervisor \
nano \
bash \
icu-dev \
freetype-dev \
mysql-client
# Configure & Install Extension
RUN docker-php-ext-configure \
opcache --enable-opcache &&\
docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ && \
docker-php-ext-install \
opcache \
mysqli \
pdo \
pdo_mysql \
sockets \
json \
intl \
gd \
xml \
bz2 \
pcntl \
bcmath \
zip
# Download Akaunting application
RUN mkdir -p /var/www/akaunting \
&& curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers' \
&& unzip /tmp/akaunting.zip -d /var/www/html \
&& rm -f /tmp/akaunting.zip
COPY files/akaunting-php-fpm.sh /usr/local/bin/akaunting-php-fpm.sh
COPY files/html /var/www/html
# Setup Working Dir
WORKDIR /var/www/html
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/akaunting-php-fpm.sh"]
CMD ["--start"]

40
fpm-docker-compose.yml Normal file
View File

@ -0,0 +1,40 @@
version: '3.7'
services:
akaunting:
image: docker.io/akaunting/akaunting:latest
build:
dockerfile: fpm.Dockerfile
context: .
volumes:
- akaunting-data:/var/www/html
restart: unless-stopped
env_file:
- env/run.env
environment:
- AKAUNTING_SETUP
depends_on:
- akaunting-db
akaunting-proxy:
image: nginx:1.19.0
ports:
- 8080:80
depends_on:
- akaunting
volumes:
- akaunting-data:/var/www/html
- ./nginx/templates:/etc/nginx/templates
akaunting-db:
image: mariadb
volumes:
- akaunting-db:/var/lib/mysql
restart: unless-stopped
env_file:
- env/db.env
volumes:
akaunting-data:
akaunting-db:

63
fpm.Dockerfile Normal file
View File

@ -0,0 +1,63 @@
FROM php:7.4-fpm
# Arguments defined in docker-compose.yml
ARG AKAUNTING_DOCKERFILE_VERSION=0.1
ARG SUPPORTED_LOCALES="en_US.UTF-8"
RUN apt-get update \
&& apt-get -y upgrade --no-install-recommends \
&& apt-get install -y \
build-essential \
imagemagick \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libjpeg-dev \
libmcrypt-dev \
libonig-dev \
libpng-dev \
libpq-dev \
libssl-dev \
libxml2-dev \
libxrender1 \
libzip-dev \
locales \
openssl \
unzip \
zip \
zlib1g-dev \
--no-install-recommends \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN for locale in ${SUPPORTED_LOCALES}; do \
sed -i 's/^# '"${locale}/${locale}/" /etc/locale.gen; done \
&& locale-gen
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
&& docker-php-ext-install -j$(nproc) \
gd \
bcmath \
intl \
mbstring \
pcntl \
pdo \
pdo_mysql \
zip
# Download Akaunting application
RUN mkdir -p /var/www/akaunting \
&& curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers' \
&& unzip /tmp/akaunting.zip -d /var/www/html \
&& rm -f /tmp/akaunting.zip
COPY files/akaunting-php-fpm.sh /usr/local/bin/akaunting-php-fpm.sh
COPY files/html /var/www/html
# Set working directory
WORKDIR /var/www/html
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/akaunting-php-fpm.sh"]
CMD ["--start"]

89
nginx/nginx.conf Normal file
View File

@ -0,0 +1,89 @@
# Generic startup file.
user www-data;
#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes auto;
worker_cpu_affinity auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Keeps the logs free of messages about not being able to bind().
#daemon off;
events {
worker_connections 1024;
}
http {
# rewrite_log on;
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
# tcp_nopush on;
keepalive_timeout 64;
# tcp_nodelay on;
# gzip on;
#php max upload limit cannot be larger than this
client_max_body_size 13m;
index index.php index.html index.htm;
# Upstream to abstract backend connection(s) for PHP.
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/tmp/php-fpm.sock;
server localhost:9000;
}
server {
listen 80 default_server;
server_name _;
root /var/www/html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Prevent Direct Access To Protected Files
location ~ \.(env|log) {
deny all;
}
# Prevent Direct Access To Protected Folders
location ~ ^/(^app$|bootstrap|config|database|overrides|resources|routes|storage|tests|artisan) {
deny all;
}
# Prevent Direct Access To modules/vendor Folders Except Assets
location ~ ^/(modules|vendor)\/(.*)\.((?!ico|gif|jpg|jpeg|png|js\b|css|less|sass|font|woff|woff2|eot|ttf|svg).)*$ {
deny all;
}
error_page 404 /index.php;
# Pass PHP Scripts To FastCGI Server
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
}

View File

@ -0,0 +1,54 @@
upstream php {
server unix:/tmp/php-fpm.sock;
server akaunting:9000;
}
server {
listen 80 default_server;
server_name _;
root /var/www/html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Prevent Direct Access To Protected Files
location ~ \.(env|log) {
deny all;
}
# Prevent Direct Access To Protected Folders
location ~ ^/(^app$|bootstrap|config|database|overrides|resources|routes|storage|tests|artisan) {
deny all;
}
# Prevent Direct Access To modules/vendor Folders Except Assets
location ~ ^/(modules|vendor)\/(.*)\.((?!ico|gif|jpg|jpeg|png|js\b|css|less|sass|font|woff|woff2|eot|ttf|svg).)*$ {
deny all;
}
error_page 404 /index.php;
# Pass PHP Scripts To FastCGI Server
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}