Skip to content

Commit

Permalink
Merge pull request #27 from yunkon-kim/refactor-project
Browse files Browse the repository at this point in the history
Refactor project structure
  • Loading branch information
seokho-son authored Nov 29, 2023
2 parents 66e080e + 66a3845 commit f13ddac
Show file tree
Hide file tree
Showing 26 changed files with 1,855 additions and 525 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pkg/cm-beetle
pkg/cm-beetle-arm
pkg/cli/tbctl
pkg/cli/cli
cmd/cm-beetle/cm-beetle

# AutoGenerated DB data directory
meta_db/
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apk add --no-cache build-base

ADD . /go/src/github.com/cloud-barista/cm-beetle

WORKDIR /go/src/github.com/cloud-barista/cm-beetle/pkg
WORKDIR /go/src/github.com/cloud-barista/cm-beetle/cmd/cm-beetle

RUN go build -ldflags '-w -extldflags "-static"' -tags cm-beetle -o cm-beetle -v

Expand All @@ -27,15 +27,15 @@ FROM ubuntu:latest as prod
# use bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

WORKDIR /app/src
WORKDIR /app

# COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/assets/ /app/assets/

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/pkg/cm-beetle /app/pkg/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/cmd/cm-beetle /app/

#RUN /bin/bash -c "source /app/conf/setup.env"
ENV CMBEETLE_ROOT /app
Expand Down Expand Up @@ -68,6 +68,6 @@ ENV SELF_ENDPOINT localhost:8056
# Swagger UI API document file path
ENV API_DOC_PATH /app/pkg/api/rest/docs/swagger.json

ENTRYPOINT [ "/app/pkg/cm-beetle" ]
ENTRYPOINT [ "/app/cm-beetle" ]

EXPOSE 8056
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default:
cd cmd/cm-beetle && $(MAKE)
cc:
cd cmd/cm-beetle && $(MAKE)
run:
cd cmd/cm-beetle && $(MAKE) run
runwithport:
cd cmd/cm-beetle && $(MAKE) runwithport --port=$(PORT)
clean:
cd cmd/cm-beetle && $(MAKE) clean
prod:
cd cmd/cm-beetle && $(MAKE) prod
swag swagger:
cd pkg/ && $(MAKE) swag
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ git clone https://github.com/cloud-barista/cm-beetle.git ${HOME}/cm-beetle
#### Build CM-Beetle

```bash
cd ${HOME}/cm-beetle/pkg
cd ${HOME}/cm-beetle
make
```

(Optional) Update Swagger API document
```bash
cd ${HOME}/cm-beetle/pkg
cd ${HOME}/cm-beetle
make swag
```

Expand All @@ -95,7 +95,7 @@ go install github.com/swaggo/swag/cmd/swag@latest
#### Run CM-Beetle binary

```bash
cd ${HOME}/cm-beetle/pkg
cd ${HOME}/cm-beetle
make run
```

Expand Down
10 changes: 0 additions & 10 deletions cmd/beetle/Makefile

This file was deleted.

187 changes: 0 additions & 187 deletions cmd/beetle/main.go

This file was deleted.

17 changes: 17 additions & 0 deletions cmd/cm-beetle/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default:
go build -o cm-beetle
cc:
GOOS=linux GOARCH=arm go build -o cm-beetle-arm
run:
./cm-beetle
runwithport:
./cm-beetle --port=$(PORT)
clean:
rm -v cm-beetle
prod:
@echo "Build for production"
# Note - Using cgo write normal Go code that imports a pseudo-package "C". I may not need on cross-compiling.
# 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.
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o cm-beetle
16 changes: 1 addition & 15 deletions pkg/main.go → cmd/cm-beetle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,6 @@ func init() {

// Main Body

// @title CM-Beetle REST API
// @version latest
// @description CM-Beetle REST API

// @contact.name API Support
// @contact.url http://cloud-barista.github.io
// @contact.email contact-to-cloud-barista@googlegroups.com

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @BasePath /beetle

// @securityDefinitions.basic BasicAuth
func main() {
fmt.Println("")

Expand Down Expand Up @@ -145,7 +131,7 @@ func main() {
fmt.Println("")
fmt.Println("[Setup SQL Database]")

err := os.MkdirAll("../meta_db/dat/", os.ModePerm)
err := os.MkdirAll("./meta_db/dat/", os.ModePerm)
if err != nil {
fmt.Println(err.Error())
}
Expand Down
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CM-Beetle Docs

Documentation site for CM-Beetle, computing infrastructure migrator.
Loading

0 comments on commit f13ddac

Please sign in to comment.