New Akaunting with Supervisor image

This commit is contained in:
Mohammed Al-Mahdawi 2021-06-18 18:29:24 +03:00
parent 07903994cf
commit b1371bf97f
7 changed files with 136 additions and 2 deletions

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
image: ['', fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer] image: ['', fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer, fpm-alpine-nginx-composer-supervisor]
include: include:
- image: '' - image: ''
file: Dockerfile file: Dockerfile
@ -25,6 +25,8 @@ jobs:
file: fpm-alpine-nginx.Dockerfile file: fpm-alpine-nginx.Dockerfile
- image: fpm-alpine-nginx-composer - image: fpm-alpine-nginx-composer
file: fpm-alpine-nginx-composer.Dockerfile file: fpm-alpine-nginx-composer.Dockerfile
- image: fpm-alpine-nginx-composer-supervisor
file: fpm-alpine-nginx-composer-supervisor.Dockerfile
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -86,7 +88,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.image-tags.outputs.tags }} tags: ${{ steps.image-tags.outputs.tags }}
- name: Build and push images - name: Build and push images
if: matrix.image == 'fpm-alpine-nginx-composer' if: matrix.image == 'fpm-alpine-nginx-composer' || matrix.image == 'fpm-alpine-nginx-composer-supervisor'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .

View File

@ -109,6 +109,9 @@ AKAUNTING_SETUP=true docker-compose -f fpm-alpine-nginx-docker-compose.yml up --
# Download Akaunting using git and install composer and npm and run Akaunting using FPM on Alpine and using Nginx as internal proxy # Download Akaunting using git and install composer and npm and run Akaunting using FPM on Alpine and using Nginx as internal proxy
AKAUNTING_SETUP=true docker-compose -f fpm-alpine-nginx-docker-compose.yml -f fpm-alpine-nginx-composer-docker-compose.yml up --build AKAUNTING_SETUP=true docker-compose -f fpm-alpine-nginx-docker-compose.yml -f fpm-alpine-nginx-composer-docker-compose.yml up --build
# Download Akaunting using git and install composer and npm and run Akaunting using FPM on Alpine and using Nginx as internal proxy and supervisor to manage the queues
AKAUNTING_SETUP=true docker-compose -f fpm-alpine-nginx-docker-compose.yml -f fpm-alpine-nginx-composer-supervisor-docker-compose.yml up --build
``` ```
## License ## License

View File

@ -0,0 +1,36 @@
#!/bin/bash -e
mkdir -p storage/framework/{sessions,views,cache}
mkdir -p storage/app/uploads
if [ "$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
exec "$@"

28
files/supervisord.conf Normal file
View File

@ -0,0 +1,28 @@
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
loglevel = INFO
[program:php-fpm]
command = /usr/local/sbin/php-fpm
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View File

@ -0,0 +1,7 @@
version: '3.7'
services:
akaunting:
build:
dockerfile: fpm-alpine-nginx-composer-supervisor.Dockerfile
context: .

View File

@ -0,0 +1,57 @@
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 \
gcc \
g++ \
make \
python2 \
supervisor \
vim \
bash \
nodejs \
npm \
git \
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 redis
# Configure Extension
RUN docker-php-ext-configure \
opcache --enable-opcache
# Installing composer
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm -rf composer-setup.php
# Clear npm proxy
RUN npm config rm proxy
RUN npm config rm https-proxy
# Download Akaunting application
RUN mkdir -p /var/www/html
RUN cd /var/www/html && git clone https://github.com/akaunting/akaunting.git . && composer install && npm install && npm run dev
COPY files/akaunting-php-fpm-nginx-supervisord.sh /usr/local/bin/akaunting-php-fpm-nginx-supervisord.sh
COPY files/html /var/www/html
# Setup Working Dir
WORKDIR /var/www/html
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/akaunting-php-fpm-nginx-supervisord.sh"]
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@ -10,6 +10,7 @@ services:
volumes: volumes:
- akaunting-data:/var/www/html - akaunting-data:/var/www/html
- ./files/php.ini:/usr/local/etc/php/php.ini - ./files/php.ini:/usr/local/etc/php/php.ini
- ./files/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
- ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./nginx/nginx.conf:/etc/nginx/nginx.conf
restart: unless-stopped restart: unless-stopped
ports: ports: