Skip to content

Commit 38854b4

Browse files
authored
Merge pull request #3 from XHyperDEVX/cto/rebuild-from-scratch-ultra-lightweight
Rebuild webhooktimer from scratch with lightweight scheduler and minimal UI
2 parents c50d0d0 + 81ca3d9 commit 38854b4

18 files changed

Lines changed: 1753 additions & 1135 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git
2+
.gitignore
3+
.github
4+
/data
5+
/bin
6+
/vendor
7+
*.db
8+
*.log

.github/workflows/docker-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- main
7+
#pull_request:
8+
# branches:
9+
# - main
1010

1111
env:
1212
REGISTRY: ghcr.io

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ webhooktimer
66
*.exe
77
*.test
88
.DS_Store
9+
/data/
10+
*.corrupt-*

Dockerfile

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
1-
# Build stage
2-
FROM golang:alpine AS builder
1+
FROM golang:1.22-alpine AS builder
32

4-
WORKDIR /app
3+
WORKDIR /src
54

6-
# Install build dependencies
7-
RUN apk add --no-cache git
5+
RUN apk add --no-cache ca-certificates
86

9-
# Copy go mod and sum files
10-
COPY go.mod go.sum ./
11-
12-
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
7+
COPY go.mod ./
138
RUN go mod download
149

15-
# Copy the source from the current directory to the Working Directory inside the container
1610
COPY . .
11+
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/webhooktimer .
1712

18-
# Build the Go app
19-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o webhooktimer .
20-
21-
# Final stage
22-
FROM alpine:latest
23-
24-
RUN apk --no-cache add ca-certificates tzdata
25-
26-
WORKDIR /app
13+
FROM scratch
2714

28-
# Copy the Pre-built binary file from the previous stage
29-
COPY --from=builder /app/webhooktimer .
30-
COPY --from=builder /app/web ./web
15+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
16+
COPY --from=builder /out/webhooktimer /webhooktimer
3117

32-
# Expose port 8080 to the outside world
3318
EXPOSE 8080
19+
VOLUME ["/data"]
3420

35-
# Environment variables
3621
ENV PORT=8080
37-
ENV DB_PATH=/data/timers.db
22+
ENV STATE_PATH=/data/state.json
23+
ENV TZ=UTC
3824

39-
# Command to run the executable
40-
CMD ["./webhooktimer"]
25+
ENTRYPOINT ["/webhooktimer"]

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ services:
33
build: .
44
ports:
55
- "8080:8080"
6+
environment:
7+
- TZ=UTC
8+
- STATE_PATH=/data/state.json
69
volumes:
710
- ./data:/data
811
restart: unless-stopped

go.mod

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
11
module webhooktimer
22

3-
go 1.25.0
4-
5-
require (
6-
github.com/go-chi/chi/v5 v5.2.5
7-
github.com/google/uuid v1.6.0
8-
github.com/gorilla/websocket v1.5.3
9-
modernc.org/sqlite v1.30.0
10-
)
11-
12-
require (
13-
github.com/dustin/go-humanize v1.0.1 // indirect
14-
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
15-
github.com/mattn/go-isatty v0.0.20 // indirect
16-
github.com/ncruces/go-strftime v1.0.0 // indirect
17-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
18-
golang.org/x/sys v0.42.0 // indirect
19-
modernc.org/gc/v3 v3.1.2 // indirect
20-
modernc.org/libc v1.70.0 // indirect
21-
modernc.org/mathutil v1.7.1 // indirect
22-
modernc.org/memory v1.11.0 // indirect
23-
modernc.org/strutil v1.2.1 // indirect
24-
modernc.org/token v1.1.0 // indirect
25-
)
3+
go 1.22

go.sum

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

internal/handlers/handlers.go

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

0 commit comments

Comments
 (0)