Code Monkey home page Code Monkey logo

dockerfile-javaweb's Introduction

Dockerfile for Java Web

为Java Web应用开发者准备的快速部署Java Web应用的镜像

1. 特性:

  • 使用Apache作为前端代理,实现动静态资源的分离;
  • 默认使用JDK8,可以在构建镜像时指定JDK版本;
  • 使用Tomcat7,可以在构建镜像时指定Tomcat版本;
  • 内建了apr支持;
  • 使用Supervisor实现对镜像内多进程的管理;

2. 配置目录与文件说明

镜像内GitHub代码
Apache Proxy及虚拟主机配置目录/data/wwwconfconf/data/wwwconf
Apache DocumentRoot/data/wwwrootconf/wwwroot
Tomcat 目录/data/tomcatN/A
Tomcat 应用目录/data/tomcat/webapps可以在运行时通过 -v /home/xxx/webapps:/data/tomcat/webapps的方式映射到host上Java Web应用所在的目录
Tomcat 配置目录/data/tomcat/confconf/tomcat
Tomcat 日志目录/data/tomcat/logs可以在运行时通过 -v /home/xxx/logs/tomcat:/data/tomcat/logs 的方式映射到host上,方便查看日志
Supervisor 配置文件/etc/supervisord.confconf/supervisor/supervisord.conf
Supervisor Tomcat运行脚本路径/data/tomcat/bin/supervisord_tomcat.shconf/supervisor/supervisord_tomcat.sh

3. 环境变量说明

  • JAVA_VERSION:JDK的大版本号, BUILD_VERSION:JDK的小版本号, JAVA_VERSION与BUILD_VERSION一起组成了JDK的版本号,可以在构建镜像时指定,例如:
-e JAVA_VERSION=8u45 -e BUILD_VERSION=b14

必须保证:http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/jdk-$JAVA_VERSION-linux-x64.rpm 该文件是存在的,否则下载出错,构建出错。

  • TOMCAT_VERSION:Tomcat版本号,可以在构建镜像时指定,例如:
-e TOMCAT_VERSION=7.0.62

必须保证:http://mirrors.cnnic.cn/apache/tomcat/tomcat-7/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.zip 该文件是存在的,否则下载出错,构建出错。

4. 使用方法

  1. 克隆Docker及相关配置文件到本地
git clone https://github.com/docker-images/Dockerfile-javaweb.git
  1. 构建
cd Dockerfile-javaweb
./build.sh

或者

docker build -t guuuo/javaweb ./Dockerfile-javaweb
  1. 运行
cd Dockerfile-javaweb
./run.sh

或者

docker run -p 80:80 -p 9001:9001 -p 8080:8080 -t -i guuuo/javaweb

或者 指定静态资源与Java Web应用程序的路径

docker run -v /c/Users/xxx/javaproject/static:/data/wwwroot/static -v /c/Users/xxx/javaproject/webapps:/data/tomcat/webapps -p 80:80 -p 9001:9001 -p 8080:8080 -t -i guuuo/javaweb
  1. 浏览与高度

dockerfile-javaweb's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.