https://github.com/vdustr/g2d
Transform .gitignore into .dockerignore
https://github.com/vdustr/g2d
container deno docker dockerignore git gitignore linux macos podman windows
Last synced: about 1 year ago
JSON representation
Transform .gitignore into .dockerignore
- Host: GitHub
- URL: https://github.com/vdustr/g2d
- Owner: VdustR
- License: mit
- Created: 2021-10-09T07:16:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-25T11:35:00.000Z (over 4 years ago)
- Last Synced: 2025-03-25T08:51:22.439Z (about 1 year ago)
- Topics: container, deno, docker, dockerignore, git, gitignore, linux, macos, podman, windows
- Language: TypeScript
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# g2d
[](https://github.com/VdustR/g2d/actions/workflows/test.yml)
[](https://github.com/VdustR/g2d/actions/workflows/build.yml)
[](https://github.com/VdustR/g2d/actions/workflows/ghcr.yml)
Transform `.gitignore` into `.dockerignore`.
| `.gitignore` | `.dockerignore` |
| ------------ | --------------- |
| `!/` | `!` |
| `!` | `!**/` |
| `/` | - |
| - | `**/` |
## Download
Check [releases](https://github.com/VdustR/g2d/releases).
## Usage
`g2d` will detect the nearest `.gitignore` by default.
```sh
# stdout
g2d
# specific file
g2d foo/.gitignore
# export to ./.dockerignore
g2d -o .
# if foo is a directory
# .dockerignore would be exported to foo/.dockerignore
g2d -o foo
cat foo/.gitignore
# if foo is a file
# .dockerignore would be exported to foo
g2d -o foo
cat foo
# from stdin to stdout
cat .gitignore | g2d > .dockerignore
# more
g2d -h
```
## Install with Deno
```sh
# install from remote
deno install \
--unstable \
--allow-read \
--allow-write \
-n g2d \
https://deno.land/x/g2d/bin.ts
# install from local repo
git clone git@github.com:VdustR/g2d.git
deno install \
--unstable \
--allow-read \
--allow-write \
-n g2d \
bin.ts
# uninstall
rm $(which g2d)
```
## Deno Library
```ts
import g2b from "https://deno.land/x/g2d/mod.ts";
const gitignore = Deno.readTextFileSync(".gitignore");
const dockerignore = g2b(gitignore);
Deno.writeTextFileSync(".dockerignore", dockerignore);
```
## Container
Check [g2d container](https://github.com/VdustR/g2d/pkgs/container/g2d).
```bash
podman run --rm -it -v $(pwd):/repo g2d g2d /repo/.gitignore -o /repo
```
## Dev
```sh
deno run --unstable --allow-read --allow-write bin.ts
```
## Test
```sh
./scripts/test.sh
```
## Tested Dev Env
```
deno 1.19.1 (release, x86_64-unknown-linux-gnu)
v8 9.9.115.7
typescript 4.5.2
```
## License
MIT