-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI/CD: Remove build_dev workflow and optimize Dockerfile
- Comment out entire build_dev.yml workflow - Refactor Dockerfile for multi-arch support and local builds - Optimize image size and streamline container setup
- Loading branch information
Showing
3 changed files
with
88 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
name: Build and Test Gordon | ||
|
||
on: | ||
push: | ||
branches: | ||
- "dev" | ||
|
||
jobs: | ||
build-and-test: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
env: | ||
KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | ||
|
||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23" | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
# - name: Run tests | ||
# run: go test ./... | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: ko-build/setup-ko@v0.6 | ||
|
||
- name: Build and push with ko | ||
run: | | ||
ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev | ||
# name: Build and Test Gordon | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - "dev" | ||
|
||
# jobs: | ||
# build-and-test: | ||
# name: Build and Test | ||
# runs-on: ubuntu-latest | ||
# permissions: | ||
# contents: read | ||
# packages: write | ||
# env: | ||
# KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | ||
|
||
# steps: | ||
# - uses: actions/setup-go@v4 | ||
# with: | ||
# go-version: "1.23" | ||
|
||
# - uses: actions/checkout@v3 | ||
|
||
# # - name: Run tests | ||
# # run: go test ./... | ||
|
||
# - name: Log in to GitHub Container Registry | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.actor }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - uses: ko-build/setup-ko@v0.6 | ||
|
||
# - name: Build and push with ko | ||
# run: | | ||
# ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
# Use a minimal base image | ||
FROM alpine | ||
# Install ca-certificates bundle | ||
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* | ||
# Copy the binary | ||
COPY gordon /gordon | ||
# Copy other necessary files | ||
COPY .iscontainer / | ||
# Start from scratch | ||
FROM alpine:latest | ||
|
||
ARG ARCH | ||
|
||
# Copy the pre-built binary for the specific architecture | ||
COPY dist/gordon-linux-${ARCH} /gordon | ||
# Create the .iscontainer file | ||
RUN touch /.iscontainer | ||
|
||
# Set the entrypoint | ||
ENTRYPOINT ["/gordon"] | ||
|
||
# Default command | ||
CMD ["serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
REPO="ghcr.io/bnema/gordon" | ||
TAG="dev" | ||
DIST_DIR="./dist" | ||
|
||
# Ensure dist directory exists | ||
mkdir -p $DIST_DIR | ||
|
||
# Build Go binaries for multiple platforms with CGO_ENABLED=0 | ||
echo "Building Go binaries..." | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./cmd/cli | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./cmd/cli | ||
|
||
# Build Docker images for each architecture | ||
echo "Building Docker images..." | ||
docker build -t $REPO:${TAG}-amd64 --build-arg ARCH=amd64 -f Dockerfile . | ||
docker build -t $REPO:${TAG}-arm64v8 --build-arg ARCH=arm64 -f Dockerfile . | ||
|
||
# Push images | ||
echo "Pushing Docker images..." | ||
docker push $REPO:${TAG}-amd64 | ||
docker push $REPO:${TAG}-arm64v8 | ||
|
||
# Create and push multi-arch manifest | ||
echo "Creating and pushing multi-arch manifest..." | ||
docker manifest create $REPO:$TAG \ | ||
$REPO:${TAG}-amd64 \ | ||
$REPO:${TAG}-arm64v8 \ | ||
--amend | ||
|
||
# Annotate the arm64 image with variant information | ||
docker manifest annotate $REPO:$TAG \ | ||
$REPO:${TAG}-arm64v8 --arch arm64 --variant v8 | ||
|
||
docker manifest push $REPO:$TAG |