Giter VIP home page Giter VIP logo

r2-registry's Introduction


Text changing depending on mode.'

Docker image registry on Cloudflare R2 (No workers)

Built with Bash Made for Docker Built with Cloudflare R2


πŸ“– About

This is a very simple Bash shell script that converts local Docker container images into the registry distribution format and structure. The tool then uploads that structure via rclone to your R2 bucket of choice. The end result is having a Docker registry compatible URL on R2.

Example URL: docker pull pub-6975b173047b49bf97e9146ff7808721.r2.dev/myapp:v1.0.0

Example URL with custom domain: docker pull images.sheldon.is/myapp:v1.0.0

πŸ’» Demo

Demo GIF

πŸ“• Requirements

  • skopeo - Toolkit for container images
  • rclone - Upload container image structure to R2
  • jq - CLI utility for handling JSON data

⛔️ Limitations

Most notably, read-only access to images.

JΓ©rome (who inspired this all-in-one script) goes over the other limitations of using a static-file-like-host such as R2 here.

⌨️ Usage

First, build your Docker image as you normally would.

  1. cd myapp
  2. docker build -t myapp .
  3. docker tag myapp:latest myapp:v1.0.0

Next, install r2-registry:

  1. git clone https://github.com/fieu/r2-registry
  2. cd r2-registry
  3. ./generate.sh [image] [tag]

Now, setup your environment variables that are used by the script:

  • CLOUDFLARE_ACCOUNT_ID - Cloudflare account ID (found here)
  • R2_BUCKET - Name of R2 bucket to store image contents
  • R2_ACCESS_KEY_ID - R2 Access Key (info)
  • R2_SECRET_ACCESS_KEY - R2 Secret Access Key (info)
  • R2_DOMAIN - R2 custom domain (optional) (info)

πŸ§ͺ Example

export CLOUDFLARE_ACCOUNT_ID=123456789
export R2_BUCKET=docker-images
export R2_ACCESS_KEY_ID=123
export R2_SECRET_ACCESS_KEY=123
export R2_DOMAIN=images.sheldon.is
./generate.sh myapp v1.0.0

🧬 Output

Demo GIF

πŸŽ‰ Try it out

Try and pull my image from my R2 bucket:

docker pull images.sheldon.is/myapp:v1.0.0

❓ Help

$ ./generate.sh
Usage: ./generate.sh <image> <tag>
	image (string)	 The name of the image to build
	tag (string)	 The tag of the image to build

✏️ Contributing

Contributions are welcome and will be fully credited.

I accept contributions within project scope via Pull Requests on GitHub.

πŸ‘€ Credits

jpetazzo/registrish - Initial concept and code snippets

πŸ“ License

r2-registry is open-sourced software licensed under the MIT License.

r2-registry's People

Contributors

fieu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

r2-registry's Issues

issue with pull

docker: Error response from daemon: unknown: InvalidArgumentInvalid Argument: Authorization.

Successfully uploaded docker image assets but fails to pull due to file accesibility

First of all, thanks for the great project on building private docker registry simplified and cost effective for individual developers; but one major problem I met after uploading image to the r2 buckets is returning an HTML page titled "You are not authorized to view this object" from Cloudflare after the GET operation by running docker pull. While I tried your example yet it seems to be working and I successfully managed to run your application, but when it comes to me the problem exists. I'm assuming there might be an issue with the CORS policy setting for the bucket to some degree while it automatically blocks access from unknown domains if AllowedOrigins field is not configured? Whereas I did set the allowed origins to * wildcard for authorizing access from all entry points, but it still doesn't seem to be working, I have tried to switch machines from my local devices to VMs but the same issue repeatedly occurs, below is my CORS configuration for the certain bucket storing my images edited on the policy tab of Cloudflare.

[
  {
    "AllowedOrigins": [
      "*"
    ],
    "AllowedMethods": [
      "GET",
      "POST"
    ],
    "AllowedHeaders": [
      "*"
    ],
    "ExposeHeaders": [
      "*"
    ]
  }
]

I have read the Cloudflare documentation on granting public access to bucket via custom domains, I initially believed the problem persists was due to the cache period for the CORs policy to take effect on the certain domain, but I've also tried binding other domains and it pulling images from still did not succeed and persisted returning 404 page, could you please share your CORS setting to make the bucket to work as a registry or there might be some issue with my own configs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.