forked from silinternational/docker-sync-with-s3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logging to logentries; replace "s3cmd sync" with "aws s3 sync"
- Loading branch information
Showing
8 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk update \ | ||
&& apk add ca-certificates python py-pip \ | ||
&& pip install s3cmd | ||
&& apk add ca-certificates python py-pip rsyslog rsyslog-tls ca-certificates openssl \ | ||
&& pip install awscli | ||
|
||
COPY run.py /run.py | ||
COPY crontab.txt /etc/crontabs/root | ||
COPY crontab.txt /crontab.txt | ||
COPY crontab-syslog.txt /crontab-syslog.txt | ||
COPY rsyslog.conf /etc/rsyslog.conf | ||
COPY entry.sh /entry.sh | ||
COPY .s3cfg /root/.s3cfg | ||
|
||
RUN chmod 755 /entry.sh | ||
|
||
CMD ["/entry.sh"] | ||
CMD ["/entry.sh"] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The 's3 sync' command reports progress every few seconds with lines like: | ||
# Completed 231.4 KiB/~255.4 KiB (3.8 MiB/s) with ~2 file(s) remaining (calculating...)^M | ||
# | ||
# We don't want to send these lines to logentries. The final line contains | ||
# only ASCII space characters. The 'sed' commands strip the progress lines | ||
# and the final blank line from the output leaving only one line for each | ||
# file transfered. | ||
# | ||
CRON_SCHEDULE (aws --color=off --no-paginate s3 sync SOURCE_PATH DESTINATION_PATH 2>&1) | sed -e 's/Completed .*\r//' -e '/^ *$/d' | logger -p user.info |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CRON_SCHEDULE s3cmd sync SOURCE_PATH DESTINATION_PATH | ||
CRON_SCHEDULE aws --color=off --no-paginate s3 sync SOURCE_PATH DESTINATION_PATH |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
#!/bin/sh | ||
|
||
# configure crontab based on the existance of the LOGENTRIES_KEY environment variable | ||
if [ "$LOGENTRIES_KEY" ]; then | ||
cp /crontab-syslog.txt /etc/crontabs/root | ||
sed -i /etc/rsyslog.conf -e "s/LOGENTRIESKEY/${LOGENTRIES_KEY}/" | ||
rsyslogd | ||
sleep 10 # ensure rsyslogd is running before we may need to send logs to it | ||
else | ||
cp /crontab.txt /etc/crontabs/root | ||
fi | ||
|
||
# setup env | ||
mkdir -p /root/.aws | ||
echo "[default]" > /root/.aws/config | ||
|
||
echo "[default]" > /root/.aws/credentials | ||
echo "aws_access_key_id = ${ACCESS_KEY}" >> /root/.aws/credentials | ||
echo "aws_secret_access_key = ${SECRET_KEY}" >> /root/.aws/credentials | ||
|
||
python /run.py | ||
|
||
# start cron | ||
crond -f | ||
crond -f |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ SECRET_KEY= | |
CRON_SCHEDULE= | ||
SOURCE_PATH= | ||
DESTINATION_PATH= | ||
BUCKET_LOCATION= | ||
BUCKET_LOCATION= | ||
LOGENTRIES_KEY= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# if you experience problems, check: | ||
# http://www.rsyslog.com/troubleshoot | ||
|
||
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command) | ||
|
||
# | ||
# Configure TLS (logentries-specific example: https://docs.logentries.com/docs/rsyslog/) | ||
# | ||
$DefaultNetstreamDriverCAFile /etc/ssl/certs/ca-certificates.crt | ||
$ActionSendStreamDriver gtls | ||
$ActionSendStreamDriverMode 1 | ||
$ActionSendStreamDriverAuthMode x509/name | ||
$ActionSendStreamDriverPermittedPeer *.logentries.com | ||
|
||
$template LogentriesFormat,"LOGENTRIESKEY %msg%\n" | ||
*.emerg,*.alert,*.crit,*.err,*.warning,user.* @@data.logentries.com:443;LogentriesFormat |
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