Skip to content

Commit f7d71ad

Browse files
committed
project init
0 parents  commit f7d71ad

File tree

9 files changed

+265
-0
lines changed

9 files changed

+265
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github

.github/workflows/publish-image.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and Publish Image
2+
3+
on:
4+
# Trigger the workflow on push or pull request,
5+
# but only for the master branch
6+
push:
7+
branches:
8+
- master
9+
paths-ignore:
10+
- '**.html'
11+
12+
env:
13+
ZOOKEEPER_VERSION: 3.7.1
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
# Login against a Docker registry except on PR
31+
# https://github.com/docker/login-action
32+
- name: Log into registry dockerhub
33+
if: steps.cache.outputs.cache-hit != 'true'
34+
uses: docker/login-action@v1
35+
with:
36+
username: ${{ secrets.DOCKER_HUB_USER }}
37+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
38+
39+
- name: Build and push
40+
uses: docker/build-push-action@v3
41+
with:
42+
context: ./
43+
build-args: |
44+
ZOOKEEPER_VERSION=${{ env.ZOOKEEPER_VERSION }}
45+
push: true
46+
tags: |
47+
yunnysunny/zookeeper:latest
48+
yunnysunny/zookeeper:${{ env.ZOOKEEPER_VERSION }}
49+
cache-from: type=registry,ref=yunnysunny/zookeeper:buildcache
50+
cache-to: type=registry,ref=yunnysunny/zookeeper:buildcache,mode=max
51+
- name: Update zookeeper description
52+
uses: peter-evans/dockerhub-description@v2
53+
if: ${{ github.event_name != 'pull_request' }}
54+
with:
55+
username: ${{ secrets.DOCKER_HUB_USER }}
56+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
57+
repository: yunnysunny/zookeeper
58+

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM openjdk:11
2+
3+
COPY install_zk.sh /data/install_zk.sh
4+
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
5+
RUN apt-get update \
6+
&& apt-get install --no-install-recommends wget -y \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
ARG ZOOKEEPER_VERSION
10+
RUN /data/install_zk.sh
11+
COPY entrypoint.sh /
12+
ENTRYPOINT [ "/entrypoint.sh" ]

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# zookeeper
2+
3+
基于父镜像 openjdk:11 。
4+
5+
## 镜像 tag
6+
7+
registry.cn-hangzhou.aliyuncs.com/whyun/base:zookeeper-${ZOOKEEPER_VERSION}

build_zk.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
source ../scripts/read_param.sh
4+
5+
ZOOKEEPER_VERSION=3.7.0
6+
7+
docker pull openjdk:11
8+
docker build . -f zk.Dockerfile -t yunnysunny/zookeeper:${ZOOKEEPER_VERSION} \
9+
--build-arg ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION}
10+
if [ "$NEED_PUSH" = "1" ] ; then
11+
docker push yunnysunny/zookeeper:${ZOOKEEPER_VERSION}
12+
fi
13+
14+
15+

install_zk.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#title :zookeeper-install.sh
3+
#description :The script to install zookeeper 0.8.x
4+
#author :Motty Cohen
5+
#date :05-Feb-2015
6+
#usage :/bin/bash install-zookeeper.sh
7+
8+
#https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz
9+
ZOOKEEPER_VERSION=3.6.2
10+
ZOOKEEPER_FILENAME=apache-zookeeper-$ZOOKEEPER_VERSION-bin
11+
ZOOKEEPER_ARCHIVE_NAME=$ZOOKEEPER_FILENAME.tar.gz
12+
13+
ZOOKEEPER_DOWNLOAD_ADDRESS=https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-$ZOOKEEPER_VERSION/$ZOOKEEPER_ARCHIVE_NAME
14+
15+
INSTALL_DIR=/opt
16+
ZOOKEEPER_FULL_DIR=$INSTALL_DIR/$ZOOKEEPER_FILENAME
17+
ZOOKEEPER_DIR=$INSTALL_DIR/zookeeper
18+
ZOOKEEPER_SERVICE=zookeeper
19+
20+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21+
22+
if [[ $EUID -ne 0 ]]; then
23+
echo "This script must be run as root."
24+
exit 1
25+
fi
26+
27+
echo "Downloading: $ZOOKEEPER_DOWNLOAD_ADDRESS..."
28+
[ -e "$ZOOKEEPER_ARCHIVE_NAME" ] && echo 'zookeeper archive already exists.'
29+
if [ ! -e "$ZOOKEEPER_ARCHIVE_NAME" ]; then
30+
wget -q $ZOOKEEPER_DOWNLOAD_ADDRESS
31+
if [ $? -ne 0 ]; then
32+
echo "Not possible to download zookeeper."
33+
exit 1
34+
fi
35+
fi
36+
37+
echo "Cleaning up..."
38+
rm -f "$ZOOKEEPER_DIR"
39+
rm -rf "$ZOOKEEPER_FULL_DIR"
40+
rm -rf "/var/run/$ZOOKEEPER_SERVICE/"
41+
rm -f "/etc/init.d/$ZOOKEEPER_SERVICE"
42+
43+
echo "Installation to $ZOOKEEPER_FULL_DIR ..."
44+
mkdir $ZOOKEEPER_FULL_DIR
45+
tar -xzvf $ZOOKEEPER_ARCHIVE_NAME -C $INSTALL_DIR
46+
47+
echo "Creating symbolic link: to $ZOOKEEPER_DIR ..."
48+
ln -s $ZOOKEEPER_FULL_DIR/ $ZOOKEEPER_DIR
49+
cp $ZOOKEEPER_DIR/conf/zoo_sample.cfg $ZOOKEEPER_DIR/conf/zoo.cfg
50+
51+
echo "Cleaning archive..."
52+
rm -f "$ZOOKEEPER_ARCHIVE_NAME"

