diff --git a/docker-compose.yml b/docker-compose.yml index 236dc6f..8f4d80b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,25 @@ services: networks: - internal + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + args: + EXPO_PUBLIC_API_URL: http://192.168.0.69:80/api + restart: always + ports: + - "8081:8081" + volumes: + - .:/frontend + - /frontend/node_modules + stdin_open: true + tty: true + depends_on: + - backend + networks: + - internal + volumes: postgres_data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..37acc47 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,19 @@ +FROM node:18-alpine + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +EXPOSE 8081 + +ARG EXPO_PUBLIC_API_URL + +ENV EXPO_PUBLIC_API_URL $EXPO_PUBLIC_API_URL + +RUN npm install -g expo-cli + +CMD ["npx", "expo", "start", "-c"] diff --git a/frontend/app/_layout.jsx b/frontend/app/_layout.jsx index 3fa19d0..1fcf4c7 100644 --- a/frontend/app/_layout.jsx +++ b/frontend/app/_layout.jsx @@ -2,7 +2,7 @@ import { Stack, Slot } from 'expo-router' import '../global.css' import GlobalProvider from '../context/GlobalProvider' -export const API_URL = 'http://192.168.0.69:5000/api' +export const API_URL = process.env.EXPO_PUBLIC_API_URL || 'http://localhost:80/api' const RootLayout = () => { diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0424630..d004439 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,7 +8,9 @@ "name": "frontend", "version": "1.0.0", "dependencies": { + "dotenv": "^16.4.7", "expo": "~52.0.23", + "expo-config": "^1.0.0", "expo-constants": "~17.0.3", "expo-linking": "~7.0.3", "expo-router": "~4.0.15", @@ -2158,14 +2160,14 @@ } }, "node_modules/@expo/config": { - "version": "10.0.6", - "resolved": "https://registry.npmjs.org/@expo/config/-/config-10.0.6.tgz", - "integrity": "sha512-xXkfPElrtxznkOZxFASJ7OPa6E9IHSjcZwj5BQ6XUF2dz5M7AFa2h5sXM8AalSaDU5tEBSgoUOjTh5957TlR8g==", + "version": "10.0.8", + "resolved": "https://registry.npmjs.org/@expo/config/-/config-10.0.8.tgz", + "integrity": "sha512-RaKwi8e6PbkMilRexdsxObLMdQwxhY6mlgel+l/eW+IfIw8HEydSU0ERlzYUjlGJxHLHUXe4rC2vw8FEvaowyQ==", "dependencies": { "@babel/code-frame": "~7.10.4", - "@expo/config-plugins": "~9.0.10", - "@expo/config-types": "^52.0.0", - "@expo/json-file": "^9.0.0", + "@expo/config-plugins": "~9.0.14", + "@expo/config-types": "^52.0.3", + "@expo/json-file": "^9.0.1", "deepmerge": "^4.3.1", "getenv": "^1.0.0", "glob": "^10.4.2", @@ -2178,13 +2180,13 @@ } }, "node_modules/@expo/config-plugins": { - "version": "9.0.12", - "resolved": "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-9.0.12.tgz", - "integrity": "sha512-/Ko/NM+GzvJyRkq8PITm8ms0KY5v0wmN1OQFYRMkcJqOi3PjlhndW+G6bHpJI9mkQXBaUnHwAiGLqIC3+MQ5Wg==", + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-9.0.14.tgz", + "integrity": "sha512-Lx1ebV95rTFKKQmbu4wMPLz65rKn7mqSpfANdCx+KwRxuLY2JQls8V4h3lQjG6dW8NWf9qV5QaEFAgNB6VMyOQ==", "dependencies": { - "@expo/config-types": "^52.0.0", - "@expo/json-file": "~9.0.0", - "@expo/plist": "^0.2.0", + "@expo/config-types": "^52.0.3", + "@expo/json-file": "~9.0.1", + "@expo/plist": "^0.2.1", "@expo/sdk-runtime-versions": "^1.0.0", "chalk": "^4.1.2", "debug": "^4.3.5", @@ -2210,9 +2212,9 @@ } }, "node_modules/@expo/config-types": { - "version": "52.0.1", - "resolved": "https://registry.npmjs.org/@expo/config-types/-/config-types-52.0.1.tgz", - "integrity": "sha512-vD8ZetyKV7U29lR6+NJohYeoLYTH+eNYXJeNiSOrWCz0witJYY11meMmEnpEaVbN89EfC6uauSUOa6wihtbyPQ==" + "version": "52.0.3", + "resolved": "https://registry.npmjs.org/@expo/config-types/-/config-types-52.0.3.tgz", + "integrity": "sha512-muxvuARmbysH5OGaiBRlh1Y6vfdmL56JtpXxB+y2Hfhu0ezG1U4FjZYBIacthckZPvnDCcP3xIu1R+eTo7/QFA==" }, "node_modules/@expo/config/node_modules/@babel/code-frame": { "version": "7.10.4", @@ -2261,9 +2263,9 @@ } }, "node_modules/@expo/env": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.0.tgz", - "integrity": "sha512-g2JYFqck3xKIwJyK+8LxZ2ENZPWtRgjFWpeht9abnKgzXVXBeSNECFBkg+WQjQocSIdxXhEWM6hz4ZAe7Tc4ng==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.1.tgz", + "integrity": "sha512-oDtbO3i9yXD1nx93acWiPTWGljJ3vABn35x1NAbqtQ2JL6mFOcRcArt1dwi4imZyLnG4VCcjabT9irj+LgYntw==", "dependencies": { "chalk": "^4.0.0", "debug": "^4.3.4", @@ -2373,9 +2375,9 @@ } }, "node_modules/@expo/json-file": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@expo/json-file/-/json-file-9.0.0.tgz", - "integrity": "sha512-M+55xFVrFzDcgMDf+52lPDLjKB5xwRfStWlv/b/Vu2OLgxGZLWpxoPYjlRoHqxjPbCQIi2ZCbobK+0KuNhsELg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@expo/json-file/-/json-file-9.0.1.tgz", + "integrity": "sha512-ZVPhbbEBEwafPCJ0+kI25O2Iivt3XKHEKAADCml1q2cmOIbQnKgLyn8DpOJXqWEyRQr/VWS+hflBh8DU2YFSqg==", "dependencies": { "@babel/code-frame": "~7.10.4", "json5": "^2.2.3", @@ -2494,9 +2496,9 @@ "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info." }, "node_modules/@expo/plist": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@expo/plist/-/plist-0.2.0.tgz", - "integrity": "sha512-F/IZJQaf8OIVnVA6XWUeMPC3OH6MV00Wxf0WC0JhTQht2QgjyHUa3U5Gs3vRtDq8tXNsZneOQRDVwpaOnd4zTQ==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@expo/plist/-/plist-0.2.1.tgz", + "integrity": "sha512-9TaXGuNxa0LQwHQn4rYiU6YaERv6dPnQgsdKWq2rKKTr6LWOtGNQCi/yOk/HBLeZSxBm59APT5/6x60uRvr0Mg==", "dependencies": { "@xmldom/xmldom": "~0.7.7", "base64-js": "^1.2.3", @@ -4886,6 +4888,17 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/config": { + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/config/-/config-3.3.12.tgz", + "integrity": "sha512-Vmx389R/QVM3foxqBzXO8t2tUikYZP64Q6vQxGrsMpREeJc/aWRnPRERXWsYzOHAumx/AOoILWe6nU3ZJL+6Sw==", + "dependencies": { + "json5": "^2.2.3" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -5540,13 +5553,24 @@ "react-native": "*" } }, + "node_modules/expo-config": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/expo-config/-/expo-config-1.0.0.tgz", + "integrity": "sha512-hHPk01bSkU7/qsnz1vpJctGe9TvwEhnOCIx/0MmJGwhXmwTrbfhIJDqq3xI1Tw576vxuacpdCsTOnmuzoxo9cA==", + "dependencies": { + "config": "^3.2.0" + }, + "bin": { + "expo-config": "cli.js" + } + }, "node_modules/expo-constants": { - "version": "17.0.3", - "resolved": "https://registry.npmjs.org/expo-constants/-/expo-constants-17.0.3.tgz", - "integrity": "sha512-lnbcX2sAu8SucHXEXxSkhiEpqH+jGrf+TF+MO6sHWIESjwOUVVYlT8qYdjR9xbxWmqFtrI4KV44FkeJf2DaFjQ==", + "version": "17.0.4", + "resolved": "https://registry.npmjs.org/expo-constants/-/expo-constants-17.0.4.tgz", + "integrity": "sha512-5c0VlZycmDyQUCMCr3Na3cpHAsVJJ+5o6KkkD4rmATQZ0++Xp/S2gpnjWyEo2riRmO91vxoyHwmAySXuktJddQ==", "dependencies": { - "@expo/config": "~10.0.4", - "@expo/env": "~0.4.0" + "@expo/config": "~10.0.8", + "@expo/env": "~0.4.1" }, "peerDependencies": { "expo": "*", diff --git a/frontend/package.json b/frontend/package.json index 5b61d0a..5b1d5da 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,7 +9,9 @@ "web": "expo start --web" }, "dependencies": { + "dotenv": "^16.4.7", "expo": "~52.0.23", + "expo-config": "^1.0.0", "expo-constants": "~17.0.3", "expo-linking": "~7.0.3", "expo-router": "~4.0.15", @@ -20,8 +22,8 @@ "react-native-reanimated": "^3.16.6", "react-native-safe-area-context": "^4.12.0", "react-native-screens": "~4.4.0", - "tailwindcss": "^3.4.17", - "react-native-web": "~0.19.13" + "react-native-web": "~0.19.13", + "tailwindcss": "^3.4.17" }, "devDependencies": { "@babel/core": "^7.20.0" diff --git a/nginx.conf b/nginx.conf index 4b5b7c1..d4c98d1 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,11 +2,15 @@ server { listen 80; server_name _; - location / { + location /api { proxy_pass http://backend:5000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + location / { + proxy_pass http://frontend:8081; + } } \ No newline at end of file