docker support added
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
FROM php:7.4.21-apache
|
||||
ENV APP_VERSION=1.0.0
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y less nano tini curl tar git zip unzip && \
|
||||
#echo "**** # To install networking tools for testing purpose ****" && \
|
||||
apt-get install -y iputils-ping dnsutils net-tools procps
|
||||
#echo "**** cleanup ****" && \
|
||||
#apt-get autoremove -y && \
|
||||
#apt-get clean -y
|
||||
|
||||
# curl -SL -o app.tar.gz "https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code/archive/${APP_VERSION}.tar.gz" \
|
||||
RUN curl -SL -o app.tar.gz "https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code/archive/refs/heads/master.tar.gz" \
|
||||
&& mkdir -p /app \
|
||||
&& tar xvf app.tar.gz -C /app --strip-components=1 \
|
||||
&& cp -r /app/qrcode/** /var/www/html \
|
||||
&& rm app.tar.gz
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y libzip-dev libjpeg62-turbo-dev libpng-dev libfreetype6-dev
|
||||
|
||||
# install composer
|
||||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||
RUN php composer-setup.php
|
||||
RUN rm composer-setup.php
|
||||
RUN mv composer.phar /usr/local/bin/composer
|
||||
|
||||
# Install extensions
|
||||
RUN docker-php-source extract
|
||||
RUN docker-php-ext-install pdo_mysql zip exif pcntl gd
|
||||
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
|
||||
RUN docker-php-ext-install gettext && docker-php-ext-enable gettext
|
||||
RUN docker-php-ext-install sockets && docker-php-ext-enable sockets
|
||||
|
||||
RUN mv "/usr/local/etc/php/php.ini-production" "/usr/local/etc/php/php.ini"
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY ./config/docker-entrypoint.sh /bin/docker-entrypoint.sh
|
||||
RUN chmod +x /bin/docker-entrypoint.sh
|
||||
COPY ./config/vhost.conf /etc/apache2/sites-available/000-default.conf
|
||||
RUN a2enmod rewrite
|
||||
|
||||
ENV APP_USER appuser
|
||||
ARG PUID=1000
|
||||
ARG PGID=1000
|
||||
RUN groupadd -g ${PGID} $APP_USER \
|
||||
&& useradd -M -u ${PUID} -g ${PGID} $APP_USER \
|
||||
&& chown -R $APP_USER:$APP_USER /var/run/apache2 \
|
||||
&& chown -R $APP_USER:$APP_USER /var/log \
|
||||
&& chown -R $APP_USER:$APP_USER /etc/apache2 \
|
||||
&& chown -R $APP_USER:$APP_USER /var/lib/apache2 \
|
||||
&& chown -R $APP_USER:$APP_USER /var/www
|
||||
USER $APP_USER
|
||||
CMD apache2ctl -D FOREGROUND
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# needs to fix install process to create database and then below line can be commented out
|
||||
#ENTRYPOINT ["/bin/docker-entrypoint.sh"]
|
||||
@@ -0,0 +1,27 @@
|
||||
### How to run this image
|
||||
- currently this image must be build locally.(in future can be pulled from docker hub)
|
||||
- create folder to mount inside docker container
|
||||
- `mkdir -p ./data/mariadb ./data/app/config ./data/app/saved_qrcode`
|
||||
- Run and build this image as host machine user
|
||||
- `PUID="$(id -u)" PGID="$(id -g)" docker-compose up --build -d`
|
||||
- Run and build this image as specific user
|
||||
- `PUID="1000" PGID="1000" docker-compose up --build -d`
|
||||
- Run app installation <IP>:8080/install
|
||||
- Provide Database credentials
|
||||
- Default login: <IP>:8080
|
||||
- user: superadmin
|
||||
- password: superadmin
|
||||
|
||||
### Roadmap
|
||||
- Make install process run via docker-compose.
|
||||
- Work is partially done. docker-entrypoint.sh is created.(currently disabled due to next steps are pending)
|
||||
- qrcode/install/database.php should be adjusted to create database without form submission.
|
||||
- Make it possible to set PUID and GUID, from environment variable in docker-compose.yml .
|
||||
- Reduce image size by removing unnecessary dependencies.
|
||||
- Automate Build image and push to docker hub.
|
||||
- Audit security flaws and fix it if needed.
|
||||
|
||||
### some debug commands
|
||||
- `docker-compose logs`
|
||||
- `PUID="$(id -u)" PGID="$(id -g)" docker-compose config`
|
||||
- `ps -aef | grep apache2`
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset
|
||||
|
||||
APP_PATH=/var/www/html
|
||||
|
||||
echo "##### coping config file #####"
|
||||
cp $APP_PATH/install/config/database.php $APP_PATH/config/config.php
|
||||
|
||||
echo "##### setting database hostname #####"
|
||||
sed -i "s/%HOSTNAME%/$DATABASE_HOST/" $APP_PATH/config/config.php
|
||||
|
||||
echo "##### setting database username #####"
|
||||
sed -i "s/%USERNAME%/$DATABASE_USER/" $APP_PATH/config/config.php
|
||||
|
||||
echo "##### setting database password #####"
|
||||
sed -i "s/%PASSWORD%/$DATABASE_PASSWORD/" $APP_PATH/config/config.php
|
||||
|
||||
echo "##### setting database name #####"
|
||||
sed -i "s/%DATABASE%/$DATABASE_NAME/" $APP_PATH/config/config.php
|
||||
|
||||
echo "#### Deleting install folder #####"
|
||||
rm -r $APP_PATH/install
|
||||
|
||||
exec apache2-foreground
|
||||
@@ -0,0 +1 @@
|
||||
<?php phpinfo( ); ?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/html/
|
||||
<Directory “/var/www/html/”>
|
||||
AllowOverride all
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
|
||||
</VirtualHost>
|
||||
@@ -0,0 +1,49 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
qrcode:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
PUID: ${PUID}
|
||||
PGID: ${PGID}
|
||||
image: qrcode:1.0
|
||||
container_name: qrcode
|
||||
restart: "unless-stopped"
|
||||
networks:
|
||||
- qrcode_network
|
||||
ports:
|
||||
- "8080:80"
|
||||
user: "${PUID}:${PGID}"
|
||||
#environment:
|
||||
#ADMIN_USER: "superadmin" # not supported yet please see road map
|
||||
#ADMIN_PASSWORD: "superadmin" # not supported yet please see road map
|
||||
#DATABASE_HOST: "mariadb" # not supported yet please see road map
|
||||
#DATABASE_NAME: "qrcode" # not supported yet please see road map
|
||||
#DATABASE_USER: "qrcode" # not supported yet please see road map
|
||||
#DATABASE_PASSWORD: "changeme" # not supported yet please see road map
|
||||
volumes:
|
||||
- ./data/app/config:/var/www/html/config
|
||||
- ./data/app/saved_qrcode:/var/www/html/saved_qrcode
|
||||
|
||||
mariadb:
|
||||
image: mariadb:10.5
|
||||
container_name: mariadb
|
||||
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
|
||||
restart: "unless-stopped"
|
||||
environment:
|
||||
MARIADB_ROOT_PASSWORD: "changeme"
|
||||
MARIADB_DATABASE: "qrcode"
|
||||
MARIADB_USER: "qrcode"
|
||||
MARIADB_PASSWORD: "changeme"
|
||||
networks:
|
||||
- qrcode_network
|
||||
volumes:
|
||||
- ./data/mariadb:/var/lib/mysql
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
||||
networks:
|
||||
qrcode_network:
|
||||
driver: bridge
|
||||
name: qrcode
|
||||
Reference in New Issue
Block a user