Skip to content

Commit

Permalink
Implemented first version
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed May 21, 2024
0 parents commit 02bc021
Show file tree
Hide file tree
Showing 15 changed files with 1,337 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Fetch all tags
run: git fetch --force --tags
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
tags:
- v*
branches:
- main
pull_request:

name: run tests
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v3
- name: Run linters
uses: golangci/golangci-lint-action@v3

test:
strategy:
matrix:
go-version: [ '1.22.x' ]
os: [ 'ubuntu-latest', 'macos-latest' ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: go test -v ./...

# coverage:
# runs-on: ubuntu-latest
# steps:
# - name: Install Go
# if: success()
# uses: actions/setup-go@v2
# with:
# go-version: 1.15.x
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Calc coverage
# run: |
# go test -v -covermode=count -coverprofile=coverage.out ./...
# - name: Convert coverage.out to coverage.lcov
# uses: jandelgado/[email protected]
# - name: Coveralls
# uses: coverallsapp/[email protected]
# with:
# github-token: ${{ secrets.github_token }}
# path-to-lcov: coverage.lcov
#
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# devbox
.devbox

/tmp
69 changes: 69 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
main: ./cmd
archives:
- name_template: >-
{{ .ProjectName }}_
{{ .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
dockers:
- image_templates:
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/networkteam/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/networkteam/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- image_templates:
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-arm64v8
goarch: arm64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/networkteam/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/networkteam/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
docker_manifests:
- name_template: ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/networkteam/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/networkteam/{{ .ProjectName }}:{{ .Version }}-arm64v8
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM alpine:3.19
ENTRYPOINT ["/stacker"]
STOPSIGNAL SIGINT
COPY stacker /stacker
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 networkteam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stacker

A tool to rebase container (Docker) images instead of rebuilding them.

It is based around the idea of OCI annotations for base images to just change the layers of the base image if a newer version is available.

## Acknowledgements

This tool heavily uses https://github.com/google/go-containerregistry/tree/main/cmd/crane for the image manipulation.

## License

[MIT](./LICENSE)
Loading

0 comments on commit 02bc021

Please sign in to comment.