-
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.
Merge pull request #26 from SimerusM/productionize
Productionize
- Loading branch information
Showing
10 changed files
with
186 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
*.env |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3.10.10 | ||
|
||
WORKDIR /app/server | ||
|
||
# install packages | ||
COPY requirements.txt ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
RUN pip install gunicorn==23.0.0 gevent==24.2.1 gevent-websocket==0.10.1 | ||
|
||
COPY . . | ||
|
||
CMD ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "1", "--threads", "100", "-b", "0.0.0.0:8080", "app:app"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
services: | ||
api_server: | ||
build: | ||
context: ./api-server | ||
dockerfile: Dockerfile.prod | ||
container_name: api_server | ||
environment: | ||
- PRODUCTION=true | ||
networks: | ||
- app_network | ||
|
||
nginx: | ||
container_name: nginx | ||
image: jonasal/nginx-certbot | ||
restart: always | ||
environment: | ||
- [email protected] | ||
- CERTBOT_DOMAINS=vmeet.duckdns.org | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
volumes: | ||
- nginx_secrets:/etc/letsencrypt | ||
- ./user_conf.d:/etc/nginx/user_conf.d | ||
- ./client/build:/usr/share/nginx/html | ||
depends_on: | ||
- api_server | ||
networks: | ||
- app_network | ||
|
||
volumes: | ||
nginx_secrets: | ||
|
||
networks: | ||
app_network: | ||
driver: bridge |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
export REACT_APP_API_URL="https://vmeet.duckdns.org" | ||
export PRODUCTION="true" | ||
|
||
(cd client && rm -rf build && npm run build) | ||
|
||
DOWN_COMMAND="down --remove-orphans" | ||
if command -v docker-compose &> /dev/null; then | ||
docker-compose $DOWN_COMMAND | ||
elif command -v docker compose &> /dev/null; then | ||
docker compose $DOWN_COMMAND | ||
else | ||
echo "Error: Neither 'docker-compose' nor 'docker compose' is installed." | ||
exit 1 | ||
fi | ||
|
||
COMPOSE_COMMAND="-f docker-compose.prod.yml up --build -d" | ||
|
||
if command -v docker-compose &> /dev/null; then | ||
docker-compose $COMPOSE_COMMAND "$@" | ||
elif command -v docker compose &> /dev/null; then | ||
docker compose $COMPOSE_COMMAND "$@" | ||
else | ||
echo "Error: Neither 'docker-compose' nor 'docker compose' is installed." | ||
exit 1 | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
server { | ||
listen 80; | ||
server_name vmeet.duckdns.org; | ||
|
||
# Redirect all HTTP traffic to HTTPS | ||
return 301 https://$host$request_uri; | ||
} | ||
|
||
server { | ||
listen 443 ssl http2; | ||
server_name vmeet.duckdns.org; | ||
|
||
# SSL certificates (use Let's Encrypt certificates or any other trusted provider) | ||
ssl_certificate /etc/letsencrypt/live/vmeet.duckdns.org/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/vmeet.duckdns.org/privkey.pem; | ||
ssl_protocols TLSv1.2 TLSv1.3; | ||
ssl_ciphers HIGH:!aNULL:!MD5; | ||
ssl_prefer_server_ciphers on; | ||
|
||
# Serve React app (single-page application) | ||
location / { | ||
root /usr/share/nginx/html; | ||
try_files $uri /index.html; | ||
} | ||
|
||
# Proxy settings for API requests | ||
location /api/ { | ||
proxy_pass http://api_server:8080; | ||
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; | ||
} | ||
|
||
# Proxy settings for WebSocket connections | ||
location /socket.io/ { | ||
proxy_pass http://api_server:8080; | ||
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; | ||
proxy_read_timeout 60s; | ||
proxy_send_timeout 60s; | ||
proxy_buffering off; | ||
} | ||
|
||
# Additional settings for better security (optional) | ||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; | ||
add_header X-Frame-Options DENY; | ||
add_header X-Content-Type-Options nosniff; | ||
|
||
# Logging | ||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
# Increase buffer and timeout settings if needed | ||
client_max_body_size 100M; | ||
proxy_read_timeout 3600s; | ||
proxy_send_timeout 3600s; | ||
} |