https://github.com/kdwils/dockerfile
golang package to help parse and modify dockerfile contents
https://github.com/kdwils/dockerfile
dockerfile golang parser
Last synced: 5 months ago
JSON representation
golang package to help parse and modify dockerfile contents
- Host: GitHub
- URL: https://github.com/kdwils/dockerfile
- Owner: kdwils
- Created: 2023-09-29T21:43:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-01T21:50:09.000Z (over 2 years ago)
- Last Synced: 2024-06-19T21:55:28.548Z (about 2 years ago)
- Topics: dockerfile, golang, parser
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dockerfile
Dockerfile is a package that provides a methods on parsing and updating dockerfile commands. The initial intent of this package was to provide an interface to update base image tags of dockerfiles in a programmatic way. This could be used for automated updates to fix image vulnerabilites, mass image updates, etc.
Behind the scenes, this package is wrapped around buildkit's dockerfile parser, and provides methods to make modifying a dockerfile easier.
# Usage
Example of how to parse the contents of a dockerfile
```golang
import (
"bytes"
"io"
"log"
"os"
"github.com/kdwils/dockerfile"
)
b, err := os.ReadFile("Dockerfile")
if err != nil {
// handle err
}
d, err := dockerfile.ParseFromReader(bytes.NewReder(b))
if err != nil {
// handle err
}
err = d.WriteContents(os.Stdout)
if err != nil {
// handler err
}
```