From c750c1f001b4c2f4c826fe0d8a4fc4527f4db33c Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Fri, 26 Apr 2024 07:50:08 +0000 Subject: [PATCH 1/6] devcontainer support Signed-off-by: Casper Thygesen --- .devcontainer/Dockerfile | 16 ++++++++++ .devcontainer/devcontainer.json | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..2bba1987 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/go/.devcontainer/base.Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster +FROM mcr.microsoft.com/devcontainers/go:1-1.21-bullseye + +ENV DOCKER_BUILDKIT=1 +ENV DOCKER_DEFAULT_PLATFORM=linux/amd64 + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends git curl graphviz + +USER vscode + +# Install github act +RUN curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..bd31383d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,56 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/go +{ + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + "args": { + } + }, + "containerEnv": { + "GITHUB_ACTOR": "${localEnv:GITHUB_ACTOR}", + "GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}" + }, + // "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + "runArgs": [ + //"--cap-add=SYS_PTRACE", + //"--security-opt", + //"seccomp=unconfined", + "--network=host", + //"--network=cheetah-infrastructure" + "--privileged" + ], + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go", + "ms-azuretools.vscode-docker", + "redhat.vscode-yaml", + "IronGeek.vscode-env", + "github.vscode-github-actions", + "jebbs.plantuml", + "GitHub.copilot", + "github.vscode-github-actions" + ] + } + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 1854 + ], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} \ No newline at end of file From f08cccfe3c724ffc526dc607e8c4aed1680bbc50 Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Fri, 26 Apr 2024 07:50:54 +0000 Subject: [PATCH 2/6] Publish Manual Release Signed-off-by: Casper Thygesen --- .github/workflows/rc-release.yaml | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/rc-release.yaml diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml new file mode 100644 index 00000000..cce62092 --- /dev/null +++ b/.github/workflows/rc-release.yaml @@ -0,0 +1,56 @@ +name: "Publish Manual Release" +on: + workflow_dispatch: + push: + branches: + - cheetah-main + +env: + IMAGE_NAME: ${{ github.repository }} + +jobs: + release: + runs-on: ubuntu-latest + name: Release release-candiate + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: "1.19" + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@879dcbb708d40f8b8679d4f7941b938a086e23a7 + with: + images: ghcr.io/${{ env.IMAGE_NAME }} + labels: | + org.opencontainers.image.vendor=Trifork + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch,suffix=-${{ github.run_id }} + type=ref,event=pr + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: switch dir + run: cd opensearch-operator/ + + - name: build + run: make build + + - name: Build and push Docker image + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5 + with: + push: true + outputs: type=registry + builder: ${{ steps.buildx.outputs.name }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 81bf6c5963e8b48716ed26bc288591ff497ad7df Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Fri, 26 Apr 2024 08:02:47 +0000 Subject: [PATCH 3/6] try fix build Signed-off-by: Casper Thygesen --- .github/workflows/rc-release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index cce62092..b7774271 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -38,15 +38,15 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - name: switch dir - run: cd opensearch-operator/ - - name: build + working-directory: opensearch-operator/ run: make build - name: Build and push Docker image uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5 with: + file: opensearch-operator/Dockerfile + context: opensearch-operator/ push: true outputs: type=registry builder: ${{ steps.buildx.outputs.name }} From ffb5e319b870388d02963fe675788c0593663733 Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Fri, 26 Apr 2024 08:34:49 +0000 Subject: [PATCH 4/6] fix permissions Signed-off-by: Casper Thygesen --- .github/workflows/rc-release.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index b7774271..8ae8b2a5 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -8,6 +8,10 @@ on: env: IMAGE_NAME: ${{ github.repository }} +permissions: + contents: read + packages: write + jobs: release: runs-on: ubuntu-latest From b9896f5475603a680c3833a28b44909d4722740a Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Fri, 26 Apr 2024 08:39:10 +0000 Subject: [PATCH 5/6] Docker login Signed-off-by: Casper Thygesen --- .github/workflows/rc-release.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 8ae8b2a5..9cf86eaa 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -19,13 +19,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2.3.4 + - name: Setup go uses: actions/setup-go@v3 with: go-version: "1.19" + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@879dcbb708d40f8b8679d4f7941b938a086e23a7 @@ -46,6 +49,13 @@ jobs: working-directory: opensearch-operator/ run: make build + - name: Docker login + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5 with: From f36c60ec0d83e9cfd7d97b66980ced15c1367fb0 Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Mon, 29 Apr 2024 08:23:15 +0200 Subject: [PATCH 6/6] Update rc-release.yaml with go.work Signed-off-by: Casper Thygesen --- .github/workflows/rc-release.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml index 9cf86eaa..0a7f8c6d 100644 --- a/.github/workflows/rc-release.yaml +++ b/.github/workflows/rc-release.yaml @@ -21,9 +21,10 @@ jobs: uses: actions/checkout@v2.3.4 - name: Setup go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: "1.19" + go-version-file: 'go.work' + cache: false - name: Set up Docker Buildx id: buildx