Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karolyp/docker-tar-pusher
Push tar images into Docker registry from NodeJS without using the Docker Engine.
https://github.com/karolyp/docker-tar-pusher
docker docker-image docker-registry docker-registry-v2 docker-tar
Last synced: 24 days ago
JSON representation
Push tar images into Docker registry from NodeJS without using the Docker Engine.
- Host: GitHub
- URL: https://github.com/karolyp/docker-tar-pusher
- Owner: karolyp
- License: mit
- Created: 2021-05-28T23:12:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-16T15:05:18.000Z (about 2 years ago)
- Last Synced: 2024-10-01T15:53:54.510Z (about 1 month ago)
- Topics: docker, docker-image, docker-registry, docker-registry-v2, docker-tar
- Language: TypeScript
- Homepage:
- Size: 701 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-tar-pusher
[![build](https://github.com/karolyp/docker-tar-pusher/actions/workflows/node.js.yml/badge.svg)](https://github.com/karolyp/docker-tar-pusher/actions/workflows/node.js.yml)
With this library you can push tar Docker images directly to a Docker registry without the need of having them loaded into the Docker Engine, re-tagging and pushing.
The library uses [chunked upload](https://docs.docker.com/registry/spec/api/#pushing-an-image) to push the layers.
Supports HTTP Basic auth.
## How to use
First, you have to create a configuration object with the following properties:
- registryUrl: address of the registry
- tarball: absolute path to tar file
- chunkSize (optional): size of chunks, defaults to 10 MiB (10 \* 1024 \* 1024)
- logger (optional): specify custom applicationLogger, defaults to console.log
- sslVerify (optional): should reject invalid TLS certificates, defaults to true
- auth (optional): HTTP Basic auth containing the username and password, defaults to empty### Clean-up
After a successful upload, the library will take care about cleaning up the temporary files that have been created
during the process.
However, you might want to call this clean-up function on in one of your shutdown hooks in order to remove
any leftovers in case of a shutdown.## Examples
### Quickstart
```typescript
import {DockerTarPusher, DockerTarPusherOptions} from 'docker-tar-pusher';const options: DockerTarPusherOptions = {
registryUrl: 'http://localhost:5000',
tarball: 'path/to/file.tar'
};
const dockerTarPusher = new DockerTarPusher(options);await dockerTarPusher.pushToRegistry();
```### Complete example with custom logger
```typescript
import {DockerTarPusher, DockerTarPusherOptions, Logger} from 'docker-tar-pusher';const myLogger: Logger = {
error: (msg: string): void => {
console.log(`[ERROR] ${msg}`);
},
warn: (msg: string): void => {
console.log(`[WARN] ${msg}`);
},
info: (msg: string): void => {
console.log(`[INFO] ${msg}`);
},
debug: (msg: string): void => {
console.log(`[DEBUG] ${msg}`);
}
};const options: DockerTarPusherOptions = {
registryUrl: 'http://localhost:5000',
tarball: 'path/to/file.tar',
chunkSize: 8 * 1024 * 1024,
applicationLogger: myLogger,
sslVerify: false,
auth: {
username: 'testuser',
password: 'testpassword'
}
};
const dockerTarPusher = new DockerTarPusher(options);// Attaching clean-up logic to shutdown hook
process.on('SIGINT', () => {
dockerTarPusher.cleanUp();
});(async () => {
await dockerTarPusher.pushToRegistry();
})();
```## License
[MIT](LICENSE)
Inspired by [dockerregistrypusher](https://github.com/Razikus/dockerregistrypusher)