mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-27 23:51:47 +00:00
Add rsync Dockerfile
This commit is contained in:
parent
0f6fa71657
commit
e6834fa6f7
8
deploy/test_case_rsync/Dockerfile
Normal file
8
deploy/test_case_rsync/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM alpine:3.6
|
||||
|
||||
RUN apk add --update --no-cache rsync
|
||||
|
||||
ADD ./run.sh /tmp/run.sh
|
||||
ADD ./rsyncd.conf /etc/rsyncd.conf
|
||||
|
||||
CMD /bin/sh /tmp/run.sh
|
24
deploy/test_case_rsync/docker-compose.yml
Normal file
24
deploy/test_case_rsync/docker-compose.yml
Normal file
@ -0,0 +1,24 @@
|
||||
version: "3"
|
||||
services:
|
||||
oj-rsync-master:
|
||||
image: oj_rsync
|
||||
container_name: oj-rsync
|
||||
volumes:
|
||||
- $PWD/data/backend/test_case:/test_case:ro
|
||||
- $PWD/data/rsync_master:/log
|
||||
environment:
|
||||
- RSYNC_MODE=master
|
||||
- RSYNC_USER=ojrsync
|
||||
- RSYNC_PASSWORD=CHANGE_THIS_PASSWORD
|
||||
ports:
|
||||
- "0.0.0.0:873:873"
|
||||
|
||||
oj-rsync-slave:
|
||||
image: oj-rsync
|
||||
volumes:
|
||||
- $PWD/test_case:/test_case
|
||||
- $PWD/rsync_slave:/log
|
||||
environment:
|
||||
- RSYNC_MODE=slave
|
||||
- RSYNC_USER=ojrsync
|
||||
- RSYNC_PASSWORD=CHANGE_THIS_PASSWORD
|
12
deploy/test_case_rsync/rsyncd.conf
Normal file
12
deploy/test_case_rsync/rsyncd.conf
Normal file
@ -0,0 +1,12 @@
|
||||
port = 873
|
||||
uid = root
|
||||
gid = root
|
||||
use chroot = yes
|
||||
read only = yes
|
||||
log file = /log/rsyncd.log
|
||||
|
||||
[testcase]
|
||||
path = /test_case/
|
||||
list = yes
|
||||
auth users = ojrsync
|
||||
secrets file = /etc/rsyncd.passwd
|
33
deploy/test_case_rsync/run.sh
Normal file
33
deploy/test_case_rsync/run.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
slave_runner()
|
||||
{
|
||||
while true
|
||||
do
|
||||
rsync -avzP --delete --progress --password-file=/etc/rsync_slave.passwd $RSYNC_USER@$RSYNC_MASTER_ADDR::testcase /test_case >> /log/rsync_slave.log
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
master_runner()
|
||||
{
|
||||
rsync --daemon --config=/etc/rsyncd.conf
|
||||
while true
|
||||
do
|
||||
sleep 60
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$RSYNC_MODE" = "master" ]; then
|
||||
if [ ! -f "/etc/rsyncd.passwd" ]; then
|
||||
echo "$RSYNC_USER:$RSYNC_PASSWORD" > /etc/rsyncd.passwd
|
||||
fi
|
||||
chmod 600 /etc/rsyncd.passwd
|
||||
master_runner
|
||||
else
|
||||
if [ ! -f "/etc/rsync_slave.passwd" ]; then
|
||||
echo "$RSYNC_PASSWORD" > /etc/rsync_slave.passwd
|
||||
fi
|
||||
chmod 600 /etc/rsync_slave.passwd
|
||||
slave_runner
|
||||
fi
|
Loading…
Reference in New Issue
Block a user