Skip to content

Commit

Permalink
Add workflow to track and customize golang:1.21-bullseye
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmccune committed Nov 8, 2023
0 parents commit 07f7998
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Golang

on:
workflow_dispatch:
schedule:
- cron: "0 1 * * *" # 1AM UTC, 6PM PST

jobs:
git:
runs-on: [dev-runners]
steps:
- name: Checkout
uses: actions/checkout@v4
aws:
runs-on: [dev-runners]
permissions:
id-token: write # Necessary to get aws creds via oidc token exchange
contents: read
steps:
- name: AWS Credentials
id: login-aws
uses: aws-actions/configure-aws-credentials@v4
with:
# Defined at https://github.com/holos-run/holos-infra/blob/main/terraform/projects/nonprod-holos/shared_services/aws/github_oidc/main.tf#L90-L106
role-to-assume: arn:aws:iam::271053619184:role/gha-app-role
aws-region: us-east-2
output-credentials: true
- name: AWS ECR Credentials
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Docker Login
id: docker-login
run: |
echo -n ${{ steps.login-ecr.outputs.docker_password_271053619184_dkr_ecr_us_east_2_amazonaws_com }} | docker login --password-stdin --username ${{ steps.login-ecr.outputs.docker_username_271053619184_dkr_ecr_us_east_2_amazonaws_com }} ${{ steps.login-ecr.outputs.registry }}
echo "docker-config=$(cat ~/.docker/config.json | base64 -w 0)" >> $GITHUB_OUTPUT
outputs:
registry: ${{ steps.login-ecr.outputs.registry }}
docker-config: ${{ steps.docker-login.outputs.docker-config }}
kaniko:
needs: [git, aws]
runs-on: [dev-runners]
container:
image: gcr.io/kaniko-project/executor:v1.17.0-debug
permissions:
contents: read # read the repository
steps:
- name: Build and push container image
run: |
# Kaniko
echo -n ${{ needs.aws.outputs.docker-config }} | base64 -d > /kaniko/.docker/config.json
# Configure git credentials to access github private repositories.
export GIT_USERNAME='holos-server-go'
export GIT_PASSWORD='${{ secrets.GITHUB_TOKEN }}'
# Build and push
/kaniko/executor --dockerfile=golang/Dockerfile \
--context='${{ github.repositoryUrl }}#${{ needs.git.outputs.sha }}' \
--destination=${{ needs.aws.outputs.registry }}/holos-run/container-images/golang:1.21-bullseye
--push-retry 5 \
--image-name-with-digest-file /workspace/image-digest.txt
# Make this an artifact?
cat /workspace/image-digest.txt
20 changes: 20 additions & 0 deletions golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM public.ecr.aws/docker/library/golang:1.21-bullseye AS final

# Install NodeJS 20
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" \
| tee /etc/apt/sources.list.d/nodesource.list

# Install tools
RUN apt-get -qq -y update && \
apt-get -qq -y install \
nodejs \
git \
curl \
sqlite

RUN curl -fsSL -o /bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn-1.22.19.js && \
chmod a+x /bin/yarn

RUN groupadd --gid 8192 app && useradd -c "App" -m --uid 8192 --gid 8192 app

0 comments on commit 07f7998

Please sign in to comment.