Skip to content

Commit d043801

Browse files
authored
fix: docker compose (#104)
1 parent 1ce2bdc commit d043801

File tree

8 files changed

+58
-48
lines changed

8 files changed

+58
-48
lines changed

ai/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ COPY . .
2121

2222
EXPOSE 4000
2323

24-
CMD ["uvicorn", "app.reccomendation:app", "--host", "0.0.0.0", "--port", "4000"]
24+
CMD ["uvicorn", "reccomendation:app", "--host", "0.0.0.0", "--port", "4000"]

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:

frontend/app/(review)/[id].tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
KeyboardAvoidingView,
88
ScrollView,
99
StyleSheet,
10+
Touchable,
1011
TouchableOpacity,
1112
View,
1213
} from "react-native";
@@ -142,13 +143,15 @@ export default function Route() {
142143

143144
{/* User Info */}
144145
<View style={styles.userInfo}>
145-
<View style={styles.userInfoLeft}>
146-
<Image source={{ uri: review?.reviewer.pfp }} style={styles.profilePicture} />
147-
<View>
148-
<ThemedText style={styles.userName}>{review?.reviewer.username}</ThemedText>
149-
<ThemedText style={styles.userHandle}>@{review?.reviewer.username}</ThemedText>
146+
<TouchableOpacity onPress={() => router.push(`/friend/${review?.reviewer._id}`)}>
147+
<View style={styles.userInfoLeft}>
148+
<Image source={{ uri: review?.reviewer.pfp }} style={styles.profilePicture} />
149+
<View>
150+
<ThemedText style={styles.userName}>{review?.reviewer.username}</ThemedText>
151+
<ThemedText style={styles.userHandle}>@{review?.reviewer.username}</ThemedText>
152+
</View>
150153
</View>
151-
</View>
154+
</TouchableOpacity>
152155
</View>
153156
<View style={{ paddingBottom: 12 }}>
154157
<TouchableOpacity

frontend/components/UserInfo/UserInfoRowBase.tsx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { View, StyleSheet, TouchableOpacity } from "react-native";
33
import { ThemedText } from "../themed/ThemedText";
44
import { Avatar } from "../Avatar";
5+
import { router } from "expo-router";
56

67
type Props = {
78
name: string;
@@ -13,28 +14,41 @@ type Props = {
1314
onPress: () => void;
1415
};
1516

16-
const UserInfoRowBase = ({ name, username, right, icon, large, onPress }: Props) => (
17+
const UserInfoRowBase = ({ name, username, right, icon, large, onPress, id }: Props) => (
1718
<View style={{ flexDirection: "row", alignItems: "center", width: "100%" }}>
18-
<View style={styles.row}>
19-
<View style={{ flexDirection: "row", gap: 12, alignItems: "center" }}>
20-
<Avatar imageSource={{ uri: icon }} size={large ? 64 : 48} />
21-
<View style={{ gap: 0 }}>
22-
<TouchableOpacity onPress={onPress}>
23-
<ThemedText numberOfLines={1} ellipsizeMode="tail" type="default" style={styles.nameContainer}>
24-
{name}
25-
</ThemedText>
26-
<ThemedText
27-
numberOfLines={1}
28-
ellipsizeMode="tail"
29-
type="caption"
30-
style={styles.usernameContainer}>
31-
@{username}
32-
</ThemedText>
33-
</TouchableOpacity>
19+
<TouchableOpacity
20+
disabled={id ? false : true}
21+
onPress={() => {
22+
if (id) {
23+
router.push(`/(profile)/${id}`);
24+
return;
25+
}
26+
}}>
27+
<View style={styles.row}>
28+
<View style={{ flexDirection: "row", gap: 12, alignItems: "center" }}>
29+
<Avatar imageSource={{ uri: icon }} size={large ? 64 : 48} />
30+
<View style={{ gap: 0 }}>
31+
<TouchableOpacity onPress={onPress}>
32+
<ThemedText
33+
numberOfLines={1}
34+
ellipsizeMode="tail"
35+
type="default"
36+
style={styles.nameContainer}>
37+
{name}
38+
</ThemedText>
39+
<ThemedText
40+
numberOfLines={1}
41+
ellipsizeMode="tail"
42+
type="caption"
43+
style={styles.usernameContainer}>
44+
@{username}
45+
</ThemedText>
46+
</TouchableOpacity>
47+
</View>
3448
</View>
49+
{right}
3550
</View>
36-
{right}
37-
</View>
51+
</TouchableOpacity>
3852
</View>
3953
);
4054

frontend/types/review.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ export type TReview = {
1010
picture: string;
1111
content: string;
1212
reviewer: {
13-
id: string;
13+
_id: string;
1414
pfp: string;
1515
username: string;
16-
name: string;
1716
};
1817
timestamp: any;
1918
comments: any[];

0 commit comments

Comments
 (0)