diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..07aa6ddec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM jbfink/docker-lampstack +MAINTAINER jekkos +# Install dependencies +RUN apt-get install -y --no-install-recommends software-properties-common +RUN apt-get install -y python git +RUN apt-get update +# RUN add-apt-repository ppa:chris-lea/node.js + +# Get latest Ospos source from Git +RUN git clone https://github.com/jekkos/opensourcepos.git /app +# RUN cd app && npm install + +RUN ln -fs /app/* /var/www +ADD ./start_container.sh /start_container.sh +RUN chmod 755 /start_container.sh +EXPOSE 80 3306 +CMD ["/bin/bash", "/start_container.sh"] diff --git a/start_container.sh b/start_container.sh new file mode 100644 index 000000000..342a27d08 --- /dev/null +++ b/start_container.sh @@ -0,0 +1,16 @@ +#!/bin/bash +if [ ! -f /mysql-configured ]; then + /usr/bin/mysqld_safe & + sleep 10s + MYSQL_PASSWORD=`pwgen -c -n -1 12` + echo mysql root password: $MYSQL_PASSWORD + echo $MYSQL_PASSWORD > /mysql-root-pw.txt + mysqladmin -u root password $MYSQL_PASSWORD + cp /app/application/config/database.php.tmpl /app/application/config/database.php + sed -i "s/\(password...=.\).*/\1'${MYSQL_PASSWORD}';/g" /app/application/config/database.php + mysql -e "CREATE DATABASE IF NOT EXISTS ospos; use ospos; source /app/database/tables.sql; source /app/database/constraints.sql;" -uroot -p${MYSQL_PASSWORD} + touch /mysql-configured + killall mysqld + sleep 10s +fi +supervisord -n