Skip to content

Commit

Permalink
add workflow for building and publishing builder image
Browse files Browse the repository at this point in the history
  • Loading branch information
rajrohanyadav committed Nov 14, 2024
1 parent 1675cf3 commit 87c0682
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build_publish_builder_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Push Builder Image

on:
push:
branches:
- main
- master
- feat/fips-image-and-workflow # for testing purposes

jobs:
build-and-push:
name: Build and Push Builder Image
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set version
id: set_version
run: |
VERSION="${{ github.run_number }}-$(date +'%Y%m%d%H%M%S')"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: build/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
49 changes: 49 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Use Ubuntu 16.04 as the base image
FROM ubuntu:16.04

# Define Go version
ARG GO_VERSION=1.23.2
ARG ARCH='amd64'
ARG GH_VERSION='2.61.0'

# Install dependencies
RUN apt-get update && apt-get install -y \
gnupg-agent \
unzip \
zip \
curl \
wget \
expect \
git \
tar \
gcc \
jq \
g++ \
gnupg2 \
gnupg-agent \
debsigs \
rpm \
build-essential \
software-properties-common \
python-software-properties \
gcc-arm-linux-gnueabi \
dpkg-sig \
gcc-aarch64-linux-gnu

# Install Go
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o go${GO_VERSION}.linux-${ARCH}.tar.gz && \
tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH}.tar.gz && \
rm go${GO_VERSION}.linux-${ARCH}.tar.gz

# Set Go environment variables
ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go"

# Optional: Set Go environment flags
ENV GOFLAGS="-buildvcs=false"

# Since the user does not match the owners of the repo "git rev-parse --is-inside-work-tree" fails and goreleaser does not populate projectName
# https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor
RUN git config --global --add safe.directory '*'
RUN curl -L https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.deb -o gh_${GH_VERSION}_linux_amd64.deb
RUN dpkg -i gh_${GH_VERSION}_linux_amd64.deb

0 comments on commit 87c0682

Please sign in to comment.