๐Ÿ“—
smiley book
  • Smiley Books
  • AI
    • Readme
    • openai-whisper
      • ์ƒ˜ํ”Œ ์‹คํ–‰ํ•ด๋ณด๊ธฐ
      • GPU ์„œ๋ฒ„ ์ค€๋น„ํ•˜๊ธฐ
      • API๋กœ whisper๋ฅผ ์™ธ๋ถ€์— ์˜คํ”ˆํ•˜๊ธฐ
      • ํ”„๋กฌํ”„ํŠธ ์ง€์›
      • ์‹ค์‹œ๊ฐ„ message chat
      • ํ™”๋ฉด ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ์™€ ๋กœ๊ทธ์ธ
      • ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ
      • ์‹ค์‹œ๊ฐ„ voice chat
      • fine tunning(๋ฏธ์„ธ ์กฐ์ •) ์œผ๋กœ ์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๊ธฐ
      • app์—์„œ api๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ…์ŠคํŠธ๋กœ ๋ฐ”๊ฟ”๋ณด๊ธฐ
    • ollama - llm์„ ์‰ฝ๊ฒŒ ๋‚ด์ปด์—์„œ ์‹คํ–‰
      • ollama webui
      • ollama docker
    • stable diffusion
      • SDXL - text to image
      • SD-webui
    • ChatGPT
      • ๋‹ต๋ณ€์ด ๋Š๊ธธ๋•Œ
      • ์—ญํ• ์„ ์ •ํ•˜์ž
      • ๊ตฌ์ฒด์ ์ธ ์งˆ๋ฌธ
      • ๊ฒฐ๊ณผํ˜•ํƒœ๋ฅผ ์ง€์ •
      • ํ”„๋กฌํ”„ํŠธ๋ฅผ ์—ฌ๋Ÿฌ์ค„๋กœ ์‚ฌ์šฉํ•˜์ž.
      • ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ ๊ธ€ ๋ฒˆ์—ญ๋ณธ
    • Prompt Engineering
    • Auto-GPT
    • Gemini
      • google ai studio
      • gemini-api
      • embedding guide
    • Huggingface
      • huggingface ์‚ฌ์šฉ๋ฒ•
      • huggingface nlp ๊ณต๋ถ€์ค‘
    • kaggle
      • download dataset
    • langchain
      • langchain์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ •๋ฆฌ
      • basic
      • slackbot
      • rag
      • document-loader
      • website-loader
      • confluence
      • memory
      • function-call
      • langsmith
      • agent-toolkit
  • Ansible
    • templates vs files and jinja2
    • dynamic inventory
    • limit ์˜ต์…˜ ๊ฐ•์ œํ•˜๊ธฐ
    • limit ์‚ฌ์šฉํ›„ gather_fact ๋ฌธ์ œ
  • AWS
    • AWS CLI
    • EKS
      • cluster manage
      • ALB Controller
      • external-dns
      • fargate
    • ECR
    • S3
    • Certificate Manager
  • Azure
    • Azure AD OAuth Client Flow
  • Container
    • Registry
    • ๋นŒ๋“œ์‹œ์— env๊ฐ’ ์„ค์ •ํ•˜๊ธฐ
  • DB
    • PXC
      • Operator
      • PMM
      • ์‚ญ์ œ
      • GTID
      • Cross Site Replication
    • Mssql
    • Mysql
  • dotnet
    • Thread Pool
    • Connection Pool
    • Thread Pool2
  • Devops
    • Recommendation
  • GIT
    • Basic
    • Submodule
  • GitHub
    • Repository
    • GitHub Action
    • GitHub PR
    • Self Hosted Runner
    • GitHub Webhook
  • GitLab
    • CI/CD
    • CI/CD Advance
    • Ssl renew
    • CI/CD Pass env to other job
  • Go Lang
    • ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•
    • multi os binary build
    • kubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ
    • azure ad cli
    • embed static file
    • go study
      • pointer
      • module and package
      • string
      • struct
      • goroutine
  • Kubernetes
    • Kubernetes๋Š” ๋ฌด์—‡์ธ๊ฐ€
    • Tools
    • Install with kubespray
    • Kubernetes hardening guidance
    • 11 ways not to get hacked
    • ArgoCD
      • Install
      • CLI
      • Repository
      • Apps
      • AWS ALB ์‚ฌ์šฉ
      • Notification slack
      • Backup / DR
      • Ingress
      • 2021-11-16 Github error
      • Server Config
      • auth0 ์ธ์ฆ ์ถ”๊ฐ€(oauth,OIDC)
    • Extension
      • Longhorn pvc
      • External dns
      • Ingress nginx
      • Cert Manager
      • Kube prometheus
    • Helm
      • Subchart
      • Tip
    • Loki
    • Persistent Volume
    • TIP
      • Job
      • Pod
      • Log
  • KAFKA
    • raft
  • KVM
    • kvm cpu model
  • Linux
    • DNS Bind9
      • Cert-Manager
      • Certbot
      • Dynamic Update
      • Log
    • Export and variable
    • Grep ์‚ฌ์šฉ๋ฒ•
  • Modeling
    • C4 model introduce
    • Mermaid
    • reference
  • Monitoring
    • Readme
    • 0. What is Monitoring
    • 1. install prometheus and grafana
    • 2. grafana provisioning
    • 3. grafana dashboard
    • 4. grafana portable dashboard
    • 5. prometheus ui
    • 6. prometheus oauth2
    • Prometheus
      • Metric type
      • basic
      • rate vs irate
      • k8s-prometheus
    • Grafana
      • Expolorer
    • Node Exporter
      • advance
      • textfile collector
  • Motivation
    • 3 Simple Rule
  • OPENNEBULA
    • Install(ansible)
    • Install
    • Tip
    • Windows vm
  • Reading
    • comfort zone
    • ๋ฐฐ๋ ค
    • elon musk 6 rule for insane productivity
    • Feynman Technique
    • how to interview - elon musk
    • ๊ฒฝ์ฒญ
    • Readme
  • Redis
    • Install
    • Master-slave Architecture
    • Sentinel
    • Redis Cluster
    • Client programming c#
  • SEO
    • Readme
  • Security
    • criminalip.io
      • criminalip.io
  • Stock
    • robinhood-python
  • Terraform
    • moved block
    • output
  • vault
    • Readme
  • VS Code
    • dev container
    • dev container on remote server
  • Old fashione trend
    • curity
    • MAAS
      • Install maas
      • Manage maas
      • Tip
