refactor: project structure
This commit is contained in:
parent
2abed91918
commit
727b083e52
|
@ -0,0 +1,30 @@
|
|||
FROM golang:1.22 as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY internal ./internal
|
||||
COPY pk ./pk
|
||||
ARG PORT
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/webhook-ci /app/main.go
|
||||
|
||||
FROM alpine:3.15
|
||||
|
||||
# Install ca-certificates, ffmpeg (which includes ffprobe), Python, and yt-dlp
|
||||
RUN apk --no-cache add ca-certificates ffmpeg python3 py3-pip \
|
||||
&& python3 -m venv /opt/venv \
|
||||
&& source /opt/venv/bin/activate \
|
||||
&& pip install --no-cache-dir yt-dlp
|
||||
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
|
||||
COPY --from=builder /app/banana-byte /app/banana-byte
|
||||
COPY --from=builder /app/web /app/web
|
||||
|
||||
ENV VIEWS_DIR="/app/web"
|
||||
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["/app/banana-byte"]
|
|
@ -4,13 +4,13 @@ import (
|
|||
"errors"
|
||||
"log"
|
||||
|
||||
pkgwatcher "gitea.urkob.com/urko/git-webhook-ci/pkg/watcher"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/pkg"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
)
|
||||
|
||||
type watcher struct {
|
||||
fswatcher *fsnotify.Watcher
|
||||
deploy pkgwatcher.DeployFunc
|
||||
deploy pkg.DeployFunc
|
||||
}
|
||||
|
||||
type notifier struct{}
|
||||
|
@ -28,7 +28,7 @@ var (
|
|||
errErrorsClosedChan = errors.New("errors is closed")
|
||||
)
|
||||
|
||||
func NewWatcher(notifier pkgwatcher.NotifyIface, deploy pkgwatcher.DeployFunc) *watcher {
|
||||
func NewWatcher(notifier pkg.NotifyIface, deploy pkg.DeployFunc) *watcher {
|
||||
wt, err := notifier.NewWatcher()
|
||||
if err != nil {
|
||||
log.Printf("fsnotify.NewWatcher: %s\n", err)
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.urkob.com/urko/git-webhook-ci/cfg"
|
||||
pkgwatcher "gitea.urkob.com/urko/git-webhook-ci/pkg/watcher"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/kit/cfg"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/pkg"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -26,8 +26,8 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
mockDeploy pkgwatcher.DeployFunc
|
||||
mockErrorDeploy pkgwatcher.DeployFunc
|
||||
mockDeploy pkg.DeployFunc
|
||||
mockErrorDeploy pkg.DeployFunc
|
||||
errIntentional = errors.New("intentional error")
|
||||
binaryPath = ""
|
||||
scriptPath = ""
|
||||
|
|
10
main.go
10
main.go
|
@ -7,14 +7,14 @@ import (
|
|||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"gitea.urkob.com/urko/git-webhook-ci/cfg"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/internal/watcher"
|
||||
pkgwatcher "gitea.urkob.com/urko/git-webhook-ci/pkg/watcher"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/kit/cfg"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/pkg"
|
||||
)
|
||||
|
||||
var (
|
||||
watcherIface pkgwatcher.WatcherIface
|
||||
notifierIface pkgwatcher.NotifyIface
|
||||
watcherIface pkg.WatcherIface
|
||||
notifierIface pkg.NotifyIface
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -27,7 +27,7 @@ func main() {
|
|||
config := cfg.NewConfig(envFilePath)
|
||||
|
||||
notifierIface = watcher.NewNotifier()
|
||||
watcherIface = watcher.NewWatcher(notifierIface, pkgwatcher.Deploy)
|
||||
watcherIface = watcher.NewWatcher(notifierIface, pkg.Deploy)
|
||||
|
||||
defer func() {
|
||||
if err := watcherIface.Close(); err != nil {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package watcher
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,9 +1,9 @@
|
|||
package watcher
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.urkob.com/urko/git-webhook-ci/cfg"
|
||||
"gitea.urkob.com/urko/git-webhook-ci/kit/cfg"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
Loading…
Reference in New Issue