-
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.
Merge pull request #32 from funnyzak:gitsync
Add Docker support for git-sync
- Loading branch information
Showing
13 changed files
with
184 additions
and
125 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
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
Binary file not shown.
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,50 @@ | ||
FROM golang:1.23.4-alpine AS builder | ||
|
||
WORKDIR /go/src/app | ||
|
||
RUN apk update && \ | ||
apk add upx ca-certificates tzdata git | ||
|
||
ARG VERSION | ||
ARG BUILD_DATE | ||
ARG VCS_REF | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux | ||
|
||
RUN git clone https://github.com/AkashRajpurohit/git-sync.git . \ | ||
&& git checkout ${VERSION} || git checkout $(git remote show origin | awk '/HEAD branch/ {print $NF}') \ | ||
&& echo ${VERSION:-$(git rev-parse --short=12 HEAD)}-$(git log -1 --format=%cd --date=format:'%y%m%d') > VERSION | ||
|
||
RUN go mod download \ | ||
&& go mod tidy | ||
|
||
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/AkashRajpurohit/git-sync/pkg/version.Version=${VERSION} -X github.com/AkashRajpurohit/git-sync/pkg/version.Build=${BUILD_DATE}" -o git-sync . \ | ||
&& upx -q git-sync | ||
|
||
FROM alpine:latest | ||
WORKDIR /opt/go | ||
|
||
LABEL org.label-schema.name="git-sync" \ | ||
org.label-schema.description="A simple tool to backup and sync your git repositories." \ | ||
org.label-schema.version="${VERSION}" \ | ||
org.label-schema.build-date="${BUILD_DATE}" \ | ||
org.label-schema.vcs-ref="${VCS_REF}" \ | ||
org.label-schema.vendor="Leon<silenceace@gmail.com>" \ | ||
org.label-schema.url="https://github.com/funnyzak/docker-release" | ||
|
||
RUN apk update && \ | ||
apk add git su-exec | ||
|
||
RUN mkdir -p /git-sync /backups | ||
|
||
COPY --from=builder /go/src/app/git-sync /opt/go/git-sync | ||
COPY --from=builder /go/src/app/VERSION /opt/go/VERSION | ||
COPY --from=builder /go/src/app/entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod +x /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh", "/opt/go/git-sync"] | ||
CMD ["--config", "/git-sync/config.yaml", "--backup-dir", "/backups"] | ||
|
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,88 @@ | ||
# git-sync | ||
|
||
[](https://hub.docker.com/r/funnyzak/git-sync/) | ||
[](https://hub.docker.com/r/funnyzak/git-sync/) | ||
[](https://hub.docker.com/r/funnyzak/git-sync/) | ||
[](https://hub.docker.com/r/funnyzak/git-sync/) | ||
|
||
`git-sync` is a CLI tool designed to help you back up your Git repositories. This tool ensures you have a local copy of your repositories, safeguarding against potential issues such as account bans or data loss. | ||
. This image supports `linux/amd64`,`linux/arm/v7`, `linux/arm64`. | ||
|
||
You can pull the images using the following commands: | ||
|
||
```bash | ||
docker pull funnyzak/git-sync:latest | ||
# GHCR | ||
docker pull ghcr.io/funnyzak/git-sync:latest | ||
# Aliyun | ||
docker pull registry.cn-beijing.aliyuncs.com/funnyzak/git-sync:latest | ||
``` | ||
|
||
--- | ||
|
||
## Usage Example | ||
|
||
### Docker run | ||
|
||
```bash | ||
docker run \ | ||
--name=git-sync \ | ||
-e PUID=1000 \ | ||
-e PGID=1000 \ | ||
-v ./git-sync/config.yaml:/git-sync/config.yaml \ | ||
-v ./git-backups:/backups \ | ||
funnyzak/git-sync:latest | ||
``` | ||
|
||
### Docker Compose | ||
|
||
```yaml | ||
version: '3' | ||
services: | ||
git-sync: | ||
image: funnyzak/git-sync:latest | ||
container_name: git-sync | ||
environment: | ||
- PUID=1000 | ||
- PGID=1000 | ||
volumes: | ||
- ./git-sync/config.yaml:/git-sync/config.yaml | ||
- ./git-backups:/backups | ||
``` | ||
### Configuration | ||
Here is an example of a `config.yaml` file: | ||
|
||
```yaml | ||
# Git Sync Configuration | ||
# Repository settings | ||
include_forks: false # Include forked repositories | ||
include_wiki: true # Include wiki's | ||
include_repos: [] # Include specific repositories | ||
exclude_repos: [] # Exclude specific repositories | ||
include_orgs: [] # Include repositories from specific organizations | ||
exclude_orgs: [] # Exclude repositories from specific organizations | ||
raw_git_urls: [] # Raw valid git URLs | ||
# Authentication | ||
username: <username> | ||
tokens: [<token 1>] | ||
# Server settings | ||
backup_dir: /path/to/backup | ||
clone_type: bare # Clone type: bare, shallow, mirror or full. Default: bare | ||
cron: 0 0 * * * # run every 24 hours at 00:00 | ||
concurrency: 5 | ||
retry: | ||
count: 3 | ||
delay: 10 # in seconds | ||
platform: github | ||
server: | ||
domain: github.com | ||
protocol: https | ||
``` | ||
More information about the configuration can be found [here](https://github.com/AkashRajpurohit/git-sync/wiki/Configuration). | ||
|
||
More Examples can be found [here](https://github.com/AkashRajpurohit/git-sync/wiki/Examples). |
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
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.