Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container image building and publishing #23

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.17.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to lock this?

- name: lint
run: make lint
- name: test
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Release
on:
push:
tags:
- "*"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.5
- name: Login to quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ ipxe-*.tar.gz

# added by lint-install
out/

dist/
77 changes: 77 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
flags: -trimpath
ldflags: '-s -w -extldflags "-static"'
main: ./cmd/
goos:
- linux
- darwin
goarch:
- amd64
- arm64
- arm
archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
dockers:
- image_templates:
- "quay.io/tinkerbell/ipxedust:{{ .Version }}-amd64"
use: buildx
dockerfile: Dockerfile.goreleaser
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
- image_templates:
- "quay.io/tinkerbell/ipxedust:{{ .Version }}-arm64"
use: buildx
goarch: arm64
dockerfile: Dockerfile.goreleaser
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm64"
- image_templates:
- "quay.io/tinkerbell/ipxedust:{{ .Version }}-arm"
use: buildx
goarch: arm
goarm: "6"
dockerfile: Dockerfile.goreleaser
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm/v6"
docker_manifests:
- name_template: quay.io/tinkerbell/ipxedust:{{ .Version }}
image_templates:
- quay.io/tinkerbell/ipxedust:{{ .Version }}-amd64
- quay.io/tinkerbell/ipxedust:{{ .Version }}-arm64
- quay.io/tinkerbell/ipxedust:{{ .Version }}-arm
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.17.5 as builder

WORKDIR /code
COPY go.mod go.sum /code/
RUN go mod download

COPY . /code
RUN CGO_ENABLED=0 make build

FROM scratch

COPY --from=builder /code/bin/ipxedust-linux /ipxedust
EXPOSE 69/udp
EXPOSE 8080/tcp
ENV IPXE_TFTP_SINGLE_PORT=TRUE

ENTRYPOINT ["/ipxedust"]
8 changes: 8 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM scratch

COPY ipxedust /ipxedust
EXPOSE 69/udp
EXPOSE 8080/tcp
ENV IPXE_TFTP_SINGLE_PORT=TRUE

ENTRYPOINT ["/ipxedust"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OSFLAG:=$(shell go env GOHOSTOS)
BINARY:=ipxe
BINARY:=ipxedust
IPXE_BUILD_SCRIPT:=binary/script/build_ipxe.sh
IPXE_NIX_SHELL:=binary/script/shell.nix

Expand Down Expand Up @@ -56,3 +56,7 @@ ifeq (${OSFLAG},linux)
else
@$(MAKE) build-darwin
endif

.PHONY: build-image
build-image: ## Build the container image
docker build -t ${BINARY}:latest .
jacobweinstock marked this conversation as resolved.
Show resolved Hide resolved