Skip to content

Commit e8bb12e

Browse files
committed
feat: add R2 and S3 support for image synchronization
1 parent 1a1add8 commit e8bb12e

File tree

8 files changed

+471
-85
lines changed

8 files changed

+471
-85
lines changed

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,72 @@ sync:
151151
username: "_json_key_base64"
152152
name: GCR / GAR
153153
url: gcr.io
154-
```
154+
```
155+
156+
#### R2 (target only)
157+
158+
```yaml
159+
sync:
160+
images:
161+
- source: docker.io/library/ubuntu
162+
targets:
163+
- r2:f6934f56ce237241104dbe9302cee786:docker-sync-test:ubuntu # r2:<endpoint>:<bucket>:<image>
164+
registries:
165+
- auth:
166+
helper: ""
167+
password: "SECRET_ACCES_KEY"
168+
token: ""
169+
username: "ACCESS_KEY_ID"
170+
name: R2
171+
url: r2:f6934f56ce237241104dbe9302cee786:docker-sync-test # r2:<endpoint>:<bucket>
172+
```
173+
174+
Note that pulls should be performed against the bucket's public url. Check [the docs](https://developers.cloudflare.com/r2/buckets/public-buckets/#enable-managed-public-access) for more information.
175+
176+
Don't use the standard `r2.dev` domain, as some rules need to be created and they won't work without a custom domain.
177+
178+
To match the [official spec](https://github.com/openshift/docker-distribution/blob/master/docs/spec/api.md#api-version-check), some rules need to be created.
179+
180+
Use the Cloudflare UI to create the rules by going to Rules > Transform Rules.
181+
182+
##### V2 Ping Fix - /v2/ requires `200 OK`
183+
184+
Create a **Rewrite URL** rule.
185+
186+
**If incoming requests match...**: Custom filter expression
187+
188+
**URI Path**: `equals` `/v2/`
189+
190+
**Expression Preview**: `(http.request.uri.path eq "/v2/")` (optionally also add your hostname for a better match)
191+
192+
**Then...**: Path > Rewrite to... > Static > `/v2` (without the trailing slash)
193+
194+
##### V2 Ping Fix - /v2/ requires `Docker-Distribution-API-Version` header
195+
196+
Create a **Modify Response Header** rule.
197+
198+
**If incoming requests match...**: Custom filter expression
199+
200+
**URI Path**: `starts with` `/v2/`
201+
202+
**Expression Preview**: `(starts_with(http.request.uri.path, "/v2"))` (optionally also add your hostname for a better match)
203+
204+
**Then...**: Set static > `Docker-Distribution-API-Version` > `registry/2.0`
205+
206+
#### S3 (target only)
207+
208+
```yaml
209+
sync:
210+
images:
211+
- source: docker.io/library/ubuntu
212+
targets:
213+
- r3:us-east-1:docker-sync-test:ubuntu # s3:<region>:<bucket>:<image>
214+
registries:
215+
- auth:
216+
helper: ""
217+
password: "SECRET_ACCES_KEY"
218+
token: ""
219+
username: "ACCESS_KEY_ID"
220+
name: S3
221+
url: s3:us-east-1:docker-sync-test # s3:<region>:<bucket>
222+
```

go.mod

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
module github.com/Altinity/docker-sync
22

3-
go 1.21.5
3+
go 1.22.6
4+
5+
toolchain go1.23.3
46

57
require (
68
github.com/aws/aws-sdk-go v1.53.19
79
github.com/cenkalti/backoff/v4 v4.3.0
8-
github.com/google/go-containerregistry v0.19.1
9-
github.com/prometheus/client_golang v1.19.1
10+
github.com/google/go-containerregistry v0.20.2
11+
github.com/prometheus/client_golang v1.20.2
1012
github.com/rs/zerolog v1.33.0
1113
github.com/spf13/cast v1.6.0
12-
github.com/spf13/cobra v1.8.0
14+
github.com/spf13/cobra v1.8.1
1315
github.com/spf13/viper v1.18.2
14-
go.opentelemetry.io/otel v1.27.0
16+
go.opentelemetry.io/otel v1.28.0
1517
go.opentelemetry.io/otel/exporters/prometheus v0.49.0
1618
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.26.0
17-
go.opentelemetry.io/otel/metric v1.27.0
18-
go.opentelemetry.io/otel/sdk v1.27.0
19+
go.opentelemetry.io/otel/metric v1.28.0
20+
go.opentelemetry.io/otel/sdk v1.28.0
1921
go.opentelemetry.io/otel/sdk/metric v1.27.0
2022
go.uber.org/multierr v1.11.0
2123
gopkg.in/yaml.v3 v3.0.1
@@ -24,43 +26,46 @@ require (
2426
require (
2527
github.com/beorn7/perks v1.0.1 // indirect
2628
github.com/cespare/xxhash/v2 v2.3.0 // indirect
27-
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
28-
github.com/docker/cli v24.0.0+incompatible // indirect
29-
github.com/docker/distribution v2.8.2+incompatible // indirect
30-
github.com/docker/docker v24.0.0+incompatible // indirect
31-
github.com/docker/docker-credential-helpers v0.7.0 // indirect
29+
github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect
30+
github.com/docker/cli v27.3.1+incompatible // indirect
31+
github.com/docker/distribution v2.8.3+incompatible // indirect
32+
github.com/docker/docker-credential-helpers v0.8.2 // indirect
3233
github.com/fsnotify/fsnotify v1.7.0 // indirect
33-
github.com/go-logr/logr v1.4.1 // indirect
34+
github.com/go-logr/logr v1.4.2 // indirect
3435
github.com/go-logr/stdr v1.2.2 // indirect
36+
github.com/google/uuid v1.6.0 // indirect
3537
github.com/hashicorp/hcl v1.0.0 // indirect
3638
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3739
github.com/jmespath/go-jmespath v0.4.0 // indirect
38-
github.com/klauspost/compress v1.17.0 // indirect
40+
github.com/klauspost/compress v1.17.11 // indirect
3941
github.com/magiconair/properties v1.8.7 // indirect
4042
github.com/mattn/go-colorable v0.1.13 // indirect
4143
github.com/mattn/go-isatty v0.0.19 // indirect
4244
github.com/mitchellh/go-homedir v1.1.0 // indirect
4345
github.com/mitchellh/mapstructure v1.5.0 // indirect
46+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4447
github.com/opencontainers/go-digest v1.0.0 // indirect
45-
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
48+
github.com/opencontainers/image-spec v1.1.0 // indirect
4649
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
4750
github.com/pkg/errors v0.9.1 // indirect
4851
github.com/prometheus/client_model v0.6.1 // indirect
49-
github.com/prometheus/common v0.53.0 // indirect
50-
github.com/prometheus/procfs v0.15.0 // indirect
52+
github.com/prometheus/common v0.57.0 // indirect
53+
github.com/prometheus/procfs v0.15.1 // indirect
54+
github.com/rogpeppe/go-internal v1.12.0 // indirect
5155
github.com/sagikazarmark/locafero v0.4.0 // indirect
5256
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
53-
github.com/sirupsen/logrus v1.9.1 // indirect
57+
github.com/sirupsen/logrus v1.9.3 // indirect
5458
github.com/sourcegraph/conc v0.3.0 // indirect
5559
github.com/spf13/afero v1.11.0 // indirect
5660
github.com/spf13/pflag v1.0.5 // indirect
5761
github.com/subosito/gotenv v1.6.0 // indirect
58-
github.com/vbatts/tar-split v0.11.3 // indirect
59-
go.opentelemetry.io/otel/trace v1.27.0 // indirect
60-
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
61-
golang.org/x/sync v0.7.0 // indirect
62-
golang.org/x/sys v0.20.0 // indirect
63-
golang.org/x/text v0.14.0 // indirect
64-
google.golang.org/protobuf v1.34.1 // indirect
62+
github.com/vbatts/tar-split v0.11.6 // indirect
63+
go.opentelemetry.io/otel/trace v1.28.0 // indirect
64+
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
65+
golang.org/x/sync v0.8.0 // indirect
66+
golang.org/x/sys v0.26.0 // indirect
67+
golang.org/x/text v0.19.0 // indirect
68+
google.golang.org/protobuf v1.34.2 // indirect
6569
gopkg.in/ini.v1 v1.67.0 // indirect
70+
gotest.tools/v3 v3.5.1 // indirect
6671
)

0 commit comments

Comments
 (0)