Powered by GitBook
On this page
  • setup gox
  • tools.go ์ถ”๊ฐ€
  • build
  • ci/cd setup
  • upload artifact to package & registries
  • release

Was this helpful?

  1. Go Lang

multi os binary build

Previous๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•Nextkubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ

Last updated 1 year ago

Was this helpful?

setup gox

gox๋ผ๋Š” ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•  ๊ฒƒ์ด๋‹ค.

Gox - Simple Go Cross Compilation

๋‹ค์Œ ์›น์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์ž.

project ํด๋”์—์„œ ๋‹ค์Œ์„ ์‹คํ–‰ํ•œ๋‹ค.

go get github.com/mitchellh/gox@v1.0.1

go.mod์— ๋‚ด์šฉ์ด ์ถ”๊ฐ€๋œ๊ฑธ ํ™•์ธํ• ์ˆ˜ ์žˆ๋‹ค.

์ด์ œ ci/cd์‹œ์— ์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์„ค์น˜ํ•˜๊ฒŒ ํ•ด์ฃผ๋ฉด๋œ๋‹ค.

tools.go ์ถ”๊ฐ€

vi tools.go

//go:build tools
// +build tools

package main

// These imports are to force `go mod tidy` not to remove that tools we depend
// on development. This is explained in great detail in
// https://marcofranssen.nl/manage-go-tools-via-go-modules/
import (
  _ "github.com/mitchellh/gox"
)

build

make ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ด์„œ ๋นŒ๋“œ๋ฅผ ํ•ด๋ณด์ž.

