Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker for frontend finished #28

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
19 changes: 19 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion frontend/app/_layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {

Expand Down
82 changes: 53 additions & 29 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading