Skip to content

Commit

Permalink
try github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
woodgear committed Jan 8, 2024
1 parent 95da764 commit 7905b41
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.0
87 changes: 87 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build

on:
pull_request:
branches:
- master
- release-*
paths-ignore:
- 'docs/**'
- '**.md'
push:
branches:
- master
- release-*
paths-ignore:
- 'docs/**'
- '**.md'

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
GO_VERSION: ''
GOSEC_VERSION: '2.18.2'
HELM_VERSION: v3.13.3
SUBMARINER_VERSION: '0.16.2'
jobs:
build-alb:
name: Build alb
runs-on: ubuntu-22.04
steps:
- uses: jlumbroso/[email protected]
with:
android: true
dotnet: true
haskell: true
docker-images: false
large-packages: false
tool-cache: false
swap-storage: false

- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: azure/setup-helm@v3
with:
version: '${{ env.HELM_VERSION }}'
- name: version
uses: HardNorth/[email protected]
with:
version-source: file
version-file: .github/VERSION
version-file-extraction-pattern: '(?<=version=).+'
- name: build
run: |
source ./scripts/alb-dev-actions.sh
export RELEASE_TAG=test
OPENRESTY_BASE=theseedoaa/alb-nginx-base:v1.22.0
GO_BUILD_BASE=golang:1.18.10-alpine3.16
RUN_BASE=alpine:3.17.6
# build images
docker buildx build --platform linux/amd64 -t alauda/alb:$RELEASE_TAG --build-arg VERSION=$RELEASE_TAG --build-arg RUN_BASE=$RUN_BASE --build-arg BUILD_BASE=$GO_BUILD_BASE -o type=docker -f ./Dockerfile .
docker pull $OPENRESTY_BASE
docker buildx build --platform linux/amd64 -t alauda/alb-nginx:$RELEASE_TAG --build-arg VERSION=$RELEASE_TAG --build-arg OPENRESTY_BASE=$OPENRESTY_BASE --build-arg BUILD_BASE=$GO_BUILD_BASE -o type=docker -f ./template/Dockerfile ./
docker images
docker save alauda/alb:$RELEASE_TAG > alb.tar
docker save alauda/alb-nginx:$RELEASE_TAG > alb-nginx.tar
ls
env
# build chart
alb-build-github-chart alauda/alb:$RELEASE_TAG alauda/alb-nginx:$RELEASE_TAG $RELEASE_TAG ./deploy/chart/alb ./alauda-alb2.tgz
- name: Upload alb images to artifact
uses: actions/upload-artifact@v3
with:
name: alb
path: alb.tar
- name: Upload alb-nginx images to artifact
uses: actions/upload-artifact@v3
with:
name: alb-nginx
path: alb-nginx.tar
- name: Upload chart's to artifact
uses: actions/upload-artifact@v3
with:
name: alb-chart
path: alauda-alb2.tgz
Empty file added .github/workflows/release.yaml
Empty file.
Empty file added .github/workflows/test.yaml
Empty file.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM build-harbor.alauda.cn/ops/golang:1.18-alpine3.16 AS builder
ARG BUILD_BASE=build-harbor.alauda.cn/ops/golang:1.18-alpine3.16
ARG RUN_BASE=build-harbor.alauda.cn/ops/alpine:3.17

FROM ${BUILD_BASE} AS builder

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
Expand All @@ -11,7 +14,7 @@ RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /out/migrate/init-port-info alauda.io/alb2/migrate/init-port-info
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /out/operator alauda.io/alb2/cmd/operator

FROM build-harbor.alauda.cn/ops/alpine:3.17 AS base
FROM $RUN_BASE AS base
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add --no-cache iproute2 jq libcap && rm -rf /usr/bin/nc

Expand Down
1 change: 1 addition & 0 deletions scripts/alb-dev-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source ./scripts/alb-test-actions.sh
source ./scripts/alb-lint-actions.sh
source ./scripts/alb-build-actions.sh
source ./scripts/alb-deploy-actions.sh
source ./scripts/alb-github-actions.sh
source ./template/actions/alb-nginx.sh

function alb-cleanup() {
Expand Down
12 changes: 12 additions & 0 deletions scripts/alb-github-actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
function alb-build-github-chart() {
# alb-build-github-chart alauda/alb:$RELEASE_TAG alauda/alb-nginx:$RELEASE_TAG ./chart/alb ./alb-chart.tar
local alb_image=$1
local nginx_image=$2
local chart_version=$3
local chart_dir=$4
local out_path=$5
helm package $chart_dir --version $chart_version
mv ./alauda-alb2-$chart_version.tgz $out_path
return
}
8 changes: 6 additions & 2 deletions template/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

ARG BUILD_BASE=build-harbor.alauda.cn/ops/golang:1.18-alpine3.16
ARG OPENRESTY_BASE=build-harbor.alauda.cn/3rdparty/alb-nginx:v1.22.0

# build nignx/openresty base image
FROM build-harbor.alauda.cn/ops/golang:1.18-alpine3.15 AS tweak_gen
FROM ${BUILD_BASE} AS tweak_gen
COPY ./ /alb/
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
Expand All @@ -10,7 +14,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositorie
RUN cd cmd/utils/tweak_gen && go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /alb/out/tweak_gen alauda.io/alb2/cmd/utils/tweak_gen
RUN ls -alh /alb/out/

FROM build-harbor.alauda.cn/3rdparty/alb-nginx:v1.22.0
FROM ${OPENRESTY_BASE}

# keep it as same as pkg/config/albrun.go
ENV OLD_CONFIG_PATH /etc/alb2/nginx/nginx.conf
Expand Down

0 comments on commit 7905b41

Please sign in to comment.