diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..16af5b7dc5465d843629e0c9d92965a150cba006 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +__pycache__/ +*.pyc +*.pyo +*.git +.env diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2194b4320d7eef0b48db81dfe9bac01e7ee30e2a --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,41 @@ +FROM python:3.12-slim-bullseye +# Use the Debian 11 base image + +# Set the working directory in the container +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + unixodbc-dev \ + libmariadb-dev \ + libssl-dev \ + gcc \ + curl \ + gpg && \ + rm -rf /var/lib/apt/lists/* + +# Download and install the msodbcsql18 driver for arm64-compatible base image +RUN apt-get update && apt-get install -y --no-install-recommends unixodbc-dev curl apt-transport-https gnupg && \ + curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \ + curl -sSL https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ + apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc + + +# Install pyodbc +RUN pip install pyodbc + +# Copy the requirements file +COPY requirements.txt /app/requirements.txt + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code +COPY . /app + +# Expose the application port +EXPOSE 8000 + +# Command to run the application +CMD ["python", "main.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..f71586ef2cabcea5abb976c900844da5fe9c7734 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3.9" +services: + backend: + build: + context: . # Build the image from the parent directory + dockerfile: backend/Dockerfile + + ports: + - "8000:8000" # Map container port 8000 to host + volumes: + - ./backend:/app/backend # Map backend directory to /app/backend + - ./app:/app/app # Map app directory to /app/app + - ./config_dev.json:/app/backend/config_dev.json # Explicitly map config_dev.json + + working_dir: /app/backend # Set working directory to backend/ + command: python main.py # Command to run main.py + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + ports: + - "5173:5173" # Map container port 5173 to host + + logistics_frontend: + build: + context: ./logistics + dockerfile: Dockerfile + ports: + - "3000:3000" + depends_on: + - frontend # Ensure OpenAPI models are available \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2546daa175e97110da32d0bd44fac5ce62ccf1f --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,16 @@ +FROM node:18 + + # Set working directory + WORKDIR /app + + # Copy dependency files and install dependencies + COPY package*.json ./ + RUN npm install + + # Copy rest of the code and build the application + COPY . . + RUN npm run build + + # Use a simple HTTP server to serve the built static files + EXPOSE 5173 + CMD ["npx", "vite", "preview", "--port", "5173"] \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c897724197062bb83f79a2362908c7ebe0d54fea..25f351014b13fd9424b897e8f28ddf3a1d9d221e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -278,25 +278,25 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", - "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", + "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", "license": "MIT", "dependencies": { - "@babel/template": "^7.25.9", - "@babel/types": "^7.26.0" + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.5.tgz", - "integrity": "sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.10.tgz", + "integrity": "sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==", "license": "MIT", "dependencies": { - "@babel/types": "^7.26.5" + "@babel/types": "^7.26.10" }, "bin": { "parser": "bin/babel-parser.js" @@ -353,9 +353,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", - "integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.10.tgz", + "integrity": "sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==", "license": "MIT", "dependencies": { "regenerator-runtime": "^0.14.0" @@ -365,14 +365,14 @@ } }, "node_modules/@babel/template": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", - "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz", + "integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==", "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.25.9", - "@babel/parser": "^7.25.9", - "@babel/types": "^7.25.9" + "@babel/code-frame": "^7.26.2", + "@babel/parser": "^7.26.9", + "@babel/types": "^7.26.9" }, "engines": { "node": ">=6.9.0" @@ -406,9 +406,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.5.tgz", - "integrity": "sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz", + "integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==", "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.25.9", @@ -3414,9 +3414,9 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", - "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz", + "integrity": "sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", diff --git a/logistics/Dockerfile b/logistics/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ca78bcce0a9a772f0dc65fa95ac62eee37ca0a3 --- /dev/null +++ b/logistics/Dockerfile @@ -0,0 +1,16 @@ +FROM node:18-alpine + +WORKDIR /app + +# Copy only the necessary package files first +COPY package*.json ./ +RUN npm install + +# Copy OpenAPI models into the build context +COPY openapi ./openapi + +# Copy the rest of the logistics app files +COPY . . + +# Build the application +RUN npm run build diff --git a/testfunctions.ipynb b/testfunctions.ipynb index ef67de427c50737af9ff079abc2988c41f56305c..2b392781ecb861bb3e9f769bc48a59aedcfa3e37 100644 --- a/testfunctions.ipynb +++ b/testfunctions.ipynb @@ -3,8 +3,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-03-11T15:04:51.407218Z", - "start_time": "2025-03-11T15:04:51.403058Z" + "end_time": "2025-03-14T12:34:36.688448Z", + "start_time": "2025-03-14T12:34:36.274011Z" } }, "cell_type": "code", @@ -46,7 +46,7 @@ ] } ], - "execution_count": 48 + "execution_count": 1 }, { "metadata": {}, @@ -486,8 +486,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-03-07T20:51:14.203996Z", - "start_time": "2025-03-07T20:51:14.134135Z" + "end_time": "2025-03-14T12:37:36.649779Z", + "start_time": "2025-03-14T12:37:36.597340Z" } }, "cell_type": "code", @@ -499,14 +499,14 @@ "import requests\n", "\n", "# List of file paths to the images you want to upload\n", - "file_paths = [\n", - " \"backend/tests/sample_image/0_200.jpg\",\n", - " \"backend/tests/sample_image/90_200.jpg\",\n", - " \"backend/tests/sample_image/0_700.jpg\",\n", - " \"backend/tests/sample_image/90_700.jpg\",\n", - "]\n", + "#file_paths = [\n", + "# \"backend/tests/sample_image/0_200.jpg\",\n", + "# \"backend/tests/sample_image/90_200.jpg\",\n", + "# \"backend/tests/sample_image/0_700.jpg\",\n", + "# \"backend/tests/sample_image/90_700.jpg\",\n", + "#]\n", "\n", - "#file_paths = [\"backend/tests/sample_image/mount.jpeg.jpg\"]\n", + "file_paths = [\"backend/tests/sample_image/mount.jpeg.jpg\"]\n", "\n", "\n", "# Sample ID (ensure this exists on your backend)\n", @@ -551,40 +551,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "Uploading 0_200.jpg...\n", - "API Response for 0_200.jpg:\n", - "200\n", - "{'pgroup': 'p20003', 'sample_id': 299, 'sample_event_id': 572, 'filepath': 'images/p20003/2025-03-07/Dewar Five/PKK007/16/Mounting_2025-03-06_14-31-00/0_200.jpg', 'status': 'active', 'comment': None, 'id': 2}\n", - "Uploading 90_200.jpg...\n", - "API Response for 90_200.jpg:\n", - "200\n", - "{'pgroup': 'p20003', 'sample_id': 299, 'sample_event_id': 572, 'filepath': 'images/p20003/2025-03-07/Dewar Five/PKK007/16/Mounting_2025-03-06_14-31-00/90_200.jpg', 'status': 'active', 'comment': None, 'id': 3}\n", - "Uploading 0_700.jpg...\n", - "API Response for 0_700.jpg:\n", - "200\n", - "{'pgroup': 'p20003', 'sample_id': 299, 'sample_event_id': 572, 'filepath': 'images/p20003/2025-03-07/Dewar Five/PKK007/16/Mounting_2025-03-06_14-31-00/0_700.jpg', 'status': 'active', 'comment': None, 'id': 4}\n", - "Uploading 90_700.jpg...\n", - "API Response for 90_700.jpg:\n", - "200\n", - "{'pgroup': 'p20003', 'sample_id': 299, 'sample_event_id': 572, 'filepath': 'images/p20003/2025-03-07/Dewar Five/PKK007/16/Mounting_2025-03-06_14-31-00/90_700.jpg', 'status': 'active', 'comment': None, 'id': 5}\n" + "Uploading mount.jpeg.jpg...\n", + "API Response for mount.jpeg.jpg:\n", + "404\n", + "{'detail': 'Sample not found'}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", - " warnings.warn(\n", - "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", - " warnings.warn(\n", - "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", - " warnings.warn(\n", "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] } ], - "execution_count": 47 + "execution_count": 2 }, { "metadata": {},