Skip to content

Commit

Permalink
Add missing Dockerfile and adapt the version passed to operator
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Jul 11, 2022
1 parent 01c7190 commit 66f27eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Export tag
id: export_tag
run: |
git describe --abbrev=0 --tags
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"`
echo "::set-output name=operator_tag::$TAG"
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
Expand All @@ -37,4 +43,6 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
target: ros-operator
push: true
push: true
build-args: |
VERSION=${{ steps.export_tag.outputs.operator_tag }}
6 changes: 4 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
id: export_tag
run: |
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"`
echo "::set-output name=ros_tag::$TAG"
echo "::set-output name=operator_tag::$TAG"
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
quay.io/costoolkit/elemental-operator-ci
tags: |
type=sha,format=short,prefix=${{ steps.export_tag.outputs.ros_tag }}-
type=sha,format=short,prefix=${{ steps.export_tag.outputs.operator_tag }}-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -48,6 +48,8 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ steps.export_tag.outputs.operator_tag }}
- name: Make chart
run: make chart
- name: Set chart output
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ builds:
- CGO_ENABLED=0
ldflags:
- -extldflags -static -s
- -X github.com/rancher/elemental-operator/version.Version={{.Tag}}
goos:
- linux
goarch:
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.17-alpine as build
ENV CGO_ENABLED=0
WORKDIR /src
COPY go.mod go.sum /src/
RUN go mod download
COPY main.go /src/
COPY pkg /src/pkg
COPY cmd /src/cmd
# Set arg/env after go mod download, otherwise we invalidate the cached layers due to the commit changing easily
ARG VERSION=0.0.0
ENV VERSION=${VERSION}
RUN go build -ldflags "-extldflags -static -s -X 'github.com/rancher/elemental-operator/version.Version=$(VERSION)'" -o /usr/sbin/rancheros-operator

FROM scratch as ros-operator
COPY --from=build /usr/sbin/rancheros-operator /usr/sbin/rancheros-operator

0 comments on commit 66f27eb

Please sign in to comment.