Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d2e79fef7
|
|||
63f6f969cc
|
|||
03fa82b223
|
|||
235b1a10d8
|
|||
1a01c67759
|
|||
a45b2cfc60
|
|||
2b47398f95
|
|||
f04c1ec1b9
|
|||
ca72a0c8f9
|
|||
7219caa4ff
|
|||
2cd46e37ef
|
|||
7c8bfad01f
|
|||
4821316ee9
|
|||
798cd355b2
|
|||
eab152e928
|
|||
60e7136bcd
|
|||
99b5401c38
|
|||
b6c133bb54
|
|||
58a1a8ee2f
|
|||
bbeebda027
|
|||
267ec22c6f
|
|||
a95bf7a43e
|
|||
20de0927da
|
|||
4f8fe9e768
|
|||
15669c3861
|
|||
ccb788cbeb
|
@@ -11,51 +11,29 @@ permissions:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
name: Build image
|
||||
runs-on: ubuntu-22.04
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
env:
|
||||
REGISTRY: hub.realmanual.ru
|
||||
IMAGE_NAME: pub/sqlite-backup/backup
|
||||
REGISTRY: git.realmanual.ru
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Ensure tag commit is reachable from main
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --no-tags --depth=0 origin main
|
||||
if git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
|
||||
echo "Commit is on main history. Proceeding."
|
||||
else
|
||||
echo "Tag commit is not from main. Skipping build." >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
- name: Extract tag
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
TAG_REF="${GITHUB_REF#refs/tags/}"
|
||||
echo "tag=$TAG_REF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to registry
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.PUSH_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
- name: Build and push Docker image
|
||||
id: push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.tag }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.ref_name }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.idea
|
||||
.env
|
||||
var/*
|
||||
|
11
Dockerfile
11
Dockerfile
@@ -1,17 +1,18 @@
|
||||
FROM alpine:latest
|
||||
FROM alpine:3.19
|
||||
|
||||
ENV TZ=UTC
|
||||
LABEL maintainer="Vassiliy Yegorov <vasyakrg@gmail.com>"
|
||||
|
||||
RUN apk add --no-cache \
|
||||
sqlite \
|
||||
curl \
|
||||
wget \
|
||||
bash \
|
||||
tzdata \
|
||||
openssl
|
||||
openssl \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
RUN curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip && \
|
||||
unzip rclone-current-linux-amd64.zip && \
|
||||
RUN wget https://github.com/rclone/rclone/releases/download/v1.71.0/rclone-v1.71.0-linux-amd64.zip && \
|
||||
unzip rclone-v1.71.0-linux-amd64.zip && \
|
||||
cd rclone-*-linux-amd64 && \
|
||||
cp rclone /usr/bin/ && \
|
||||
chown root:root /usr/bin/rclone && \
|
||||
|
@@ -3,7 +3,7 @@
|
||||
```yaml
|
||||
services:
|
||||
sqlite_backup:
|
||||
image: hub.realmanual.ru/pub/sqlite-backup/backup:latest
|
||||
image: git.realmanual.ru/pub/sqlite-backup-s3
|
||||
container_name: sqlite_backup
|
||||
restart: always
|
||||
volumes:
|
||||
|
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOCKER_BASEIMAGE=alpine:latest
|
||||
TAG=$1
|
||||
|
||||
docker buildx build --platform linux/amd64,linux/arm64 --push -t hub.realmanual.ru/pub/sqlite-backup \
|
||||
--build-arg DOCKER_BASEIMAGE=${DOCKER_BASEIMAGE} .
|
||||
if [ -z "$TAG" ]; then
|
||||
TAG=latest
|
||||
fi
|
||||
|
||||
docker buildx build --platform linux/amd64,linux/arm64 --push -t git.realmanual.ru/pub/sqlite-backup:${TAG} .
|
||||
|
@@ -1,6 +1,9 @@
|
||||
services:
|
||||
sqlite_backup:
|
||||
image: hub.realmanual.ru/pub/sqlite-backup/backup:latest
|
||||
# image: git.realmanual.ru/pub/sqlite-backup/backup:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: sqlite_backup
|
||||
restart: always
|
||||
volumes:
|
||||
|
@@ -1,6 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "${CRONTAB} /scripts/backup.sh" > /etc/crontabs/root
|
||||
# Create crontab in a writable location and set proper permissions
|
||||
mkdir -p /tmp/crontabs
|
||||
echo "${CRONTAB:-"0 * * * *"} /scripts/backup.sh >> /proc/1/fd/1 2>&1" > /tmp/crontabs/root
|
||||
chmod 644 /tmp/crontabs/root
|
||||
|
||||
/scripts/backup.sh
|
||||
exec crond -f
|
||||
# Run initial backup
|
||||
# /scripts/backup.sh
|
||||
|
||||
# Start crond with debug output
|
||||
echo "Starting crond with config:"
|
||||
cat /tmp/crontabs/root
|
||||
echo "---"
|
||||
|
||||
# Start crond in foreground with debug output
|
||||
exec crond -f -c /tmp/crontabs -d 8
|
||||
|
@@ -1,6 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
rclone config create myminio s3 provider Minio access_key_id $MINIO_ACCOUNT_ID secret_access_key $MINIO_APPLICATION_KEY endpoint $MINIO_ENDPOINT region $MINIO_LOCATION acl private
|
||||
# Create rclone config on-the-fly in a writable location
|
||||
RCLONE_CONFIG_DIR="/tmp/rclone"
|
||||
mkdir -p "$RCLONE_CONFIG_DIR"
|
||||
export RCLONE_CONFIG="$RCLONE_CONFIG_DIR/rclone.conf"
|
||||
|
||||
cat > "$RCLONE_CONFIG" << EOF
|
||||
[myminio]
|
||||
type = s3
|
||||
provider = Minio
|
||||
access_key_id = $MINIO_ACCOUNT_ID
|
||||
secret_access_key = $MINIO_APPLICATION_KEY
|
||||
endpoint = $MINIO_ENDPOINT
|
||||
region = $MINIO_LOCATION
|
||||
acl = private
|
||||
no_check_bucket = true
|
||||
EOF
|
||||
|
||||
case $1 in
|
||||
copy)
|
||||
@@ -8,11 +23,11 @@ case $1 in
|
||||
rclone copy --progress $2 $3
|
||||
;;
|
||||
list)
|
||||
echo "list $2"
|
||||
rclone ls $2
|
||||
echo "list ${MINIO_PATH}/$2"
|
||||
rclone ls ${MINIO_PATH}/$2
|
||||
;;
|
||||
delete)
|
||||
echo "delete $2"
|
||||
rclone delete $2
|
||||
echo "delete ${MINIO_PATH}/$2"
|
||||
rclone delete ${MINIO_PATH}/$2
|
||||
;;
|
||||
esac
|
||||
|
Reference in New Issue
Block a user