Compare commits
No commits in common. "bf0bc3ceb898583c1482d6fd414f1cb55366ae2c" and "882548344a5082dc21ebc3de3f5107568782b79a" have entirely different histories.
bf0bc3ceb8
...
882548344a
2
.gitignore
vendored
2
.gitignore
vendored
@ -24,5 +24,3 @@ go.work
|
||||
# .env file
|
||||
.env
|
||||
|
||||
cctv/
|
||||
compose.yml
|
||||
|
||||
33
Dockerfile
33
Dockerfile
@ -1,17 +1,34 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.22
|
||||
FROM golang:1.22 as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod .
|
||||
|
||||
RUN go mod tidy && go mod download
|
||||
# Copy go module files and download dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY . .
|
||||
|
||||
RUN go build -o /cctv ./cmd
|
||||
# Build the Go application
|
||||
RUN go build -o main ./...
|
||||
|
||||
# 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
|
||||
|
||||
CMD [ "/cctv" ]
|
||||
# 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
|
||||
|
||||
@ -251,7 +251,6 @@ 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