start_zk.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
mkdir -p /data/app/log/
3+
/etc/init.d/zookeeper start

zk.Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM openjdk:11
2+
3+
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
4+
RUN apt-get update \
5+
&& apt-get install --no-install-recommends wget -y \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
COPY install_zk.sh /data/install_zk.sh
9+
ARG ZOOKEEPER_VERSION
10+
RUN /data/install_zk.sh
11+
12+
COPY zookeeper /etc/init.d/zookeeper
13+
14+
COPY start_zk.sh /start.sh
15+
16+
CMD [ "/start.sh" ]

zookeeper

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#! /bin/sh
2+
# /etc/init.d/zookeeper: start the zookeeper daemon.
3+
4+
# chkconfig: - 80 20
5+
# description: zookeeper
6+
7+
ZK_HOME=/opt/zookeeper
8+
ZK_USER=root
9+
ZK_SCRIPT=$ZK_HOME/bin/zkServer.sh
10+
ZK_CONSOLE_LOG=/data/app/log/zookeeper.log
11+
12+
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
13+
14+
prog=zookeeper
15+
DESC="zookeeper daemon"
16+
17+
RETVAL=0
18+
STARTUP_WAIT=30
19+
SHUTDOWN_WAIT=30
20+
21+
22+
# Source function library.
23+
. /etc/init.d/functions
24+
25+
start() {
26+
echo -n $"Starting $prog: "
27+
28+
# Run daemon
29+
cd $ZK_HOME
30+
nohup sh $ZK_SCRIPT start 2>&1 >> $ZK_CONSOLE_LOG 2>&1 &
31+
32+
33+
count=0
34+
launched=false
35+
36+
until [ $count -gt $STARTUP_WAIT ]
37+
do
38+
grep 'Starting zookeeper ... STARTED' $ZK_CONSOLE_LOG > /dev/null
39+
if [ $? -eq 0 ] ; then
40+
launched=true
41+
break
42+
fi
43+
sleep 1
44+
let count=$count+1;
45+
done
46+
47+
success
48+
echo
49+
return 0
50+
}
51+
52+
stop() {
53+
echo -n $"Stopping $prog: "
54+
$ZK_SCRIPT stop
55+
success
56+
echo
57+
}
58+
59+
reload() {
60+
stop
61+
start
62+
}
63+
64+
restart() {
65+
$ZK_SCRIPT restart
66+
}
67+
68+
status() {
69+
$ZK_SCRIPT status
70+
return $?
71+
}
72+
73+
case "$1" in
74+
start)
75+
start
76+
;;
77+
78+
stop)
79+
stop
80+
;;
81+
82+
reload)
83+
reload
84+
;;
85+
86+
restart)
87+
restart
88+
;;
89+
90+
status)
91+
status
92+
;;
93+
*)
94+
95+
echo $"Usage: $0 {start|stop|reload|restart|status}"
96+
exit 1
97+
esac
98+
99+
exit $?
100+
101+

0 commit comments

Comments
 (0)