Basic docker
This commit is contained in:
parent
ec252a670e
commit
6d4030fa8c
24
.docker/init.sh
Normal file
24
.docker/init.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
DB_ROOT_PASS=$1
|
||||
DB_USER_PASS=$2
|
||||
|
||||
mkdir -p /run/mysqld
|
||||
mkdir -p /run/nginx
|
||||
chown mysql:mysql /run/mysqld
|
||||
chown nginx:nginx /run/nginx
|
||||
|
||||
mysql_install_db --user=mysql
|
||||
mysqld_safe &
|
||||
mysqladmin --silent --wait=30 ping
|
||||
mysqladmin -u root password "${DB_ROOT_PASS}"
|
||||
mysql -u root -p${DB_ROOT_PASS} < /var/www/html/scripts/ulogger.sql
|
||||
mysql -u root -p${DB_ROOT_PASS} -e "CREATE USER 'ulogger'@'localhost' IDENTIFIED BY '${DB_USER_PASS}'"
|
||||
mysql -u root -p${DB_ROOT_PASS} -e "GRANT ALL PRIVILEGES ON ulogger.* TO 'ulogger'@'localhost'"
|
||||
mysql -u root -p${DB_ROOT_PASS} -e "INSERT INTO users (login, password) VALUES ('admin', '\$2y\$10\$7OvZrKgonVZM9lkzrTbiou.CVhO3HjPk5y0W9L68fVwPs/osBRIMq')" ulogger
|
||||
mysqladmin -u root -p${DB_ROOT_PASS} shutdown
|
||||
|
||||
sed -i "s/^\$dbhost = .*$/\$dbhost = \"localhost\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$dbname = .*$/\$dbname = \"ulogger\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$dbuser = .*$/\$dbuser = \"ulogger\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$dbpass = .*$/\$dbpass = \"${DB_USER_PASS}\";/" /var/www/html/config.php
|
18
.docker/nginx.conf
Normal file
18
.docker/nginx.conf
Normal file
@ -0,0 +1,18 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
root /var/www/html;
|
||||
index index.php;
|
||||
client_body_buffer_size 1M;
|
||||
client_max_body_size 10M;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
location ~ .php$ {
|
||||
include fastcgi_params;
|
||||
include fastcgi.conf;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
}
|
||||
}
|
21
.docker/run.sh
Normal file
21
.docker/run.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
# set config variables
|
||||
sed -i "s/^\$admin_user = .*$/\$admin_user = \"${ULOGGER_ADMIN_USER}\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$pass_strength = .*$/\$pass_strength = ${ULOGGER_PASS_STRENGTH};/" /var/www/html/config.php
|
||||
sed -i "s/^\$pass_lenmin = .*$/\$pass_lenmin = ${ULOGGER_PASS_LENMIN};/" /var/www/html/config.php
|
||||
sed -i "s/^\$require_authentication = .*$/\$require_authentication = ${ULOGGER_REQUIRE_AUTHENTICATION};/" /var/www/html/config.php
|
||||
sed -i "s/^\$public_tracks = .*$/\$public_tracks = ${ULOGGER_PUBLIC_TRACKS};/" /var/www/html/config.php
|
||||
sed -i "s/^\$gkey = .*$/\$gkey = \"${ULOGGER_GKEY}\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$lang = .*$/\$lang = \"${ULOGGER_LANG}\";/" /var/www/html/config.php
|
||||
sed -i "s/^\$units = .*$/\$units = \"${ULOGGER_UNITS}\";/" /var/www/html/config.php
|
||||
|
||||
# show config variables
|
||||
echo "ulogger configuration"
|
||||
echo "---------------------"
|
||||
grep '^\$' /var/www/html/config.php
|
||||
|
||||
# start services
|
||||
mysqld_safe &
|
||||
nginx
|
||||
php-fpm7 -F
|
43
Dockerfile
Normal file
43
Dockerfile
Normal file
@ -0,0 +1,43 @@
|
||||
FROM alpine:3.6
|
||||
|
||||
MAINTAINER Bartek Fabiszewski (https://github.com/bfabiszewski)
|
||||
|
||||
ARG DB_ROOT_PASS=secret1
|
||||
ARG DB_USER_PASS=secret2
|
||||
ARG ULOGGER_TAG
|
||||
|
||||
ENV ULOGGER_ADMIN_USER admin
|
||||
ENV ULOGGER_PASS_STRENGTH 0
|
||||
ENV ULOGGER_PASS_LENMIN 5
|
||||
ENV ULOGGER_REQUIRE_AUTHENTICATION 1
|
||||
ENV ULOGGER_PUBLIC_TRACKS 0
|
||||
ENV ULOGGER_GKEY ""
|
||||
ENV ULOGGER_LANG en
|
||||
ENV ULOGGER_UNITS metric
|
||||
|
||||
RUN apk add --no-cache mariadb mariadb-client nginx php7-ctype php7-fpm php7-json php7-mysqli php7-session php7-simplexml php7-xmlwriter
|
||||
|
||||
COPY .docker/run.sh /run.sh
|
||||
RUN chmod +x /run.sh
|
||||
COPY .docker/init.sh /init.sh
|
||||
RUN chmod +x /init.sh
|
||||
COPY .docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
RUN chown nginx.nginx /etc/nginx/conf.d/default.conf
|
||||
|
||||
RUN rm -rf /var/www/html
|
||||
RUN mkdir -p /var/www/html
|
||||
COPY . /var/www/html
|
||||
RUN grep '^[$<?]' /var/www/html/config.default.php > /var/www/html/config.php
|
||||
|
||||
RUN /init.sh "${DB_ROOT_PASS}" "${DB_USER_PASS}"
|
||||
|
||||
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
|
||||
ln -sf /dev/stderr /var/log/nginx/error.log && \
|
||||
ln -sf /dev/stdout /var/log/php7/error.log && \
|
||||
ln -sf /dev/stderr /var/log/php7/error.log
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
VOLUME ["/var/lib/mysql"]
|
||||
|
||||
CMD ["/run.sh"]
|
Loading…
x
Reference in New Issue
Block a user