+ {{ state.active_product.description }} +
diff --git a/back/Dockerfile b/back/Dockerfile new file mode 100644 index 0000000..5a28038 --- /dev/null +++ b/back/Dockerfile @@ -0,0 +1,30 @@ +# Use the official Python image with version 3.11 +FROM python:3.11 + +# Set environment variables for Python and unbuffered mode +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 + +# RUN addgroup --system app && adduser --system --group app + +# Set the working directory to /app +ENV APP_HOME=/app +WORKDIR $APP_HOME +# Install deb pkgs for usb +RUN apt-get update + +# Install dependencies +COPY requirements.txt /app/ +RUN pip install --upgrade pip && pip install -r requirements.txt + +# Copy the current directory contents into the container at /app +COPY . $APP_HOME/ + +# Expose the port that Gunicorn will run on +EXPOSE 8000 + +# RUN python manage.py collectstatic -y +# RUN python manage.py makemigrations +# RUN python manage.py migrate + +CMD ["bash", "./docker-entrypoint.sh"] diff --git a/back/back/settings.py b/back/back/settings.py index 4b6207b..5ca2af2 100644 --- a/back/back/settings.py +++ b/back/back/settings.py @@ -32,6 +32,8 @@ ALLOWED_HOSTS = [ "127.0.0.1:8000", "192.168.103.159", "192.168.103.159:8000", + "back", + "back:8000", ] CSRF_TRUSTED_ORIGINS = ( "http://localhost", @@ -47,6 +49,9 @@ CORS_ORIGIN_WHITELIST = [ "http://127.0.0.1", "http://192.168.103.159", "http://192.168.103.159:8000", + "http://front:4173", + "http://front:5173", + "http://back:8000", ] # Application definition diff --git a/back/back/urls.py b/back/back/urls.py index 7dda663..767bc7b 100644 --- a/back/back/urls.py +++ b/back/back/urls.py @@ -22,4 +22,4 @@ from api import views urlpatterns = [ path("admin/", admin.site.urls), path("api/products", views.products), -] + static('/files', document_root='back/files') +] + static('/files', document_root='files') diff --git a/back/docker-entrypoint.sh b/back/docker-entrypoint.sh new file mode 100755 index 0000000..2c5e94f --- /dev/null +++ b/back/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Collect static files +echo "Collect static files" +python manage.py collectstatic --noinput + +# Apply database migrations +echo "Apply database migrations" +python manage.py makemigrations +python manage.py migrate + +# Start server +echo "Starting server" +python manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/back/requirements.txt b/back/requirements.txt new file mode 100644 index 0000000..3f30053 --- /dev/null +++ b/back/requirements.txt @@ -0,0 +1,12 @@ +asgiref==3.8.1 ; python_version >= "3.10" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" +django-cors-headers==4.3.1 ; python_version >= "3.10" and python_version < "4.0" +django==5.0.4 ; python_version >= "3.10" and python_version < "4.0" +djangorestframework==3.15.1 ; python_version >= "3.10" and python_version < "4.0" +mslex==1.2.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" +psutil==5.9.8 ; python_version >= "3.10" and python_version < "4.0" +sqlparse==0.5.0 ; python_version >= "3.10" and python_version < "4.0" +taskipy==1.12.2 ; python_version >= "3.10" and python_version < "4.0" +tomli==2.0.1 ; python_version >= "3.10" and python_version < "4.0" +typing-extensions==4.11.0 ; python_version >= "3.10" and python_version < "3.11" +tzdata==2024.1 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..57a5953 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,58 @@ +services: + back: + build: + context: ./back + dockerfile: Dockerfile + container_name: back + restart: always + expose: + - "8000" + environment: + - HOST_IP_ADDR=$HOST_IP_ADDR + healthcheck: + test: curl -f http://localhost:8000/api/products || exit 1 + interval: 5s + timeout: 3s + retries: 10 + start_interval: 10s + privileged: true + volumes: + - ./.env:/app/.env + networks: + - network + + front: + build: + context: ./front + dockerfile: Dockerfile + container_name: front + restart: always + expose: + - "4173" + depends_on: + back: + condition: service_healthy + networks: + - network + + nginx: + image: nginx:1.25 + container_name: nginx + restart: always + ports: + - "8098:80" + depends_on: + back: + condition: service_healthy + links: + - back:back + - front:front + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf + - ./nginx/conf.d:/etc/nginx/conf.d + networks: + - network + +networks: + network: + driver: bridge diff --git a/front/Dockerfile b/front/Dockerfile new file mode 100644 index 0000000..8af2174 --- /dev/null +++ b/front/Dockerfile @@ -0,0 +1,13 @@ +FROM node:21 + +RUN mkdir -p /src + +COPY package.json src/package.json + +WORKDIR /src + +RUN npm install + +COPY . /src +RUN npm run build +CMD npm run preview -- --host \ No newline at end of file diff --git a/front/src/App.vue b/front/src/App.vue index ca5ee27..6bb766d 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -2,10 +2,11 @@ import { onMounted, reactive } from 'vue'; import { ModelFbx } from 'vue-3d-model'; import { useProductStore } from './stores/product'; +import type { ProductInfo } from './stores/product'; import { SERVER_URL } from './constants' type StateType = { - active_product?: number + active_product?: ProductInfo } const products = useProductStore() @@ -37,8 +38,10 @@ onMounted(async () => {
+ {{ state.active_product.description }} +