Merge branch 'main' of https://git.neunzweinull.com/jan/CCTV
This commit is contained in:
commit
d37cacf2b7
2
.gitignore
vendored
2
.gitignore
vendored
@ -24,3 +24,5 @@ go.work
|
||||
# .env file
|
||||
.env
|
||||
|
||||
cctv/
|
||||
compose.yml
|
||||
|
||||
33
Dockerfile
33
Dockerfile
@ -1,34 +1,17 @@
|
||||
FROM golang:1.22 as builder
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.22
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go module files and download dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY go.mod .
|
||||
|
||||
RUN go mod tidy && go mod download
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY . .
|
||||
|
||||
# Build the Go application
|
||||
RUN go build -o main ./...
|
||||
RUN go build -o /cctv ./cmd
|
||||
|
||||
# Stage 2: Create a minimal production image
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built application from the builder stage
|
||||
COPY --from=builder /app/main .
|
||||
|
||||
# Copy the .env file (if exists)
|
||||
COPY .env .env
|
||||
|
||||
# Expose the necessary port (change as needed)
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the application
|
||||
CMD ["./main"]
|
||||
|
||||
# Healthcheck to ensure the app is running
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/health || exit 1
|
||||
CMD [ "/cctv" ]
|
||||
|
||||
@ -251,6 +251,7 @@ func AuthMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
mu.Unlock()
|
||||
|
||||
authHeader := r.Header.Get("Authorization")
|
||||
fmt.Println(authHeader,"-", os.Getenv("CCTV_BearerToken"))
|
||||
if !strings.HasPrefix(authHeader, "Bearer ") || strings.TrimPrefix(authHeader, "Bearer ") != os.Getenv("CCTV_BearerToken") {
|
||||
LogFailedAttempt(ip)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user