Skip to content

Commit 65b6d05

Browse files
refactor: drop cobra dependencies and reorganize code for hexagonal architecture introduction (#3)
1 parent f6bc646 commit 65b6d05

18 files changed

Lines changed: 138 additions & 199 deletions

File tree

.github/workflows/go.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@ permissions: read-all
1414
jobs:
1515

1616
build:
17-
18-
1917
runs-on: ubuntu-24.04-arm
2018
steps:
2119
- uses: actions/checkout@v4
2220
- name: Buildah Action
2321
uses: redhat-actions/buildah-build@v2
2422
with:
25-
image: phantom
23+
image: ghcr.io/${{ github.repository }}
2624
tags: ${{ github.sha }}
2725
containerfiles: |
2826
./Containerfile
2927
extra-args: |
3028
--target=build
3129
- name: Run go vet
32-
run: podman run phantom:${{ github.sha }} go vet -v ./...
30+
run: podman run ghcr.io/${{ github.repository }}:${{ github.sha }} go vet -v ./...
3331
- name: Run go test
34-
run: podman run phantom:${{ github.sha }} go test -v ./...
32+
run: podman run ghcr.io/${{ github.repository }}:${{ github.sha }} go test -v ./...
3533

Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/golang:1.24.2-alpine3.21 AS build
22
WORKDIR /app
33
COPY . .
44
RUN apk add build-base musl-dev opencv-dev icu-libs --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
5-
RUN go build main.go
5+
RUN go build cmd/main.go
66

77
FROM docker.io/alpine:3.21
88
WORKDIR /app

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ stream video from usb device over the web
1010
In order to install opencv4 you can either rely on your system package manager or compile it directly using:
1111

1212
```bash
13-
pushd $GOPATH/gocv.io/x/gocv
13+
cd $GOPATH/gocv.io/x/gocv
1414
make install
15-
popd
1615
```
1716

17+
## Getting started
1818

19+
Build the container
20+
21+
```bash
22+
podman build -t phantom:$(git describe) .
23+
```
24+
25+
Run the container
26+
27+
```bash
28+
podman run --device /dev/video0 -p 8080:8080 localhost/phantom:$(git describe) /app/main
29+
```

api/middlewares/recovery.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

api/server.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

api/templates/index.html.tpl

Lines changed: 0 additions & 33 deletions
This file was deleted.

cmd/main.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
package cmd
1+
package main
22

33
import (
4-
"fmt"
5-
"os"
6-
7-
"github.com/spf13/cobra"
4+
"github.com/bugbundle/phantom/internal/adapter/http"
85
)
96

10-
var rootCmd = &cobra.Command{
11-
Use: "phantom",
12-
Short: "phantom is used to stream video device over internet using multipart",
13-
Run: func(cmd *cobra.Command, args []string) {
14-
cmd.Usage()
15-
},
16-
}
17-
18-
func Execute() {
19-
if err := rootCmd.Execute(); err != nil {
20-
fmt.Println(err)
21-
os.Exit(1)
22-
}
7+
func main() {
8+
http.Server("0.0.0.0:8080")
239
}

cmd/server.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,4 @@ module github.com/bugbundle/phantom
22

33
go 1.22.2
44

5-
require (
6-
github.com/spf13/cobra v1.9.1
7-
gocv.io/x/gocv v0.41.0
8-
)
9-
10-
require (
11-
github.com/inconshreveable/mousetrap v1.1.0 // indirect
12-
github.com/spf13/pflag v1.0.6 // indirect
13-
)
5+
require gocv.io/x/gocv v0.41.0

go.sum

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
2-
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3-
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
5-
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
6-
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
7-
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
8-
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
91
gocv.io/x/gocv v0.41.0 h1:KM+zRXUP28b6dHfhy+4JxDODbCNQNtLg8kio+YE7TqA=
102
gocv.io/x/gocv v0.41.0/go.mod h1:zYdWMj29WAEznM3Y8NsU3A0TRq/wR/cy75jeUypThqU=
11-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)