Skip to content

Commit

Permalink
🚀 migrate commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Apr 8, 2024
1 parent bdbf917 commit 881262c
Show file tree
Hide file tree
Showing 56 changed files with 7,302 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# [cuongdm] for rosie machine
GO_CMD=/home/cuongdm/sdk/go1.21.5/bin/go
43 changes: 43 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create and publish a Docker image

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 16 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Docker Image CI

on:
push:
branches: [ "main", "dev" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
22 changes: 22 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# golangci-lint run
name: golangci-lint
on:
push:
branches:
- dev
- main

jobs:
golangci:
name: lint-codebase
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.20"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
args: --timeout 15m0s --verbose --out-${NO_FUTURE}format tab
19 changes: 19 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# govulncheck ./...
name: govulncheck
on:
push:
branches:
- "dev"
- "main"

jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Scan for Vulnerabilities in Code
uses: golang/govulncheck-action@v1
with:
go-version-input: 1.21.9
go-package: ./...
64 changes: 64 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
# golangci-lint run ./...
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
push:
branches: ["dev", "main"]

###############
# Set the Job #
###############
permissions: {}

jobs:
build:
# Name the Job
permissions:
contents: read # to fetch code (actions/checkout)
statuses: write # to mark status of each linter run (github/super-linter)

name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: super-linter/[email protected]
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: dev
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: "."
# MARKDOWN_CONFIG_FILE: .markdownlint.yml
VALIDATE_MARKDOWN: true
VALIDATE_BASH: true
26 changes: 26 additions & 0 deletions .github/workflows/readme-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint plugin readmes
on:
push:
branches:
- dev
- main

jobs:
run-readme-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21.9"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42
with:
base_sha: ${{ github.event.pull_request.base.sha }}
files: ./plugins/**/README.md
- name: Run readme linter on changed files
if: steps.changed-files.outputs.any_changed == 'true'
run: go run ./tools/readme_linter ${{ steps.changed-files.outputs.all_changed_files }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ rad.json
*.flf
#Test results file
TestResults.xml
.idea

.idea
/vngcloud-controller-manager
/vngcloud-ingress-controller
.go
105 changes: 105 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

################################################################################
## BUILD ARGS ##
################################################################################
# This build arg allows the specification of a custom Golang image.
ARG GOLANG_IMAGE=vcr.vngcloud.vn/81-vks-public/golang:1.21.9

# The distroless image on which the CPI manager image is built.
#
# Please do not use "latest". Explicit tags should be used to provide
# deterministic builds. Follow what kubernetes uses to build
# kube-controller-manager, for example for 1.27.x:
# https://github.com/kubernetes/kubernetes/blob/release-1.27/build/common.sh#L99
ARG DISTROLESS_IMAGE=vcr.vngcloud.vn/81-vks-public/go-runner:v2.3.1-go1.21.5-bookworm.0

# We use Alpine as the source for default CA certificates and some output
# images
ARG ALPINE_IMAGE=vcr.vngcloud.vn/81-vks-public/alpine:3.17.5

# cinder-csi-plugin uses Debian as a base image
ARG DEBIAN_IMAGE=vcr.vngcloud.vn/81-vks-public/debian-base:bullseye-v1.4.3

################################################################################
## BUILD STAGE ##
################################################################################

# Build an image containing a common ca-certificates used by all target images
# regardless of how they are built. We arbitrarily take ca-certificates from
# the amd64 Alpine image.
FROM --platform=linux/amd64 ${ALPINE_IMAGE} as certs
RUN apk add --no-cache ca-certificates


# Build all command targets. We build all command targets in a single build
# stage for efficiency. Target images copy their binary from this image.
# We use go's native cross compilation for multi-arch in this stage, so the
# builder itself is always amd64
FROM --platform=linux/amd64 ${GOLANG_IMAGE} as builder

ARG GOPROXY=https://goproxy.io,direct
ARG TARGETOS
ARG TARGETARCH
ARG VERSION

WORKDIR /build

COPY Makefile go.mod go.sum ./
COPY cmd/ cmd/
COPY pkg/ pkg/
RUN make build GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOPROXY=${GOPROXY} VERSION=${VERSION}
# COPY vngcloud-controller-manager ./vngcloud-controller-manager
# COPY vngcloud-ingress-controller ./vngcloud-ingress-controller
# RUN chmod +x ./vngcloud-controller-manager ./vngcloud-ingress-controller


################################################################################
## TARGET IMAGES ##
################################################################################

##
## vngcloud-controller-manager
##
FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as vngcloud-controller-manager

COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /build/vngcloud-controller-manager /bin/vngcloud-controller-manager

LABEL name="vngcloud-controller-manager" \
license="Apache Version 2.0" \
maintainers="[email protected],[email protected]" \
description="VngCloud Controller Manager" \
distribution-scope="public" \
summary="VngCloud Controller Manager" \
help="none"

CMD [ "/bin/vngcloud-controller-manager" ]

##
## vngcloud-ingress-controller
##
FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE} as vngcloud-ingress-controller

COPY --from=builder /build/vngcloud-ingress-controller /bin/vngcloud-ingress-controller
COPY --from=certs /etc/ssl/certs /etc/ssl/certs

LABEL name="vngcloud-ingress-controller" \
license="Apache Version 2.0" \
maintainers="[email protected],[email protected]" \
description="Vngcloud ingress controller" \
distribution-scope="public" \
summary="Vngcloud ingress controller" \
help="none"

CMD ["/bin/vngcloud-ingress-controller"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MIT License
MIT License

Copyright (c) 2024 VNG Cloud

Expand Down
Loading

0 comments on commit 881262c

Please sign in to comment.