Skip to content

Commit

Permalink
feat(deployment): frontend hmr
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Mar 22, 2024
1 parent fe1328f commit 558aa56
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
24 changes: 9 additions & 15 deletions data/nginx/nginx.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http {
}

upstream hmr {
server frontend:5174;
server frontend:443;
}

server {
Expand Down Expand Up @@ -50,6 +50,14 @@ http {
proxy_redirect off;
}

location /hmr {
proxy_pass http://hmr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}


location / {
proxy_pass http://frontend;
Expand All @@ -58,18 +66,4 @@ http {
proxy_redirect off;
}
}

server {
listen 5174 ssl;

ssl_certificate ssl/certificate.crt;
ssl_certificate_key ssl/private.key;

location / {
proxy_pass http://hmr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
5 changes: 2 additions & 3 deletions development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ echo "Checking environment file..."

if ! [ -f .env ]; then
cp .dev.env .env
read -s -p "Enter a random string for the django secret (just smash keyboard): " new_secret
sed -i "s/^DJANGO_SECRET_KEY=.*/DJANGO_SECRET_KEY=$new_secret/" .env
sed -i "s/^DJANGO_SECRET_KEY=.*/DJANGO_SECRET_KEY=totally_random_key_string/" .env
echo "Created environment file"
fi

Expand Down Expand Up @@ -65,7 +64,7 @@ if [ "$backend" = true ] && [ "$frontend" = true ]; then
elif [ "$frontend" = true ]; then
docker-compose -f development.yml logs --follow --tail 50 frontend
else
docker-compose -f development.yml logs --follow --tail 50 backend
docker-compose -f development.yml logs --follow --tail 50 frontend
fi

echo "Cleaning up..."
Expand Down
13 changes: 6 additions & 7 deletions development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ services:
- 80:80
- 443:443
- 8080:8080
- 5174:5174
volumes:
- $DATA_DIR/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
- $SSL_DIR:/etc/nginx/ssl:ro
- ${DATA_DIR}/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
- ${SSL_DIR}:/etc/nginx/ssl:ro
depends_on:
- backend
- frontend
Expand All @@ -55,7 +54,7 @@ services:
expose:
- 8080
volumes:
- $BACKEND_DIR:/code
- ${BACKEND_DIR}:/code

celery:
<<: *common-keys-selab
Expand All @@ -65,7 +64,7 @@ services:
dockerfile: Dockerfile.dev
command: celery -A ypovoli worker -l DEBUG
volumes:
- $BACKEND_DIR:/code
- ${BACKEND_DIR}:/code
depends_on:
- backend
- redis
Expand All @@ -80,7 +79,7 @@ services:
expose:
- 5173
volumes:
- $FRONTEND_DIR:/app
- ${FRONTEND_DIR}:/app
depends_on:
- backend

Expand All @@ -95,5 +94,5 @@ services:
- $REDIS_PORT
entrypoint: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- $DATADIR/redis:/data
- ${DATA_DIR}/redis:/data

15 changes: 12 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'vite'
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -12,8 +12,17 @@ export default defineConfig({
}
},
server: {
host: '0.0.0.0',
port: 5173,
proxy: {
'/hmr': {
target: 'ws://localhost:5173',
ws: true
},
},
hmr: {
port: 5174
path: "/hmr",
port: 443
}
}
});
2 changes: 1 addition & 1 deletion production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:
dockerfile: Dockerfile.prod
command: celery -A ypovoli worker -l ERROR
volumes:
- $BACKEND_DIR:/code
- ${BACKEND_DIR}:/code
depends_on:
- backend
- redis
Expand Down

0 comments on commit 558aa56

Please sign in to comment.