diff --git a/backand/Dockerfile b/backand/Dockerfile index fb83523..8b6b529 100644 --- a/backand/Dockerfile +++ b/backand/Dockerfile @@ -42,11 +42,14 @@ COPY --from=builder /usr/local/bin/ /usr/local/bin/ # Copy application code with ownership COPY --chown=appuser:appuser . . +# Collect static files +RUN python manage.py collectstatic --noinput + # Switch to non-root user USER appuser # Expose Django port -EXPOSE 7080 +EXPOSE 7090 # Run Django with uvicorn -CMD ["uvicorn", "MPM:application", "--host", "0.0.0.0", "--port", "7080"] +CMD ["uvicorn", "MPM:application", "--host", "0.0.0.0", "--port", "7090"] diff --git a/backand/MPM/settings.py b/backand/MPM/settings.py index 71e2b53..11623f1 100644 --- a/backand/MPM/settings.py +++ b/backand/MPM/settings.py @@ -122,6 +122,11 @@ USE_TZ = True # https://docs.djangoproject.com/en/5.2/howto/static-files/ STATIC_URL = 'static/' +STATIC_ROOT = BASE_DIR / "staticfiles" + +# Proxy settings +USE_X_FORWARDED_HOST = True +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Default primary key field type # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field diff --git a/docker-compose.yml b/docker-compose.yml index f1e4fb3..2a96c27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,12 @@ services: backend: container_name: mayo-production-manager-backend build: - context: ./backend + context: ./backand dockerfile: Dockerfile - environment: - NODE_ENV: production + env_file: + - ./backand/.env + volumes: + - static_content:/app/staticfiles ports: - 7090:7090 restart: unless-stopped @@ -17,6 +19,11 @@ services: dockerfile: Dockerfile environment: NODE_ENV: production + volumes: + - static_content:/static_django ports: - 7080:7080 restart: unless-stopped + +volumes: + static_content: diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 290c104..0fff65b 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -30,41 +30,35 @@ http { listen 7080; server_name localhost; - root /usr/share/nginx/html; - index index.html; + # Serwowanie statycznych plików Django Admina + location /mayo-manager/static/ { + alias /static_django/; + } + # Serwowanie aplikacji Vue location /mayo-manager/ { - try_files $uri $uri/ /index.html; + alias /usr/share/nginx/html/; + try_files $uri $uri/ /mayo-manager/index.html; } - location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg|map)$ { - expires 1y; - access_log off; - add_header Cache-Control "public, immutable"; - add_header X-Content-Type-Options nosniff; - } - - # location /assets/ { - # expires 1y; - # add_header Cache-Control "public, immutable"; - # add_header X-Content-Type-Options nosniff; - # } - - # BACKEND API + # Proxy do API Django location /mayo-manager/api/ { - proxy_pass http://mayo-production-manager-backend:7090/; + proxy_pass http://mayo-production-manager-backend:7090/api/; 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; } - # DJANGO ADMIN + # Proxy do panelu admina Django location /mayo-manager/admin/ { proxy_pass http://mayo-production-manager-backend:7090/admin/; 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; } - error_page 404 /index.html; + + error_page 404 /mayo-manager/index.html; } } \ No newline at end of file diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 4217010..b060ace 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -6,6 +6,7 @@ import vueDevTools from 'vite-plugin-vue-devtools' // https://vite.dev/config/ export default defineConfig({ + base: '/mayo-manager/', plugins: [ vue(), vueDevTools(),