Last active
August 29, 2015 14:18
-
-
Save sunix/f676b8de2b819056e398 to your computer and use it in GitHub Desktop.
Devoxx fr 2015 - Spring Petclinic Dockerfile - Tomcat 8 MySQL - Codenvy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM codenvy/jdk7 | |
# Install Tomcat8 | |
RUN mkdir /home/user/tomcat8 && \ | |
wget -qO- "http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.tar.gz" | tar -zx --strip-components=1 -C /home/user/tomcat8 && \ | |
rm -rf /home/user/tomcat8/webapps/* | |
EXPOSE 8080 | |
ENV CODENVY_APP_PORT_8080_HTTP 8080 | |
WORKDIR /home/user/tomcat8/bin | |
# Install MySQL | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN sudo apt-get update && \ | |
sudo apt-get install pwgen && \ | |
sudo -E bash -c "apt-get -y install mysql-server-5.5" && \ | |
sudo sed -i.bak 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf && \ | |
sudo service mysql restart && \ | |
sudo mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;" | |
EXPOSE 3306 | |
# Configure MySQL | |
RUN sudo service mysql restart && \ | |
CODENVY_MYSQL_PASSWORD=password && \ | |
CODENVY_MYSQL_DB=petclinic && \ | |
CODENVY_MYSQL_USER=petclinic && \ | |
echo "MySQL password: $CODENVY_MYSQL_PASSWORD" >> /home/user/.mysqlrc && \ | |
echo "MySQL user : $CODENVY_MYSQL_USER" >> /home/user/.mysqlrc && \ | |
echo "MySQL Database:$CODENVY_MYSQL_DB" >> /home/user/.mysqlrc && \ | |
sudo mysql -uroot -e "CREATE USER '$CODENVY_MYSQL_USER'@'%' IDENTIFIED BY '"$CODENVY_MYSQL_PASSWORD"'" && \ | |
sudo mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '$CODENVY_MYSQL_USER'@'%' IDENTIFIED BY '"$CODENVY_MYSQL_PASSWORD"'; FLUSH PRIVILEGES;" && \ | |
sudo mysql -uroot -e "CREATE DATABASE $CODENVY_MYSQL_DB;" | |
RUN mkdir /home/user/app_src | |
ADD $app_src$ /home/user/app_src/ | |
RUN sudo service mysql restart && \ | |
sudo mysql -uroot < /home/user/app_src/src/main/resources/db/mysql/initDB.sql | |
# Start MySQL and Tomcat8 | |
$debug?EXPOSE 8000:$ | |
$debug?ENV CODENVY_APP_PORT_8000_DEBUG 8000:$ | |
$debug?CMD sudo service mysql start > /dev/null; ./catalina.sh jpda run 2>&1:$ | |
CMD cat /home/user/.mysqlrc; \ | |
echo Database host:port is $CODENVY_HOSTNAME:$CODENVY_PORT_3306; \ | |
sudo service mysql start 2>&1; \ | |
./catalina.sh run 2>&1 | |
# Mount WAR | |
ENV CODENVY_APP_BIND_DIR /home/user/tomcat8/webapps/ROOT | |
VOLUME ["/home/user/tomcat8/webapps/ROOT"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment