Skip to content

Commit

Permalink
Release v0.0.1 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
arybolovlev authored Apr 13, 2023
1 parent e3cc9d0 commit 4e0d1c9
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 93 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/docker-image-pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Pre-build Docker Image

on:
push:
branches:
- 'release/v*'

permissions:
# Allow creating GitHub release
contents: write

env:
DOCKER_HUB_REPO: arybolovlev/docker-operator
RELEASE_NOTES: /tmp/release-notes.txt

jobs:
pre-release-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
id: golang
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Docker image metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_HUB_REPO }}
tags: |
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
# Due to the Docker Buildx limitation only one platrom can be here.
platforms: amd64

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

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
build-contexts: |
golang=docker-image://golang:${{ steps.golang.outputs.go-version }}
# Due to the Docker Buildx limitation only one platrom can be here.
platforms: linux/amd64
push: false
load: true
tags: ${{ steps.meta.outputs.tags }}
4 changes: 2 additions & 2 deletions .github/workflows/docker-image-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build and Publish Docker Image

on:
push:
branches:
- 'release/v*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
# Allow creating GitHub release
Expand Down
16 changes: 2 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
## 0.0.8 (December 6, 2022)
## 0.0.1 (April 13, 2023)

🐛 BUG FIXES:

* Fix more issues.

## 0.0.7 (November 25, 2022)

🐛 BUG FIXES:

* Fix more issues.

## 0.0.6 (November 22, 2022)

* Fix concurrency issue.
* Fix a bug.
96 changes: 20 additions & 76 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,92 +1,36 @@
# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
#
# Every target has a BIN_NAME argument that must be provided via --build-arg=BIN_NAME=<name>
# when building.
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

ARG GO_VERSION=1.20

# ===================================
#
# Non-release images.
#
# ===================================


# dev-builder compiles the binary
# -----------------------------------
FROM golang:$GO_VERSION as dev-builder

ARG BIN_NAME
# Build the manager binary
FROM golang:1.20 as builder
ARG TARGETOS
ARG TARGETARCH

ENV BIN_NAME=$BIN_NAME

WORKDIR /build

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -trimpath -o $BIN_NAME main.go

# dev runs the binary from devbuild
# -----------------------------------
FROM gcr.io/distroless/static:nonroot as dev

ARG BIN_NAME
ARG PRODUCT_VERSION

ENV BIN_NAME=$BIN_NAME

LABEL version=$PRODUCT_VERSION
# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -trimpath -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=dev-builder /build/$BIN_NAME .
USER 65532:65532

ENTRYPOINT ["/$BIN_NAME"]

# ===================================
#
# Release images.
#
# ===================================


# default release image
# -----------------------------------
FROM gcr.io/distroless/static:nonroot AS release-default

ARG BIN_NAME
ARG PRODUCT_VERSION
ARG PRODUCT_REVISION
ARG PRODUCT_NAME=$BIN_NAME
ARG TARGETOS
ARG TARGETARCH

ENV BIN_NAME=$BIN_NAME

LABEL maintainer="Team Terraform Ecosystem - Kubernetes <team-tf-k8s@hashicorp.com>"
LABEL version=$PRODUCT_VERSION
LABEL revision=$PRODUCT_REVISION

COPY LICENSE /licenses/copyright.txt
COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /bin/

COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/$BIN_NAME"]

# ===================================
#
# Set default target to 'dev'.
#
# ===================================
FROM dev
ENTRYPOINT ["/manager"]
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.13
0.0.1

0 comments on commit 4e0d1c9

Please sign in to comment.