Skip to content

Commit

Permalink
Merge pull request #113 from yunkon-kim/240820-21
Browse files Browse the repository at this point in the history
Updates to Go version, build cache, proxy middleware, etc.
  • Loading branch information
seokho-son authored Aug 20, 2024
2 parents ea47de7 + 4ed3db7 commit 6ed93a3
Show file tree
Hide file tree
Showing 26 changed files with 228 additions and 788 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: Build source code
strategy:
matrix:
go-version: ["1.21"]
go-version: ["1.23.0"]
os: [ubuntu-22.04]
#os: [ubuntu-22.04, ubuntu-20.04, windows-2022, windows-2019]
runs-on: ${{matrix.os}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.21' ]
go-version: [ '1.23.0' ]

steps:
- name: Set up Go ${{ matrix.go-version }}
Expand Down
33 changes: 20 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
## Stage 1 - Go Build
##############################################################

FROM golang:1.21.6-bookworm AS builder
FROM golang:1.23.0-bookworm AS builder

# Installing necessary packages
# make for Makefile support
# sqlite3 and libsqlite3-dev for SQLite support
# build-essential for common build requirements
RUN apt-get update && apt-get install -y --no-install-recommends \
make gcc sqlite3 libsqlite3-dev build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ENV GO111MODULE=on

# Set the Current Working Directory inside the container
WORKDIR /go/src/github.com/cloud-barista/cm-beetle

# Copy only necessary files
COPY go.mod go.sum go.work go.work.sum LICENSE Makefile ./
# Copy dependency files to the container
COPY go.mod go.sum go.work go.work.sum LICENSE ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download

# Copy some necessary files to the container
COPY api ./api
COPY cmd/cm-beetle ./cmd/cm-beetle
COPY conf ./conf
COPY pkg ./pkg
COPY scripts ./scripts

# NOTE - "make prod" executes the commannd, "CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o cm-beetle"
RUN make prod
# Build the Go app
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
cd cmd/cm-beetle && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -tags cm-beetle -v -o cm-beetle main.go

#############################################################
## Stage 2 - Application Setup
Expand All @@ -37,10 +38,16 @@ RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Set the Current Working Directory inside the container
WORKDIR /app

# Installing necessary packages and cleaning up
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

## Copy the Pre-built binary and necessary files from the previous stage
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/scripts/ /app/scripts/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/conf/ /app/conf/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/cmd/cm-beetle /app/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/cmd/cm-beetle/cm-beetle /app/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/api/ /app/api/

## Set environment variables
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ prod: ## Build the binary file for production
# Note - You can find possible platforms by 'go tool dist list' for GOOS and GOARCH
# Note - Using the -ldflags parameter can help set variable values at compile time.
# Note - Using the -s and -w linker flags can strip the debugging information.
@cd cmd/$(MODULE_NAME) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -ldflags '-s -w' -o $(MODULE_NAME) main.go
@cd cmd/$(MODULE_NAME) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags '-s -w' -tags $(MODULE_NAME) -v -o $(MODULE_NAME) main.go
@echo "Build finished!"

run: build ## Run the built binary
Expand All @@ -80,5 +80,17 @@ clean: ## Remove previous build
@cd cmd/$(MODULE_NAME) && $(GO) clean
@echo "Cleaned!"

compose-up: ## Up services by docker compose
@echo "Starting services by docker compose..."
@cd deployments/docker-compose && docker compose up

compose-build-up: ## Build and up services by docker compose
@echo "Building and starting services by docker compose..."
@cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build

compose-down: ## Down services by docker compose
@echo "Removing services by docker compose..."
@cd deployments/docker-compose && docker compose down

help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ This is a sub-system on [Cloud-Barista platform](https://github.com/cloud-barist
and utilizes [CB-Tumblebug](https://github.com/cloud-barista/cb-tumblebug)
to depoly a multi-cloud infra as a target computing infrastructure.


## Overview

Computing Infrastructure Migration framework (codename: cm-beetle) is going to support:

- migration execution and control from source to target computing infrastructure, and
- recommendation of optimal configuration of target cloud infrastructure.


## Execution and development environment

- Operating system (OS):
- Ubuntu 22.04
- Languages:
- Go: 1.21.6
- Python: 3.10.12
- Operating system (OS):
- Ubuntu 22.04
- Languages:
- Go: 1.23.0
- Python: 3.10.12
- Container runtime:
- Docker: 24.0.7

- Docker: 24.0.7

## How to run and use CM-Beetle

Expand All @@ -33,14 +31,14 @@ Computing Infrastructure Migration framework (codename: cm-beetle) is going to s

#### Visualization of the codebase

> How can we “fingerprint” a codebase to see its structure at a glance?
> Let’s explore ways to automatically visualize a GitHub repo,
> How can we “fingerprint” a codebase to see its structure at a glance?
> Let’s explore ways to automatically visualize a GitHub repo,
> and how that could be useful. - [Visualizing a Codebase](https://githubnext.com/projects/repo-visualization/)
[Explore CM-Beetle codebase](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=cloud-barista%2Fcm-beetle)

![Visualization of the codebase](./docs/diagrams/visualizing-the-codebase.svg)

Note - this is automatically generated by [Repo Visualizer](https://github.com/marketplace/actions/repo-visualizer)
Note - this is automatically generated by [Repo Visualizer](https://github.com/marketplace/actions/repo-visualizer)

CM-Beetle is interested in [Potential future directions](https://githubnext.com/projects/repo-visualization/#potential-future-directions)
198 changes: 0 additions & 198 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,167 +190,6 @@ const docTemplate = `{
}
}
},
"/ns": {
"get": {
"description": "List all namespaces or namespaces' ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Namespace] Namespace management (To be used)"
],
"summary": "List all namespaces or namespaces' ID",
"responses": {
"200": {
"description": "Different return structures by the given option param",
"schema": {
"$ref": "#/definitions/common.RestGetAllNsResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
}
}
},
"post": {
"description": "Create namespace",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Namespace] Namespace management (To be used)"
],
"summary": "Create namespace",
"parameters": [
{
"description": "Details for a new namespace",
"name": "nsReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.NsReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}": {
"get": {
"description": "Get namespace",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Namespace] Namespace management (To be used)"
],
"summary": "Get namespace",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Namespace information",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
}
}
},
"delete": {
"description": "Delete namespace",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Namespace] Namespace management (To be used)"
],
"summary": "Delete namespace",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
}
}
}
}
},
"/readyz": {
"get": {
"description": "Check Beetle is ready",
Expand Down Expand Up @@ -671,18 +510,6 @@ const docTemplate = `{
}
},
"definitions": {
"common.RestGetAllNsResponse": {
"type": "object",
"properties": {
"ns": {
"description": "Name string ` + "`" + `json:\"name\"` + "`" + `",
"type": "array",
"items": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo"
}
}
}
},
"common.SimpleMessage": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -930,31 +757,6 @@ const docTemplate = `{
}
}
},
"github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"github_com_cloud-barista_cm-beetle_pkg_core_common.NsReq": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 6ed93a3

Please sign in to comment.