Add volume files check setup

This commit is contained in:
Mohammed Al-Mahdawi 2022-06-22 11:00:51 +03:00
parent d38a61df23
commit 910b415ab5
6 changed files with 174 additions and 4 deletions

View File

@ -13,12 +13,14 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
image: ['', fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer, fpm-alpine-nginx-composer-supervisor]
image: ['', v, fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer, fpm-alpine-nginx-composer-supervisor]
include:
- image: ''
file: Dockerfile
- image: fpm
file: fpm.Dockerfile
- image: v
file: v.Dockerfile
- image: fpm-alpine
file: fpm-alpine.Dockerfile
- image: fpm-alpine-nginx
@ -67,10 +69,10 @@ jobs:
fi
fi
- name: Set up QEMU
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
@ -79,7 +81,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push images
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
uses: docker/build-push-action@v2
with:
context: .

View File

@ -98,6 +98,9 @@ Right now, the only built language is US English. If you would like more support
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 setup that checks for volume files before copying them.
AKAUNTING_SETUP=true docker-compose -f v-docker-compose.yml up --build
# Run Akaunting with FPM on Debian and use Nginx as external proxy
AKAUNTING_SETUP=true docker-compose -f fpm-docker-compose.yml up --build

1
env/run.env.example vendored
View File

@ -4,6 +4,7 @@ LOCALE=en-US
# Don't change this unless you rename your database container or use rootless podman, in case of using rootless podman you should set it to 127.0.0.1 (NOT localhost)
DB_HOST=akaunting-db
DB_PORT=3306
# Change these to match env/db.env
DB_DATABASE=akaunting

71
files/akaunting-v.sh Executable file
View File

@ -0,0 +1,71 @@
#!/bin/bash -e
a2enmod rewrite
if [ ! -f /var/www/html/index.php ]; then
unzip /tmp/akaunting.zip -d /var/www/html
fi
rm -f /tmp/akaunting.zip
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-port=$DB_PORT \
--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 apache2-foreground
elif [ "$do_shell" ]; then
exec /bin/bash -li
fi

39
v-docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
version: '3.7'
services:
akaunting:
container_name: akaunting
build:
dockerfile: v.Dockerfile
context: .
ports:
- 8080:80
volumes:
- akaunting-data:/var/www/html
restart: unless-stopped
env_file:
- env/run.env
environment:
- AKAUNTING_SETUP
depends_on:
- akaunting-db
akaunting-db:
container_name: akaunting-db
image: mariadb
volumes:
- akaunting-db:/var/lib/mysql
restart: unless-stopped
env_file:
- env/db.env
akaunting-update:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --cleanup akaunting akaunting-db
volumes:
akaunting-data:
akaunting-db:

54
v.Dockerfile Normal file
View File

@ -0,0 +1,54 @@
FROM php:8.1-apache
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
RUN curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers'
COPY files/akaunting-v.sh /usr/local/bin/akaunting-v.sh
COPY files/html /var/www/html
ENTRYPOINT ["/usr/local/bin/akaunting-v.sh"]
CMD ["--start"]