-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve output handling from commanands
- Loading branch information
Tomasz Gągor
committed
Dec 17, 2024
1 parent
eab0d8d
commit 951f4dc
Showing
8 changed files
with
219 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ __pycache__ | |
.venv | ||
*.pyc | ||
*.Dockerfile | ||
*.tar | ||
.poetry-version | ||
*.bak | ||
*.old | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package parser | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/rs/zerolog/log" | ||
"github.com/tgagor/template-dockerfiles/pkg/cmd" | ||
"github.com/tgagor/template-dockerfiles/pkg/util" | ||
) | ||
|
||
type DockerInspect []struct { | ||
Config struct { | ||
Env []string `json:"Env"` | ||
Cmd []string `json:"Cmd"` | ||
Volumes map[string]struct{} `json:"Volumes"` | ||
WorkingDir string `json:"WorkingDir"` | ||
Entrypoint []string `json:"Entrypoint"` | ||
Labels map[string]string `json:"Labels"` | ||
} `json:"Config"` | ||
} | ||
|
||
func inspectImg(image string) (DockerInspect, error) { | ||
out, err := cmd.New("docker").Arg("inspect").Arg("--format").Arg("json").Arg(image).Output() | ||
util.FailOnError(err) | ||
|
||
// Create a variable to hold the unmarshaled data | ||
var inspect DockerInspect | ||
|
||
// Unmarshal the JSON data into the DockerInspect structure | ||
|
||
if err := json.Unmarshal([]byte(out), &inspect); err != nil { | ||
log.Error().Err(err).Msg("Error parsing JSON.") | ||
os.Exit(1) | ||
} | ||
|
||
return inspect, nil | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM quay.io/centos/centos:{{ .centos }} | ||
|
||
# upgrade packages | ||
RUN dnf upgrade --setopt=install_weak_deps=False -y && \ | ||
dnf clean all && \ | ||
rm -rf /tmp/* && \ | ||
rm -rf /var/cache/yum && \ | ||
rm -rf /var/cache/dnf && \ | ||
find /var/log -type f -name '*.log' -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
registry: ghcr.io | ||
prefix: tgagor | ||
maintainer: Tomasz Gągor <https://gagor.pro> | ||
|
||
labels: | ||
org.opencontainers.image.licenses: GPL-2.0-only | ||
org.opencontainers.image.url: https://hub.docker.com/repository/docker/tgagor/centos/general | ||
org.opencontainers.image.documentation: https://github.com/tgagor/docker-centos/blob/master/README.md | ||
org.opencontainers.image.title: Weekly updated CentOS Docker images | ||
org.opencontainers.image.description: | | ||
Those images are just standard CentOS base images, but: | ||
1. With all the package updates installed weekly. | ||
2. Squashed to single layer for smaller size. | ||
images: | ||
centos: | ||
dockerfile: Dockerfile.tpl | ||
variables: | ||
centos: | ||
- stream9 | ||
- stream10 | ||
tags: | ||
- centos:{{ .centos }} | ||
- centos:{{ .centos | trimPrefix "stream" }} | ||
- centos:{{ .tag | splitList "-" | first }}-{{ .centos }} | ||
- centos:{{ .tag | splitList "-" | first }} | ||
- centos:{{ .centos }}-{{ .tag | splitList "-" | rest | first }} | ||
- centos:stream | ||
- centos:latest | ||
labels: | ||
org.opencontainers.image.base.name: quay.io/centos/centos:{{ .centos }} |