ํ”„๋กœ์ ํŠธ์— Makefile์„ ๋งŒ๋“ค์ž.

vi Makefile

PROJECT_NAME := jiractl

.PHONY: setup clean build-binaries
setup: clean
 $Q mkdir -p bin/
 $Q go mod tidy
# From https://marcofranssen.nl/manage-go-tools-via-go-modules/
 @cat tools.go | \
  grep _ | \
  awk -F'"' '{print $$2}' | \
  GOBIN=$(CURDIR)/bin xargs -tI % go install %

clean:
 $Q rm -rf bin/*

BUILD_PLATFORMS ?= -os '!netbsd' -os '!openbsd'

build-binaries: setup
 # Building $(PROJECT_NAME) for $(BUILD_PLATFORMS)
 ${CURDIR}/bin/gox $(BUILD_PLATFORMS) \
  -output="bin/binaries/$(PROJECT_NAME)-{{.OS}}-{{.Arch}}" .

clean -> setup -> build-binaries ๋กœ ๋™์ž‘ํ•œ๋‹ค.

make build-binaries๋ฅผ ํ•˜๋ฉด ํŒจํ‚ค์ง€๋ฅผ ๋นŒ๋“œํ•œ๋‹ค.

ci/cd setup

.gitlab-ci.yml

variables:
  GO_VERSION: '1.18.5'
  # See https://docs.gitlab.com/ee/user/packages/generic_packages/#publish-a-package-file
  PACKAGE_REGISTRY_URL: '$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/jiractl'

image: golang:${GO_VERSION}

.binaries: &binaries
  image: golang:1.18
  rules:
    - if: '$CI_COMMIT_TAG'
  stage: build
  script:
    - export platforms=$(echo $CI_JOB_NAME | sed 's|binaries ||')
    - make build-binaries BUILD_PLATFORMS="-osarch='$platforms'"
  artifacts:
    paths:
      - app/bin/binaries
    expire_in: 7d

binaries darwin/amd64: *binaries
binaries darwin/arm64: *binaries
binaries freebsd/386 freebsd/amd64 freebsd/arm: *binaries
binaries linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le: *binaries
binaries windows/386 windows/amd64:
  extends: .binaries

yaml yank๋ฅผ ์ด์šฉํ•ด์„œ yaml์„ ์ค„์—ฟ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” *binaries์— ์œ„์— binary๋ฅผ ๋‹ค ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

binaries darwin/amd64 ์ด๊ฒŒ ์ž‘์—… ์ด๋ฆ„์ธ๋ฐ ์ด๊ฒƒ์ค‘์š” darwin/amd64๋ฅผ ๊ฐ€์ ธ์™€์„œ ๊ทธ๊ฑธ make์— ๋ณด๋‚ด์ฃผ๋ฉด make๊ฐ€ ๋นŒ๋“œ๋ฅผ ํ•˜๋Š” ๊ตฌ์กฐ์ด๋‹ค.

artifact๋ฅผ ์ด์šฉํ•˜์—ฌ ์ €์žฅ์„ ํ•ด๋‘๋Š”๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ํ•ด๋‘๋ฉด ui์—์„œ ๋‹ค์šด๋กœ๋“œ๋ฅผ ๋ฐ›์„์ˆ˜ ์žˆ๋‹ค.

upload artifact to package & registries

vi .gitlab-ci.yml

upload binaries to generic package for tag:
  stage: publish
  image: curlimages/curl:latest
  needs:
    - 'binaries darwin/amd64'
    - 'binaries darwin/arm64'
    - 'binaries freebsd/386 freebsd/amd64 freebsd/arm'
    - 'binaries linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le'
    - 'binaries windows/386 windows/amd64'
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    - cd app/bin/binaries/
    - |
      for FILE in *; do
        curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${FILE} ${PACKAGE_REGISTRY_URL}/${CI_COMMIT_TAG}/${FILE} ;
      done

์•„๊นŒ ์„ค์ •ํ•ด๋‘” variable ์„ ์‚ฌ์šฉํ•œ๋‹ค.

PACKAGE_REGISTRY_URL: '$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/jiractl'

for๋ฌธ์„ ๋Œ๋ฉด์„œ ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•œ๋‹ค.

์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŒจํ‚ค์ง€์— ์—…๋กœ๋“œ ๋จ์„ ์•Œ์ˆ˜์žˆ๋‹ค.

release

vi .gitlab-ci.yml

์ผ๋‹จ git์— ๋กœ๊ทธ๋ฅผ ์ฝ์–ด์™€์„œ description์ด๋ผ๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์‚ฌ์šฉํ•ด์•ผํ•˜๋ฏ€๋กœ ํŒŒ์ผ์— ์ ์–ด๋‘”ํ›„ artifact์— ์ถ”๊ฐ€ํ•ด์ค€๋‹ค. ๋‚˜์ค‘์— $DESCRIPTION ์ด๋Ÿฌ๋ฉด ๋‹ค๋ฅธ ์ž‘์—…์—์„œ ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๋‹ค.

generate_description:
  # generate_description needs to run in a previous stage before release
  stage: publish
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    # generate description from annotated tag's subject
    - echo "DESCRIPTION=$(git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:'At %ci, %cN committed %h - %s' --decorate --graph)" > description.env
    - cat description.env
  artifacts:
    reports:
      dotenv: description.env

์ด์ œ release๋ฅผ ์ƒ์„ฑํ•˜์ž file์€ ๋งํฌ๋กœ ์žก์•„์„œ ์˜ฌ๋ ค์ฃผ๋ฉด ๋œ๋‹ค.

release-from-tag:
  image: registry.gitlab.com/gitlab-org/release-cli
  stage: release
  needs:
    - 'upload binaries to generic package for tag'
    - 'generate_description'
  rules:
    - if: '$CI_COMMIT_TAG' # Run this job when a tag is created manually
  script:
    - echo "Creating a release for $CI_COMMIT_TAG"
    - echo "$DESCRIPTION"
  release:
    name: 'Release $CI_COMMIT_TAG'
    description: '$DESCRIPTION'
    tag_name: '$CI_COMMIT_TAG'
    ref: '$CI_COMMIT_TAG'
    assets:
      links:
        - name: 'darwin/amd64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-darwin-amd64'
          filepath: '/app/bin/binaries/jiractl-darwin-amd64'
        - name: 'darwin/arm64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-darwin-arm64'
          filepath: '/app/bin/binaries/jiractl-darwin-arm64'
        - name: 'freebsd/386'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-freebsd-386'
          filepath: '/app/bin/binaries/jiractl-freebsd-386'
        - name: 'freebsd/amd64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-freebsd-amd64'
          filepath: '/app/bin/binaries/jiractl-freebsd-amd64'
        - name: 'freebsd/arm'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-freebsd-arm'
          filepath: '/app/bin/binaries/jiractl-freebsd-arm'
        - name: 'linux/386'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-linux-386'
          filepath: '/app/bin/binaries/jiractl-linux-386'
        - name: 'linux/amd64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-linux-amd64'
          filepath: '/app/bin/binaries/jiractl-linux-amd64'
        - name: 'linux/arm'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-linux-arm'
          filepath: '/app/bin/binaries/jiractl-linux-arm'
        - name: 'linux/arm64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-linux-arm64'
          filepath: '/app/bin/binaries/jiractl-linux-arm64'
        - name: 'linux/ppc64le'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-linux-ppc64le'
          filepath: '/app/bin/binaries/jiractl-linux-ppc64le'
        - name: 'windows/386'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-windows-386.exe'
          filepath: '/app/bin/binaries/jiractl-windows-386.exe'
        - name: 'windows/amd64'
          url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/jiractl-windows-amd64.exe'
          filepath: '/app/bin/binaries/jiractl-windows-amd64.exe'

๋‹ค์Œ์ฒ˜๋Ÿผ release๊ฐ€ ์ƒ๊ธด๊ฒƒ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

์™„์„ฑ

https://github.com/mitchellh/gox