mirror of
https://gitee.com/kennylee/docker.git
synced 2024-11-29 18:38:34 +08:00
添加更多docker花容器
This commit is contained in:
parent
7c871e2041
commit
878ebb068f
15
gitlab-ci/README.md
Normal file
15
gitlab-ci/README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# gitlab
|
||||||
|
|
||||||
|
注意宿主机器映射地址和访问权限!
|
||||||
|
|
||||||
|
指定docker-compose.yml可参考命令
|
||||||
|
|
||||||
|
```
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
配置runner,第一次启动后,输入下面命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker exec -it gitlab-runner gitlab-runner register
|
||||||
|
```
|
32
gitlab-ci/docker-compose.yml
Normal file
32
gitlab-ci/docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: gitlab/gitlab-ce:latest
|
||||||
|
container_name: gitlab
|
||||||
|
ports:
|
||||||
|
- "10080:80"
|
||||||
|
- "10022:22"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./data/gitlab/data:/var/opt/gitlab:z
|
||||||
|
- ./data/gitlab/logs:/var/log/gitlab:z
|
||||||
|
- ./data/gitlab/config:/etc/gitlab:z
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
networks:
|
||||||
|
- new
|
||||||
|
# runner:
|
||||||
|
image: gitlab/gitlab-runner:latest
|
||||||
|
container_name: gitlab-runner
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./data/gitlab-runner/config:/etc/gitlab-runner:Z
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
networks:
|
||||||
|
new:
|
||||||
|
aliases:
|
||||||
|
- gitlab-runner
|
||||||
|
networks:
|
||||||
|
new:
|
15
gitlab-runner/docker-runner-gitlab/Dockerfile
Executable file
15
gitlab-runner/docker-runner-gitlab/Dockerfile
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
FROM sameersbn/gitlab-ci-runner:latest
|
||||||
|
MAINTAINER sameer@damagehead.com
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y build-essential cmake openssh-server \
|
||||||
|
ruby2.1-dev libmysqlclient-dev zlib1g-dev libyaml-dev libssl-dev \
|
||||||
|
libgdbm-dev libreadline-dev libncurses5-dev libffi-dev \
|
||||||
|
libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev \
|
||||||
|
mysql-server mysql-client redis-server fontconfig && \
|
||||||
|
gem install --no-document bundler && \
|
||||||
|
rm -rf /var/lib/apt/lists/* # 20150613
|
||||||
|
|
||||||
|
ADD assets/ /app/
|
||||||
|
RUN chmod 755 /app/setup/install
|
||||||
|
RUN /app/setup/install
|
21
gitlab-runner/docker-runner-gitlab/LICENSE
Executable file
21
gitlab-runner/docker-runner-gitlab/LICENSE
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Sameer Naik
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
4
gitlab-runner/docker-runner-gitlab/Makefile
Executable file
4
gitlab-runner/docker-runner-gitlab/Makefile
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
all: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
@docker build --tag=${USER}/runner-gitlab .
|
134
gitlab-runner/docker-runner-gitlab/README.md
Executable file
134
gitlab-runner/docker-runner-gitlab/README.md
Executable file
@ -0,0 +1,134 @@
|
|||||||
|
> **NOTICE**:
|
||||||
|
>
|
||||||
|
> End-Of-Life.
|
||||||
|
|
||||||
|
# Table of Contents
|
||||||
|
- [Introduction](#introduction)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Quick Start](#quick-start)
|
||||||
|
- [Data Store](#data-store)
|
||||||
|
- [Shell Access](#shell-access)
|
||||||
|
- [Upgrading](#upgrading)
|
||||||
|
|
||||||
|
# Introduction
|
||||||
|
|
||||||
|
A CI runner for gitlab-ce.
|
||||||
|
|
||||||
|
Built on top of the [sameersbn/gitlab-ci-runner](https://github.com/sameersbn/docker-gitlab-ci-runner) base image, this repo demonstrates the use of sameersbn/gitlab-ci-runner to build a runner for your project.
|
||||||
|
|
||||||
|
Since we inherit the [sameersbn/gitlab-ci-runner](https://github.com/sameersbn/docker-gitlab-ci-runner) base image, we also inherit its runtime. This means we only have to setup the image to satisfy your projects build requirements which in this case is gitlab-ce.
|
||||||
|
|
||||||
|
All package installations are performed in the [Dockerfile](https://github.com/sameersbn/docker-runner-gitlab/blob/master/Dockerfile) while the system configuration, such as mysql and redis setup, are performed in the [install](https://github.com/sameersbn/docker-runner-gitlab/blob/master/assets/setup/install) script.
|
||||||
|
|
||||||
|
Rest of this document describes use of the runner to perform continuous integration of gitlab-ce.
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
If you find this image useful here's how you can help:
|
||||||
|
|
||||||
|
- Send a Pull Request with your awesome new features and bug fixes
|
||||||
|
- Help new users with [Issues](https://github.com/sameersbn/docker-runner-gitlab/issues) they may encounter
|
||||||
|
- Support the development of this image with a [donation](http://www.damagehead.com/donate/)
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Pull the latest version of the image from the docker index.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull sameersbn/runner-gitlab:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternately you can build the image yourself.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/sameersbn/docker-runner-gitlab.git
|
||||||
|
cd docker-runner-gitlab
|
||||||
|
docker build --tag="$USER/runner-gitlab" .
|
||||||
|
```
|
||||||
|
|
||||||
|
# Quick Start
|
||||||
|
For a runner to do its trick, it has to first be registered/authorized on the GitLab CI server. This can be done by running the image with the **app:setup** command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p /opt/runner-gitlab
|
||||||
|
docker run --name runner-gitlab -i -t --rm \
|
||||||
|
-v /opt/runner-gitlab:/home/gitlab_ci_runner/data \
|
||||||
|
sameersbn/runner-gitlab:latest app:setup
|
||||||
|
```
|
||||||
|
|
||||||
|
The command will prompt you to specify the location of the GitLab CI server and provide the registration token to access the server. With this out of the way the image is ready, lets get is started.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --name runner-gitlab -d \
|
||||||
|
-v /opt/runner-gitlab:/home/gitlab_ci_runner/data \
|
||||||
|
sameersbn/runner-gitlab:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
You now have the runner to perform continous integration of GitLab CE.
|
||||||
|
|
||||||
|
Login to your GitLab CI server and add a CI build for gitlab-ce with the following build settings
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ruby -v
|
||||||
|
cp config/database.yml.mysql config/database.yml
|
||||||
|
cp config/gitlab.yml.example config/gitlab.yml
|
||||||
|
sed "s/username\:.*$/username\: runner/" -i config/database.yml
|
||||||
|
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
|
||||||
|
sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
|
||||||
|
touch log/application.log
|
||||||
|
touch log/test.log
|
||||||
|
bundle --without postgres
|
||||||
|
bundle exec rake db:create RAILS_ENV=test
|
||||||
|
bundle exec rake gitlab:test RAILS_ENV=test
|
||||||
|
```
|
||||||
|
|
||||||
|
# Data Store
|
||||||
|
GitLab CI Runner saves the configuration for connection and access to the GitLab CI server. In addition, SSH keys are generated as well. To make sure this configuration is not lost when when the container is stopped/deleted, we should mount a data store volume at
|
||||||
|
|
||||||
|
* /home/gitlab_ci_runner/data
|
||||||
|
|
||||||
|
Volumes can be mounted in docker by specifying the **'-v'** option in the docker run command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir /opt/runner-gitlab
|
||||||
|
docker run --name runner-gitlab -d -h runner-gitlab.local.host \
|
||||||
|
-v /opt/runner-gitlab:/home/gitlab_ci_runner/data \
|
||||||
|
sameersbn/runner-gitlab:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
# Shell Access
|
||||||
|
|
||||||
|
For debugging and maintenance purposes you may want access the containers shell. If you are using docker version `1.3.0` or higher you can access a running containers shell using `docker exec` command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it runner-gitlab bash
|
||||||
|
```
|
||||||
|
|
||||||
|
If you are using an older version of docker, you can use the [nsenter](http://man7.org/linux/man-pages/man1/nsenter.1.html) linux tool (part of the util-linux package) to access the container shell.
|
||||||
|
|
||||||
|
Some linux distros (e.g. ubuntu) use older versions of the util-linux which do not include the `nsenter` tool. To get around this @jpetazzo has created a nice docker image that allows you to install the `nsenter` utility and a helper script named `docker-enter` on these distros.
|
||||||
|
|
||||||
|
To install `nsenter` execute the following command on your host,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can access the container shell using the command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo docker-enter runner-gitlab
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information refer https://github.com/jpetazzo/nsenter
|
||||||
|
|
||||||
|
## Upgrading
|
||||||
|
|
||||||
|
To update the runner, simply stop the image and pull the latest version from the docker index.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker stop runner-gitlab
|
||||||
|
docker pull sameersbn/runner-gitlab:latest
|
||||||
|
docker run --name runner-gitlab -d [OPTIONS] sameersbn/runner-gitlab:latest
|
||||||
|
```
|
79
gitlab-runner/docker-runner-gitlab/assets/setup/install
Executable file
79
gitlab-runner/docker-runner-gitlab/assets/setup/install
Executable file
@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
adduser --disabled-login --gecos 'GitLab' git
|
||||||
|
|
||||||
|
# disable pam authentication for sshd
|
||||||
|
sed 's/UsePAM yes/UsePAM no/' -i /etc/ssh/sshd_config
|
||||||
|
sed 's/UsePrivilegeSeparation yes/UsePrivilegeSeparation no/' -i /etc/ssh/sshd_config
|
||||||
|
echo "UseDNS no" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# configure supervisor to start sshd
|
||||||
|
mkdir -p /var/run/sshd
|
||||||
|
cat > /etc/supervisor/conf.d/sshd.conf <<EOF
|
||||||
|
[program:sshd]
|
||||||
|
directory=/
|
||||||
|
command=/usr/sbin/sshd -D
|
||||||
|
user=root
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
stderr_logfile=/var/log/supervisor/%(program_name)s_error.log
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > /etc/supervisor/conf.d/mysqld.conf <<EOF
|
||||||
|
[program:mysqld]
|
||||||
|
priority=20
|
||||||
|
directory=/tmp
|
||||||
|
command=/usr/bin/mysqld_safe
|
||||||
|
user=root
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sed 's/daemonize yes/daemonize no/' -i /etc/redis/redis.conf
|
||||||
|
cat > /etc/supervisor/conf.d/redis-server.conf <<EOF
|
||||||
|
[program:redis-server]
|
||||||
|
priority=20
|
||||||
|
directory=/tmp
|
||||||
|
command=/usr/bin/redis-server /etc/redis/redis.conf
|
||||||
|
user=redis
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# start supervisor
|
||||||
|
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
|
# wait for mysql server to start (max 30 seconds)
|
||||||
|
timeout=30
|
||||||
|
while ! /usr/bin/mysqladmin -u root status >/dev/null 2>&1
|
||||||
|
do
|
||||||
|
timeout=$(($timeout - 1))
|
||||||
|
if [ $timeout -eq 0 ]; then
|
||||||
|
echo "Could not connect to mysql server. Aborting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting for database server to accept connections..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# create user for the runner
|
||||||
|
mysql -uroot -e "CREATE USER 'runner'@'localhost' IDENTIFIED BY 'password';"
|
||||||
|
mysql -uroot -e "GRANT ALL PRIVILEGES ON * . * TO 'runner'@'localhost';"
|
||||||
|
mysql -uroot -e "FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
# install phantomjs at /app prefix
|
||||||
|
mkdir -p /app/phantomjs
|
||||||
|
PHANTOMJS_VERSION=1.8.1
|
||||||
|
if [ -f /app/setup/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 ]; then
|
||||||
|
tar -jvxf /app/setup/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 --strip=1 -C /app/phantomjs/
|
||||||
|
else
|
||||||
|
wget "http://phantomjs.googlecode.com/files/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" -O - | tar -jvxf - --strip=1 -C /app/phantomjs/
|
||||||
|
fi
|
||||||
|
ln -s /app/phantomjs/bin/phantomjs /usr/bin/phantomjs
|
||||||
|
phantomjs --version
|
@ -1,16 +1,16 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: gitlab/gitlab-ce:latest
|
#image: gitlab/gitlab-ce:latest
|
||||||
container_name: gitlab
|
image: index.alauda.cn/kenny/gitlab-ce:8.13.6-ce.0
|
||||||
ports:
|
container_name: gitlab
|
||||||
- "10080:80"
|
ports:
|
||||||
- "10022:22"
|
- "10080:80"
|
||||||
restart: always
|
- "10022:22"
|
||||||
volumes:
|
restart: always
|
||||||
- ./data/gitlab/data:/var/opt/gitlab:z
|
volumes:
|
||||||
- ./data/gitlab/logs:/var/log/gitlab:z
|
- ./data/gitlab/data:/var/opt/gitlab:z
|
||||||
- ./data/gitlab/config:/etc/gitlab:z
|
- ./data/gitlab/logs:/var/log/gitlab:z
|
||||||
environment:
|
- ./data/gitlab/config:/etc/gitlab:z
|
||||||
- TZ=Asia/Shanghai
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
FROM registry.alauda.cn/kenny/docker-ruby:2.3.3
|
|
||||||
RUN apt-get -y update && apt-get -y install libicu-dev
|
|
||||||
RUN gem install gollum
|
|
||||||
RUN gem install github-markdown org-ruby
|
|
||||||
VOLUME /wiki
|
|
||||||
WORKDIR /wiki
|
|
||||||
CMD ["gollum", "--port", "80"]
|
|
||||||
EXPOSE 80
|
|
24
gollum/Dockerfile
Normal file
24
gollum/Dockerfile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Gollum
|
||||||
|
FROM registry.alauda.cn/kenny/docker-ruby:2.3.3
|
||||||
|
|
||||||
|
# FIX APT Resource
|
||||||
|
ADD ./sources.list.jessie /etc/apt/sources.list
|
||||||
|
|
||||||
|
#FIX Ruby RESOURCE
|
||||||
|
RUN bundle config mirror.https://rubygems.org https://ruby.taobao.org
|
||||||
|
RUN gem sources --remove https://rubygems.org/
|
||||||
|
RUN gem sources -a https://ruby.taobao.org/
|
||||||
|
|
||||||
|
# recommend lib
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
curl git unzip vim wget
|
||||||
|
RUN apt-get -y install libicu-dev
|
||||||
|
RUN apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN gem install gollum
|
||||||
|
RUN gem install github-markdown org-ruby
|
||||||
|
VOLUME /wiki
|
||||||
|
WORKDIR /wiki
|
||||||
|
CMD ["gollum", "--port", "80"]
|
||||||
|
EXPOSE 80
|
16
gollum/README.md
Normal file
16
gollum/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Gollum
|
||||||
|
|
||||||
|
由于一些极端情况,不能联网,所以默认情况是使用本地的 `image` ,如果非这样的情况,docker-compose文件可改为 `build .`
|
||||||
|
|
||||||
|
### 基础镜像构建命令
|
||||||
|
|
||||||
|
```
|
||||||
|
docker build -t kennylee26/gollum .
|
||||||
|
```
|
||||||
|
|
||||||
|
编译时注意启用IPv4 如 `sudo sysctl -w net.ipv4.ip_forward=1`
|
||||||
|
|
||||||
|
### 注意事项
|
||||||
|
|
||||||
|
* data目录注意权限,还有需要有 `git init` 因为 `Gollum` 会读取里面的md文件作为
|
||||||
|
|
14
gollum/docker-compose.yml
Normal file
14
gollum/docker-compose.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: kennylee26/gollum
|
||||||
|
container_name: gollum
|
||||||
|
ports:
|
||||||
|
- "4567:80"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./data:/wiki:z
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
|
8
gollum/sources.list.jessie
Normal file
8
gollum/sources.list.jessie
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
deb http://mirrors.163.com/debian/ jessie main non-free contrib
|
||||||
|
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
|
||||||
|
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
|
||||||
|
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
|
||||||
|
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
|
@ -1,10 +1,10 @@
|
|||||||
# Ruby
|
# Ruby
|
||||||
#
|
#
|
||||||
# https://github.com/docker-library/ruby
|
# https://github.com/docker-library/ruby
|
||||||
# NAME: kennylee26/ruby:2.2
|
# NAME: kennylee26/ruby:2.3.3
|
||||||
|
|
||||||
# Pull base image.
|
# Pull base image.
|
||||||
FROM ruby:2.2
|
FROM registry.alauda.cn/kenny/docker-ruby:2.3.3
|
||||||
|
|
||||||
# FIX APT Resource
|
# FIX APT Resource
|
||||||
RUN curl http://mirrors.163.com/.help/sources.list.jessie>/etc/apt/sources.list
|
RUN curl http://mirrors.163.com/.help/sources.list.jessie>/etc/apt/sources.list
|
||||||
|
@ -1 +0,0 @@
|
|||||||
docker build -t kennylee26/tomcat .
|
|
53
tomcat/tomcat8_jdk7/Dockerfile
Executable file
53
tomcat/tomcat8_jdk7/Dockerfile
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
# Tomcat
|
||||||
|
#
|
||||||
|
# VERSION 0.0.1
|
||||||
|
# Authoer: kennylee26
|
||||||
|
# NAME: kennylee26/tomcat:tomcat8-jdk7
|
||||||
|
# Command format: Instruction [arguments command] ..
|
||||||
|
|
||||||
|
# 第一行必须指定基于的基础镜像
|
||||||
|
FROM kennylee26/java7
|
||||||
|
|
||||||
|
# 维护者信息
|
||||||
|
MAINTAINER kennylee26 <kennylee26@gmail.com>
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -yq --no-install-recommends wget pwgen ca-certificates && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV TOMCAT_MAJOR_VERSION 8
|
||||||
|
ENV TOMCAT_MINOR_VERSION 8.0.39
|
||||||
|
ENV CATALINA_HOME /opt/tomcat
|
||||||
|
|
||||||
|
# INSTALL TOMCAT
|
||||||
|
RUN wget https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz && \
|
||||||
|
wget -O- https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz.md5 | md5sum -c - && \
|
||||||
|
tar zxf apache-tomcat-*.tar.gz && \
|
||||||
|
rm apache-tomcat-*.tar.gz && \
|
||||||
|
mv apache-tomcat* ${CATALINA_HOME}
|
||||||
|
|
||||||
|
# set config
|
||||||
|
COPY server.xml /tmp/
|
||||||
|
RUN cp -f /tmp/server.xml ${CATALINA_HOME}/conf/
|
||||||
|
# Add admin/admin user
|
||||||
|
# COPY tomcat-users.xml /opt/tomcat/conf/
|
||||||
|
|
||||||
|
# Add service
|
||||||
|
COPY tomcat /etc/init.d/
|
||||||
|
RUN chmod +x /etc/init.d/tomcat
|
||||||
|
|
||||||
|
# Remove garbage
|
||||||
|
RUN rm -rf ${CATALINA_HOME}/webapps/examples && \
|
||||||
|
rm -rf ${CATALINA_HOME}/webapps/docs && \
|
||||||
|
rm -rf ${CATALINA_HOME}/webapps/ROOT
|
||||||
|
|
||||||
|
WORKDIR ${CATALINA_HOME}
|
||||||
|
|
||||||
|
#ADD create_tomcat_admin_user.sh /create_tomcat_admin_user.sh
|
||||||
|
ADD run.sh /run.sh
|
||||||
|
RUN chmod +x /*.sh
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD ["/run.sh"]
|
4
tomcat/tomcat8_jdk7/run.sh
Normal file
4
tomcat/tomcat8_jdk7/run.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec ${CATALINA_HOME}/bin/catalina.sh run
|
||||||
|
|
71
tomcat/tomcat8_jdk7/tomcat
Executable file
71
tomcat/tomcat8_jdk7/tomcat
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Tomcat auto-start @/etc/init.d/tomcat
|
||||||
|
#
|
||||||
|
# description: Auto-starts tomcat
|
||||||
|
# processname: tomcat
|
||||||
|
# pidfile: /var/run/tomcat.pid
|
||||||
|
|
||||||
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||||
|
NAME=tomcat
|
||||||
|
DESC="Tomcat servlet engine"
|
||||||
|
|
||||||
|
# 由于/etc/init.d/ 中的脚本无法获取到bash设置好的环境变量。最简单解决方法是写死在这。
|
||||||
|
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
|
||||||
|
export CATALINA_HOME="/opt/tomcat"
|
||||||
|
export JAVA_OPTS="-server -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=192M"
|
||||||
|
|
||||||
|
if [ ! -f $CATALINA_HOME/bin/catalina.sh ]; then
|
||||||
|
echo "$NAME not valilable..."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
tomcat_process_count(){
|
||||||
|
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt
|
||||||
|
read line < /tmp/tomcat_process_count.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
tomcat_process_count
|
||||||
|
if [ $line -gt 0 ]; then
|
||||||
|
echo "$DESC is already running"
|
||||||
|
else
|
||||||
|
echo "Starting $DESC"
|
||||||
|
sh $CATALINA_HOME/bin/startup.sh
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
tomcat_process_count
|
||||||
|
if [ $line -gt 0 ]; then
|
||||||
|
echo "Stopping $DESC"
|
||||||
|
sh $CATALINA_HOME/bin/shutdown.sh
|
||||||
|
else
|
||||||
|
echo "$DESC is not running "
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
tomcat_process_count
|
||||||
|
if [ $line -gt 0 ]; then
|
||||||
|
echo -n "$NAME ( pid "
|
||||||
|
ps ax --width=1000 | grep "org.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
|
||||||
|
echo -n ") is running..."
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo "$NAME is stopped"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
tomcat_process_count
|
||||||
|
if [ $line -gt 0 ]; then
|
||||||
|
$0 stop
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
142
tomcat/tomcat8_jdk8/server.xml
Normal file
142
tomcat/tomcat8_jdk8/server.xml
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<!-- Note: A "Server" is not itself a "Container", so you may not
|
||||||
|
define subcomponents such as "Valves" at this level.
|
||||||
|
Documentation at /docs/config/server.html
|
||||||
|
-->
|
||||||
|
<Server port="8005" shutdown="SHUTDOWN">
|
||||||
|
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
|
||||||
|
<!-- Security listener. Documentation at /docs/config/listeners.html
|
||||||
|
<Listener className="org.apache.catalina.security.SecurityListener" />
|
||||||
|
-->
|
||||||
|
<!--APR library loader. Documentation at /docs/apr.html -->
|
||||||
|
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
|
||||||
|
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
|
||||||
|
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
|
||||||
|
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
|
||||||
|
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
|
||||||
|
|
||||||
|
<!-- Global JNDI resources
|
||||||
|
Documentation at /docs/jndi-resources-howto.html
|
||||||
|
-->
|
||||||
|
<GlobalNamingResources>
|
||||||
|
<!-- Editable user database that can also be used by
|
||||||
|
UserDatabaseRealm to authenticate users
|
||||||
|
-->
|
||||||
|
<Resource name="UserDatabase" auth="Container"
|
||||||
|
type="org.apache.catalina.UserDatabase"
|
||||||
|
description="User database that can be updated and saved"
|
||||||
|
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
|
||||||
|
pathname="conf/tomcat-users.xml" />
|
||||||
|
</GlobalNamingResources>
|
||||||
|
|
||||||
|
<!-- A "Service" is a collection of one or more "Connectors" that share
|
||||||
|
a single "Container" Note: A "Service" is not itself a "Container",
|
||||||
|
so you may not define subcomponents such as "Valves" at this level.
|
||||||
|
Documentation at /docs/config/service.html
|
||||||
|
-->
|
||||||
|
<Service name="Catalina">
|
||||||
|
|
||||||
|
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
|
||||||
|
<!--
|
||||||
|
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
|
||||||
|
maxThreads="150" minSpareThreads="4"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- A "Connector" represents an endpoint by which requests are received
|
||||||
|
and responses are returned. Documentation at :
|
||||||
|
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
|
||||||
|
Java AJP Connector: /docs/config/ajp.html
|
||||||
|
APR (HTTP/AJP) Connector: /docs/apr.html
|
||||||
|
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
|
||||||
|
-->
|
||||||
|
<Connector port="8080" protocol="HTTP/1.1"
|
||||||
|
connectionTimeout="20000" URIEncoding="UTF-8"
|
||||||
|
redirectPort="8443" />
|
||||||
|
<!-- A "Connector" using the shared thread pool-->
|
||||||
|
<!--
|
||||||
|
<Connector executor="tomcatThreadPool"
|
||||||
|
port="8080" protocol="HTTP/1.1"
|
||||||
|
connectionTimeout="20000"
|
||||||
|
redirectPort="8443" />
|
||||||
|
-->
|
||||||
|
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
|
||||||
|
This connector uses the NIO implementation that requires the JSSE
|
||||||
|
style configuration. When using the APR/native implementation, the
|
||||||
|
OpenSSL style configuration is required as described in the APR/native
|
||||||
|
documentation -->
|
||||||
|
<!--
|
||||||
|
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
|
||||||
|
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
|
||||||
|
clientAuth="false" sslProtocol="TLS" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Define an AJP 1.3 Connector on port 8009 -->
|
||||||
|
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- An Engine represents the entry point (within Catalina) that processes
|
||||||
|
every request. The Engine implementation for Tomcat stand alone
|
||||||
|
analyzes the HTTP headers included with the request, and passes them
|
||||||
|
on to the appropriate Host (virtual host).
|
||||||
|
Documentation at /docs/config/engine.html -->
|
||||||
|
|
||||||
|
<!-- You should set jvmRoute to support load-balancing via AJP ie :
|
||||||
|
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
|
||||||
|
-->
|
||||||
|
<Engine name="Catalina" defaultHost="localhost">
|
||||||
|
|
||||||
|
<!--For clustering, please take a look at documentation at:
|
||||||
|
/docs/cluster-howto.html (simple how to)
|
||||||
|
/docs/config/cluster.html (reference documentation) -->
|
||||||
|
<!--
|
||||||
|
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
|
||||||
|
via a brute-force attack -->
|
||||||
|
<Realm className="org.apache.catalina.realm.LockOutRealm">
|
||||||
|
<!-- This Realm uses the UserDatabase configured in the global JNDI
|
||||||
|
resources under the key "UserDatabase". Any edits
|
||||||
|
that are performed against this UserDatabase are immediately
|
||||||
|
available for use by the Realm. -->
|
||||||
|
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
|
||||||
|
resourceName="UserDatabase"/>
|
||||||
|
</Realm>
|
||||||
|
|
||||||
|
<Host name="localhost" appBase="webapps"
|
||||||
|
unpackWARs="true" autoDeploy="true">
|
||||||
|
|
||||||
|
<!-- SingleSignOn valve, share authentication between web applications
|
||||||
|
Documentation at: /docs/config/valve.html -->
|
||||||
|
<!--
|
||||||
|
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Access log processes all example.
|
||||||
|
Documentation at: /docs/config/valve.html
|
||||||
|
Note: The pattern used is equivalent to using pattern="common" -->
|
||||||
|
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
|
||||||
|
prefix="localhost_access_log" suffix=".txt"
|
||||||
|
pattern="%h %l %u %t "%r" %s %b" />
|
||||||
|
|
||||||
|
</Host>
|
||||||
|
</Engine>
|
||||||
|
</Service>
|
||||||
|
</Server>
|
Loading…
Reference in New Issue
Block a user