From f83c8e963f952761dcc27c38e52af4a74200b4ca Mon Sep 17 00:00:00 2001 From: k1LoW Date: Thu, 4 Mar 2021 17:15:25 +0900 Subject: [PATCH] Add dockers: setting to .goreleaser.yml --- .goreleaser.yml | 129 +++++++++++++++++++++++------------------- Dockerfile | 12 ++++ README.md | 6 ++ go.mod | 1 - scripts/entrypoint.sh | 3 + 5 files changed, 93 insertions(+), 58 deletions(-) create mode 100644 Dockerfile create mode 100644 scripts/entrypoint.sh diff --git a/.goreleaser.yml b/.goreleaser.yml index f7a6c60b..e3c13dc5 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,46 +3,46 @@ before: - go mod download - go mod tidy builds: -- - id: ndiag-darwin - hooks: - pre: packr2 - post: packr2 clean - ldflags: - - -s -w -X github.com/k1LoW/ndiag.version={{.Version}} -X github.com/k1LoW/ndiag.commit={{.FullCommit}} -X github.com/k1LoW/ndiag.date={{.Date}} -X github.com/k1LoW/ndiag/version.Version={{.Version}} - env: - - CGO_ENABLED=1 - goos: - - darwin - goarch: - - amd64 -- - id: ndiag-linux - hooks: - pre: packr2 - post: packr2 clean - ldflags: - - -s -w -X github.com/k1LoW/ndiag.version={{.Version}} -X github.com/k1LoW/ndiag.commit={{.FullCommit}} -X github.com/k1LoW/ndiag.date={{.Date}} -X github.com/k1LoW/ndiag/version.Version={{.Version}} - - -linkmode external - - -extldflags '-static' - env: - - CGO_ENABLED=1 - - CC=/usr/local/bin/x86_64-linux-musl-cc # brew install FiloSottile/musl-cross/musl-cross - goos: - - linux - goarch: - - amd64 + - + id: ndiag-darwin + hooks: + pre: packr2 + post: packr2 clean + ldflags: + - -s -w -X github.com/k1LoW/ndiag.version={{.Version}} -X github.com/k1LoW/ndiag.commit={{.FullCommit}} -X github.com/k1LoW/ndiag.date={{.Date}} -X github.com/k1LoW/ndiag/version.Version={{.Version}} + env: + - CGO_ENABLED=1 + goos: + - darwin + goarch: + - amd64 + - + id: ndiag-linux + hooks: + pre: packr2 + post: packr2 clean + ldflags: + - -s -w -X github.com/k1LoW/ndiag.version={{.Version}} -X github.com/k1LoW/ndiag.commit={{.FullCommit}} -X github.com/k1LoW/ndiag.date={{.Date}} -X github.com/k1LoW/ndiag/version.Version={{.Version}} + - -linkmode external + - -extldflags '-static' + env: + - CGO_ENABLED=1 + - CC=/usr/local/bin/x86_64-linux-musl-cc # brew install FiloSottile/musl-cross/musl-cross + goos: + - linux + goarch: + - amd64 archives: -- - id: ndiag-archive - name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - format_overrides: - - goos: darwin - format: zip - files: - - CREDITS - - README.md - - CHANGELOG.md + - + id: ndiag-archive + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + format_overrides: + - goos: darwin + format: zip + files: + - CREDITS + - README.md + - CHANGELOG.md checksum: name_template: 'checksums.txt' snapshot: @@ -54,30 +54,45 @@ changelog: exclude: - '^docs:' - '^test:' +dockers: + - + goos: linux + goarch: amd64 + image_templates: + - 'ghcr.io/k1low/ndiag:v{{ .Version }}' + - 'ghcr.io/k1low/ndiag:latest' + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + extra_files: + - scripts/entrypoint.sh brews: -- - name: ndiag - tap: - owner: k1LoW - name: homebrew-tap - commit_author: - name: k1LoW - email: k1lowxb@gmail.com - homepage: https://github.com/k1LoW/ndiag - description: 'ndiag is a high-level architecture diagramming/documentation tool.' - license: MIT - install: | - system './ndiag', 'completion', 'bash', '--out', 'ndiag.bash' - system './ndiag', 'completion', 'zsh', '--out', 'ndiag.zsh' - bin.install 'ndiag' - bash_completion.install 'ndiag.bash' => 'ndiag' - zsh_completion.install 'ndiag.zsh' => '_ndiag' + - + name: ndiag + tap: + owner: k1LoW + name: homebrew-tap + commit_author: + name: k1LoW + email: k1lowxb@gmail.com + homepage: https://github.com/k1LoW/ndiag + description: 'ndiag is a high-level architecture diagramming/documentation tool.' + license: MIT + install: | + system './ndiag', 'completion', 'bash', '--out', 'ndiag.bash' + system './ndiag', 'completion', 'zsh', '--out', 'ndiag.zsh' + bin.install 'ndiag' + bash_completion.install 'ndiag.bash' => 'ndiag' + zsh_completion.install 'ndiag.zsh' => '_ndiag' nfpms: - id: ndiag-nfpms file_name_template: "{{ .ProjectName }}_{{ .Version }}-1_{{ .Arch }}" builds: - - ndiag-linux + - ndiag-linux homepage: https://github.com/k1LoW/ndiag maintainer: Ken'ichiro Oyama description: ndiag is a high-level architecture diagramming/documentation tool. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f42344f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.16-alpine + +RUN apk add --no-cache bash + +ENTRYPOINT ["/entrypoint.sh"] +CMD [ "-h" ] + +COPY scripts/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +COPY ndiag_*.apk /tmp/ +RUN apk add --allow-untrusted /tmp/ndiag_*.apk diff --git a/README.md b/README.md index dcd335af..c7f151dd 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,9 @@ Download binary from [releases page](https://github.com/k1LoW/ndiag/releases) ```console $ go get github.com/k1LoW/ndiag ``` + +**docker:** + +```console +$ docker pull ghcr.io/k1low/ndiag:latest +``` diff --git a/go.mod b/go.mod index e9cc449f..99508175 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 github.com/olekukonko/tablewriter v0.0.4 github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c - github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.1.1 github.com/stoewer/go-strcase v1.2.0 ) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 00000000..77bb0414 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +ndiag $@