refactored container image and gitea workflows
All checks were successful
/ build-docker-image (push) Successful in 1m2s
All checks were successful
/ build-docker-image (push) Successful in 1m2s
This commit is contained in:
@@ -1,25 +1,48 @@
|
||||
FROM alpine:latest
|
||||
|
||||
# Install BorgBackup and OpenSSH client
|
||||
# Installs
|
||||
# - BorgBackup
|
||||
# - OpenSSH client
|
||||
RUN echo "Installing packages."
|
||||
RUN apk update && apk add --no-cache \
|
||||
borgbackup \
|
||||
openssh \
|
||||
bash \
|
||||
tzdata
|
||||
|
||||
RUN echo "Copying app."
|
||||
COPY ./docker/app /app
|
||||
RUN chmod +x /app/scripts -R
|
||||
|
||||
|
||||
|
||||
# having some problems if app/scripts files not set with executable permissions
|
||||
# this is not working, so please confirm files are executable on host building docker file
|
||||
# setting app owner.
|
||||
# RUN chown -R root:root /app
|
||||
#RUN echo "Setting app permissions"
|
||||
#RUN chown -R root:root /app/scripts && find /app/scripts -type f -exec chmod +x {} \;
|
||||
# use this entrypoint to verify final permissions on container
|
||||
#ENTRYPOINT ["ls", "-lah", "/app/scripts"]
|
||||
|
||||
|
||||
RUN echo "creating symbolic links to app/scripts."
|
||||
RUN ln -s /app/scripts/loadenv /usr/local/bin/loadenv
|
||||
RUN ln -s /app/scripts/remote-connect /usr/local/bin/remote-connect
|
||||
RUN ln -s /app/scripts/remote-connect /usr/local/bin/remote-get-folder-size
|
||||
RUN ln -s /app/scriptsremote-get-folder-size /usr/local/bin/remote-get-folder-size
|
||||
|
||||
#RUN addgroup -g 1001 -S borg && adduser -u 1001 -S borg -G borg
|
||||
#USER borg
|
||||
#WORKDIR /app
|
||||
RUN echo "creating .ssh folder."
|
||||
RUN mkdir /root/.ssh
|
||||
RUN echo "setting .ssh folder permissions."
|
||||
RUN chmod 700 /root/.ssh
|
||||
|
||||
# for files inside correct permission is chmod 600 /root/.ssh/key
|
||||
|
||||
RUN echo "Setting loadenv to bashrc and bash_profile"
|
||||
|
||||
RUN echo "source /usr/local/bin/loadenv" > /root/.bash_profile
|
||||
RUN echo "source /usr/local/bin/loadenv" > /root/.bashrc
|
||||
|
||||
ENTRYPOINT ["bash" , "-c", "borg $0"]
|
||||
RUN echo "setting entrypoint."
|
||||
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
|
||||
|
||||
CMD ["--help"]
|
||||
#CMD ["--help"]
|
||||
9
docker/app/README.md
Normal file
9
docker/app/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# borg backup helper
|
||||
|
||||
for mode SCRIPT, file /app/backup-scripts/backup must be created.
|
||||
|
||||
- Docker Compose Configs Sections (check repo <https:///git.limbosolutions.com/kb/borg> readme file for more information);
|
||||
- binding mounts (Ex: ./backup-scripts:/app/backup-scripts);
|
||||
- kubernetes secrets, configSections or even volumes;
|
||||
|
||||
The file backup will be automatically executed if exists.
|
||||
33
docker/app/scripts/entrypoint.sh
Executable file
33
docker/app/scripts/entrypoint.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /app/scripts/loadenv
|
||||
|
||||
|
||||
case "$MODE" in
|
||||
|
||||
BORG)
|
||||
echo "executing borg cli"
|
||||
borg "${@:1}" # Forward all arguments except $0 to another CLI so first argument (the name of this scripts don't passthrough)"
|
||||
;;
|
||||
|
||||
SCRIPT)
|
||||
# check if file exists
|
||||
if [ ! -f /app/backup-scripts/backup ]; then
|
||||
cat /app/README.md
|
||||
exit 1
|
||||
fi
|
||||
echo "Executing: backup script with arguments: "\${@:1\"."
|
||||
cd /app/backup-scripts && bash backup "${@:1}"
|
||||
;;
|
||||
|
||||
SHELL)
|
||||
echo "Executing: bash -c \"${@:1}\"."
|
||||
bash -c "${@:1}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown mode: $MODE."
|
||||
echo "Valid modes are: BORG, SCRIPT, SHELL"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -25,8 +25,7 @@ fi
|
||||
|
||||
export SSH_COMMAND="$SSH_COMMAND $SSH_CONNECTION"
|
||||
|
||||
|
||||
|
||||
: "${MODE:=BORG}" # Set default if MODE is unset to borg cli
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user