-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add docker support for proxy (#133)
* add docker * add GOPRIVATE * add GOPRIVATE * add go * add build in action * add build in action * add git configs * fix run
- Loading branch information
Showing
8 changed files
with
217 additions
and
6 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
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,117 @@ | ||
name: Release Operator Proxy | ||
on: | ||
push: | ||
tags: ["*"] | ||
workflow_dispatch: | ||
# pull_request: # for testing only | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
CARGO_TERM_COLOR: always | ||
# https://github.com/mozilla/sccache/releases | ||
SCCACHE_TAR_URL: https://github.com/mozilla/sccache/releases/download/v0.7.4/sccache-v0.7.4-x86_64-unknown-linux-musl.tar.gz | ||
SCCACHE_CACHE_SIZE: "3G" | ||
RUSTC_WRAPPER: sccache | ||
SUBWASM_VERSION: v0.20.0 | ||
CARGO_INCREMENTAL: "0" | ||
CARGO_NET_GIT_FETCH_WITH_CLI: true | ||
GOPRIVATE: github.com/alt-research/avs-generic-aggregator | ||
ECR_REPO: 305587085711.dkr.ecr.us-west-2.amazonaws.com/mach-operator-proxy | ||
PUB_REPO: public.ecr.aws | ||
|
||
jobs: | ||
build-docker-image: | ||
name: Build Docker Image and extract files | ||
runs-on: ["self-hosted", "linux", "x64", "ubuntu-latest"] | ||
steps: | ||
- name: Login to ECR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.ECR_REPO }} | ||
username: ${{ secrets.ECR_ACCESS_KEY_ID }} | ||
password: ${{ secrets.ECR_ACCESS_KEY }} | ||
|
||
- name: Login to public ECR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.PUB_REPO }} | ||
username: ${{ secrets.ECR_ACCESS_KEY_ID }} | ||
password: ${{ secrets.ECR_ACCESS_KEY }} | ||
|
||
- name: Checkout Sources | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
token: ${{ secrets.GIT_CREDENTIALS }} | ||
|
||
- uses: de-vri-es/setup-git-credentials@v2 | ||
with: | ||
credentials: https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_CREDENTIALS }}@github.com | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: docker-builder | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Prepare Environment Variables | ||
run: | | ||
echo "HOME=$HOME" | tee -a $GITHUB_ENV | ||
echo "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}" | tee -a $GITHUB_ENV | ||
echo "SHORT_SHA=${GITHUB_SHA::7}" | tee -a $GITHUB_ENV | ||
GIT_TAG=$(git tag --points-at HEAD) | ||
echo "GIT_TAG=$GIT_TAG" | tee -a $GITHUB_ENV | ||
GIT_BRANCH=$(git branch --show-current) | ||
echo "GIT_BRANCH=$GIT_BRANCH" | tee -a $GITHUB_ENV | ||
echo "REF_NAME=$(echo ${GIT_TAG:-$GITHUB_REF_NAME} | sed 's/[^a-zA-Z0-9._]/-/g')" | tee -a $GITHUB_ENV | ||
- run: cat $HOME/.gitconfig && cat $XDG_CONFIG_HOME/git/credentials | ||
|
||
- name: Set up Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21.1' # The Go version to download (if necessary) and use. | ||
- run: go version | ||
- run: go mod download && go mod tidy && go mod verify | ||
- run: go build -o ./bin/mach-operator-proxy ./generic-operator-proxy/cmd | ||
|
||
- name: Extract operator metadata (tags, labels) for Docker | ||
id: operator-meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.ECR_REPO }} | ||
${{ env.PUB_REPO }}/altlayer/mach-operator-proxy | ||
flavor: | | ||
prefix= | ||
suffix= | ||
tags: | | ||
type=sha,format=short,prefix= | ||
type=ref,event=branch | ||
type=ref,event=branch,suffix=-${{ github.run_number }} | ||
type=ref,event=tag | ||
type=raw,value=${{ env.REF_NAME }},enable=${{ github.event_name == 'pull_request' }} | ||
type=raw,value=${{ env.GIT_BRANCH }},enable=${{ env.GIT_BRANCH != '' }} | ||
type=raw,value=latest,enable=${{ env.GIT_BRANCH == 'master' }} | ||
- name: Build operator docker with cache and push images | ||
uses: docker/build-push-action@v5 | ||
id: docker_operator_build | ||
with: | ||
context: . | ||
builder: ${{ steps.docker-builder.outputs.name }} | ||
target: app | ||
push: ${{ github.event_name != 'pull_request' }} | ||
provenance: false | ||
cache-from: | | ||
type=registry,ref=${{ env.ECR_REPO }}:latest | ||
type=registry,ref=${{ env.ECR_REPO }}:${{ env.REF_NAME }} | ||
secret-files: | | ||
git_config=${{ env.HOME }}/.gitconfig | ||
git_credentials=${{ env.XDG_CONFIG_HOME }}/git/credentials | ||
file: ./ops/proxy.Dockerfile | ||
labels: ${{ steps.operator-meta.outputs.labels }} | ||
tags: ${{ steps.operator-meta.outputs.tags }} | ||
|
||
|
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
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
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
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
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
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,40 @@ | ||
FROM golang:1.21-bullseye as build | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY go.mod go.sum ./ | ||
|
||
ENV GOPRIVATE=github.com/alt-research/avs-generic-aggregator | ||
ARG XDG_CONFIG_HOME=/root/.config/ | ||
|
||
RUN \ | ||
--mount=type=secret,id=gh_hosts,target=/root/.config/gh/hosts.yml \ | ||
--mount=type=secret,id=git_config,target=/root/.gitconfig \ | ||
--mount=type=secret,id=git_credentials,target=/root/.git-credentials \ | ||
<<EOF | ||
set -ex | ||
go mod download && go mod tidy && go mod verify | ||
EOF | ||
|
||
COPY . . | ||
|
||
WORKDIR /usr/src/app/generic-operator-proxy/cmd | ||
|
||
RUN \ | ||
--mount=type=secret,id=gh_hosts,target=/root/.config/gh/hosts.yml \ | ||
--mount=type=secret,id=git_config,target=/root/.gitconfig \ | ||
--mount=type=secret,id=git_credentials,target=/root/.git-credentials \ | ||
<<EOF | ||
set -ex | ||
go build -v -o /usr/local/bin/generic-operator-proxy ./... | ||
EOF | ||
|
||
FROM debian:bullseye as app | ||
COPY --from=build /usr/local/bin/generic-operator-proxy /usr/local/bin/mach-operator-proxy | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y curl sudo daemontools jq ca-certificates && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENTRYPOINT [ "mach-operator-proxy"] |