Skip to content

Commit

Permalink
CI/CD: Dockerfile & goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
anrs committed Feb 20, 2022
1 parent 570fee8 commit fa8b494
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: docker-image

on:
push:
branches:
- master
tags:
- v*

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v2

- name: build and push to docker hub
uses: docker/build-push-action@v1
with:
repository: projecteru2/yavirt
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag_with_ref: true
tag_with_sha: false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
cscope.*
vendor/
vendor/
dist/
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
before:
hooks:
- go mod download

builds:
- main: ./yavirtd.go
id: "yavirtd"
binary: yavirtd
env:
- CGO_ENABLED=1
ldflags:
- -s -w
- -X "github.com/projecteru2/yavirt/ver.Git={{.Commit}}"
- -X "github.com/projecteru2/yavirt/ver.Compile={{.Env.GOVERSION}}"
- -X "github.com/projecteru2/yavirt/ver.Date={{.Date}}"
goos:
- linux
goarch:
- amd64

- main: ./ctl/ctl.go
id: "yavirtctl"
binary: yavirtctl
env:
- CGO_ENABLED=1
ldflags:
- -s -w
- -X "github.com/projecteru2/yavirt/ver.Git={{.Commit}}"
- -X "github.com/projecteru2/yavirt/ver.Compile={{.Env.GOVERSION}}"
- -X "github.com/projecteru2/yavirt/ver.Date={{.Date}}"
goos:
- linux
goarch:
- amd64

archives:
- name_template: "{{.ProjectName}}-{{.Tag}}-{{.Env.DISTRO}}"

checksum:
name_template: "{{.ProjectName}}-{{.Tag}}-{{.Env.DISTRO}}.checksums"

release:
name_template: "{{.Tag}}"

snapshot:
name_template: "{{.Tag}}-{{.Env.DISTRO}}"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^(?i)merge branch'
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM projecteru2/yavirt:prebuild AS BUILD

# make binary
RUN git clone https://github.com/projecteru2/yavirt.git /go/src/github.com/projecteru2/yavirt
WORKDIR /go/src/github.com/projecteru2/yavirt
ARG KEEP_SYMBOL
RUN make deps && make && ./bin/yavirtd --version

FROM alpine:latest

RUN mkdir /etc/yavirt/
LABEL ERU=1
COPY --from=BUILD /go/src/github.com/projecteru2/yavirt/bin/yavirtd /usr/bin/yavirtd
COPY --from=BUILD /go/src/github.com/projecteru2/yavirt/bin/yavirtctl /usr/bin/yavirtctl
COPY --from=BUILD /go/src/github.com/projecteru2/yavirt/virt/template/disk.xml /etc/yavirt/disk.xml
COPY --from=BUILD /go/src/github.com/projecteru2/yavirt/virt/template/guest.xml /etc/yavirt/guest.xml

0 comments on commit fa8b494

Please sign in to comment.