Add S3 storage support for mirror repository data#336
Merged
vtsykun merged 1 commit intovtsykun:masterfrom Feb 15, 2026
Merged
Conversation
Mirror repositories store metadata and zipballs on the local filesystem, which prevents running Packeton in stateless container deployments. When using S3 for regular package storage (`STORAGE_SOURCE=s3`), the `/data` directory still accumulates mirror data that cannot be shared across replicas. This change extends the existing Flysystem-based S3 storage abstraction to mirror repositories. Both metadata (packages.json, provider includes, package JSON files) and distribution archives are now stored in S3 when configured. For zipball storage, hash-based path sharding is implemented to optimize S3 performance. S3 partitions data by key prefix, so distributing files across prefixes like `ab/cd/...` prevents hot spots when mirroring large repositories like packagist.org. Local caching is optional and configurable via `MIRROR_METADATA_CACHE_DIR` and `MIRROR_DIST_CACHE_DIR` environment variables. When empty, all operations go directly to S3 for fully stateless operation. When set to `/tmp` paths, ephemeral caching improves read performance while maintaining statelessness across container restarts. The streaming fallback in `MirrorController` handles cases where local cache writes fail, ensuring zipball downloads still work by streaming directly from S3.
Contributor
Author
|
@vtsykun hey, I saw you are merging some stuff to the master, could you please check these PRs? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror repositories store metadata and zipballs on the local filesystem, which prevents running Packeton in stateless container deployments. When using S3 for regular package storage (
STORAGE_SOURCE=s3), the/datadirectory still accumulates mirror data that cannot be shared across replicas.This change extends the existing Flysystem-based S3 storage abstraction to mirror repositories. Both metadata (packages.json, provider includes, package JSON files) and distribution archives are now stored in S3 when configured.
For zipball storage, hash-based path sharding is implemented to optimize S3 performance. S3 partitions data by key prefix, so distributing files across prefixes like
ab/cd/...prevents hot spots when mirroring large repositories like packagist.org.Local caching is optional and configurable via
MIRROR_METADATA_CACHE_DIRandMIRROR_DIST_CACHE_DIRenvironment variables. When empty, all operations go directly to S3 for fully stateless operation. When set to/tmppaths, ephemeral caching improves read performance while maintaining statelessness across container restarts.The streaming fallback in
MirrorControllerhandles cases where local cache writes fail, ensuring zipball downloads still work by streaming directly from S3.Closes issue #304