-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sl.ars
committed
Feb 27, 2025
1 parent
8cce164
commit e29b7de
Showing
7 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
# Use Node.js base image | ||
FROM node:20 | ||
|
||
# Set working directory | ||
FROM node:22 AS builder | ||
|
||
WORKDIR /app | ||
|
||
# Copy package files | ||
|
||
COPY frontend/package.json frontend/package-lock.json ./ | ||
RUN npm install --frozen-lockfile | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy app source | ||
COPY frontend ./ | ||
|
||
# Build frontend | ||
RUN npm run build | ||
|
||
# Expose port | ||
EXPOSE 5173 | ||
|
||
# Start server | ||
CMD ["npm", "run", "preview"] | ||
FROM nginx:latest AS production | ||
|
||
WORKDIR /app | ||
|
||
|
||
RUN rm -rf /usr/share/nginx/html/* | ||
RUN rm -rf /app/frontend/* | ||
|
||
COPY --from=builder /app/dist /app/frontend | ||
|
||
|
||
COPY nginx/nginx.conf /etc/nginx/nginx.conf | ||
|
||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
#!/bin/sh | ||
|
||
echo "Waiting for PostgreSQL to start..." | ||
while ! nc -z db 5432; do | ||
while ! timeout 1 bash -c 'cat < /dev/null > /dev/tcp/db/5432'; do | ||
sleep 1 | ||
done | ||
echo "PostgreSQL started." | ||
|
||
# Collect static files | ||
poetry run python manage.py collectstatic --noinput | ||
|
||
# Run migrations | ||
poetry run python manage.py migrate --noinput | ||
|
||
# Collect static files | ||
poetry run python manage.py collectstatic --noinput | ||
|
||
# Start Gunicorn server | ||
exec poetry run gunicorn trading_app.wsgi:application --bind 0.0.0.0:8000 | ||
|
||
# Start Daphne in the background | ||
echo "Starting Daphne..." | ||
poetry run daphne -b 0.0.0.0 -p 8001 trading_app.asgi:application & | ||
|
||
# Start Gunicorn in the foreground | ||
echo "Starting Gunicorn..." | ||
exec poetry run gunicorn trading_app.wsgi:application --bind 0.0.0.0:8000 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,69 @@ | ||
events {} | ||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
server { | ||
listen 80; | ||
server_name _; | ||
|
||
|
||
location / { | ||
root /app/frontend; | ||
index index.html; | ||
try_files $uri /index.html; | ||
} | ||
|
||
|
||
location /api/ { | ||
proxy_pass http://backend:8000/; | ||
proxy_pass http://backend:8000; | ||
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 / { | ||
root /app/frontend/build; | ||
index index.html; | ||
try_files $uri /index.html; | ||
location /admin/ { | ||
proxy_pass http://backend:8000; | ||
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 /static/ { | ||
alias /app/staticfiles/; | ||
autoindex on; | ||
} | ||
|
||
location /media/ { | ||
alias /app/media; | ||
autoindex on; | ||
} | ||
|
||
|
||
# WebSocket support (Django Channels) | ||
location /ws/ { | ||
proxy_pass http://backend:8001/ws/; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
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 /swagger/ { | ||
proxy_pass http://backend:8000/swagger/; | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters