Skip to content

Commit

Permalink
Build docker images (#8)
Browse files Browse the repository at this point in the history
* ci(docker): build docker images and linux packages
  • Loading branch information
amine7536 authored Mar 12, 2021
1 parent a7f1ba0 commit a88f9e9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 16 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Cache go modules
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -50,6 +57,14 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Docker Login
if: success() && startsWith(github.ref, 'refs/tags/')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
echo "${DOCKER_TOKEN}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: success() && startsWith(github.ref, 'refs/tags/')
Expand Down
49 changes: 49 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,55 @@ changelog:
- Merge branch
- go mod tidy

nfpms:
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
homepage: https://github.com/pixelfactoryio/needle
description: Deliver Go binaries as fast and easily as possible
maintainer: Amine Benseddik <[email protected]>
license: MIT
vendor: pixelfactory.io
formats:
- apk
- deb
- rpm

dockers:
- image_templates:
- 'pixelfactory/needle:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use_buildx: true
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:
- 'pixelfactory/needle:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use_buildx: true
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"
goarch: arm64

docker_manifests:
- name_template: 'pixelfactory/needle:{{ .Tag }}'
image_templates:
- 'pixelfactory/needle:{{ .Tag }}-amd64'
- 'pixelfactory/needle:{{ .Tag }}-arm64'
- name_template: 'pixelfactory/needle:latest'
image_templates:
- 'pixelfactory/needle:{{ .Tag }}-amd64'
- 'pixelfactory/needle:{{ .Tag }}-arm64'

archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
Expand Down
21 changes: 5 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
FROM golang:1.15-alpine AS builder
FROM alpine:3.13

RUN apk --no-cache update && \
apk --no-cache upgrade && \
apk --no-cache add git build-base
COPY needle_*.apk /tmp/

WORKDIR /build
RUN apk add --allow-untrusted /tmp/needle_*.apk \
&& rm -fr /tmp/needle_*.apk

COPY . .

RUN go mod download

RUN make bin/needle

FROM alpine:3.12

COPY --from=builder /build/bin/needle /usr/bin/needle

ENTRYPOINT ["/usr/bin/needle"]
ENTRYPOINT ["/usr/local/bin/needle"]

0 comments on commit a88f9e9

Please sign in to comment.