Skip to content

Commit 4c26971

Browse files
committed
2 parents 85d3804 + d043801 commit 4c26971

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

backend/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
# Build stage
2-
FROM golang:1.23.4 AS builder
3-
2+
FROM golang:1.23.4-alpine AS builder
43
# Set working directory
54
WORKDIR /app
6-
75
# Copy go mod and sum files first to leverage Docker cache
86
COPY go.mod go.sum ./
97
RUN go mod download
108
COPY .env .env
11-
129
# Copy the source code
1310
COPY . .
14-
1511
# Build the application
1612
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /app/backend ./cmd/server/main.go
1713

1814
# Final stage
19-
FROM ubuntu:latest
20-
21-
# Update and install ca-certificates for HTTPS
22-
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
23-
15+
FROM alpine:latest
16+
# Update and install ca-certificates for HTTPS (using apk instead of apt-get)
17+
RUN apk update && apk add --no-cache ca-certificates && rm -rf /var/cache/apk/*
2418
WORKDIR /root/
25-
2619
# Copy the binary from builder
2720
COPY --from=builder /app/backend /root/backend
28-
COPY .env /root/.env
21+
# Copy environment file (note: you had this twice in your original)
2922
COPY --from=builder /app/.env /root/.env
30-
3123
# Copy config files if needed
3224
# COPY --from=builder /app/config /root/config
33-
3425
# Expose the port your application runs on
3526
EXPOSE 8080
36-
3727
# Command to run
38-
CMD ["./backend"]
28+
CMD ["./backend"]

backend/internal/handlers/review/review.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,12 @@ func (h *Handler) SearchUserReviews(c *fiber.Ctx) error {
361361

362362
func (h *Handler) GetTopReviews(c *fiber.Ctx) error {
363363
userID := c.Params("userId")
364+
userOID, err := primitive.ObjectIDFromHex(userID)
365+
if err != nil {
366+
return err
367+
}
364368

365-
reviews, err := h.service.GetTopReviews(userID)
369+
reviews, err := h.service.GetTopReviews(userOID)
366370
if err != nil {
367371
return err
368372
}

backend/internal/handlers/review/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,10 @@ func (s *Service) SearchUserReviews(userID primitive.ObjectID, query string) ([]
491491
return results, nil
492492
}
493493

494-
func (s *Service) GetTopReviews(userID string) ([]TopReviewDocument, error) {
494+
func (s *Service) GetTopReviews(userID primitive.ObjectID) ([]TopReviewDocument, error) {
495495
ctx := context.Background()
496496
cursor, err := s.reviews.Aggregate(ctx, bson.A{
497-
bson.D{{Key: "$match", Value: bson.D{{Key: "reviewer.id", Value: userID}}}},
497+
bson.D{{Key: "$match", Value: bson.D{{Key: "reviewer._id", Value: userID}}}},
498498
bson.D{
499499
{Key: "$lookup",
500500
Value: bson.D{

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ services:
2323
container_name: golang-api
2424
restart: always
2525
ports:
26-
- '8080:8080'
26+
- '80:8080'
2727
volumes:
2828
- ./backend:/app
2929
env_file:

0 commit comments

Comments
 (0)