diff --git a/docker-compose.yml b/docker-compose.yml index ca30511e2e024466e81e51eb1e10c3a177bad013..212118e141fde47c7806196928bb9bf927b5d067 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.9' services: database: @@ -13,12 +13,11 @@ services: - neo4j-data:/var/lib/neo4j/data container_name: neo4j redis: - image: "redis:alpine" + image: "redis:7-alpine" ports: - "6379:6379" sg-backend: build: ./sg-backend - command: sh -c "/wait && uvicorn main:app --reload --host 0.0.0.0" environment: - FRONTEND_URL="http://localhost" - NEO4J_URI=neo4j://database:7687 @@ -26,8 +25,9 @@ services: - NEO4J_PASSWORD=test - WAIT_HOSTS=database:7474 - WAIT_HOSTS_TIMEOUT=300 - - WAIT_SLEEP_INTERVAL=5 + - WAIT_SLEEP_INTERVAL=3 - WAIT_HOST_CONNECT_TIMEOUT=30 + - REDIS_URL=redis://redis:6379 volumes: - ./sg-backend:/code depends_on: diff --git a/sg-backend/Dockerfile b/sg-backend/Dockerfile index c8b1dafc6c90847a115101449a1785f1e0e2ff97..d6aa430b5fd33f1ec9a6d989c32cf7de417c3f8d 100644 --- a/sg-backend/Dockerfile +++ b/sg-backend/Dockerfile @@ -1,6 +1,9 @@ FROM python:3.10-slim + +ENV POETRY_VERSION=1.2 +ENV WAIT_VERSION 2.7.2 + WORKDIR /code -ENV POETRY_VERSION=1.2.2 RUN pip install "poetry==$POETRY_VERSION" @@ -9,8 +12,10 @@ COPY poetry.lock pyproject.toml /code/ RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi COPY . /code -EXPOSE 8000 -ENV WAIT_VERSION 2.7.2 ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait -RUN chmod +x /wait \ No newline at end of file +RUN chmod +x /wait + +EXPOSE 8000 + +CMD /wait && uvicorn main:app --reload --host 0.0.0.0 --port 8000 diff --git a/sg-backend/cache.py b/sg-backend/cache.py index 95a0cf009771b2c0a7dd532dbf422c944e428688..233e2542cc2aeb916abc31c41cdaef5ec3c81bed 100644 --- a/sg-backend/cache.py +++ b/sg-backend/cache.py @@ -1,15 +1,16 @@ +import os + from fastapi_cache import FastAPICache from fastapi_cache.backends.redis import RedisBackend - from redis import asyncio as aioredis class RedisCache: def __init__(self): - redis = aioredis.from_url("redis://redis", encoding="utf8", decode_responses=True) + redis = aioredis.from_url(os.getenv("REDIS_URL"), encoding="utf8", decode_responses=True) FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache") @staticmethod async def clear_softwares_cache(): await FastAPICache.clear(key="software") - await FastAPICache.clear(key="software-graph") \ No newline at end of file + await FastAPICache.clear(key="software-graph") diff --git a/sg-frontend/Dockerfile b/sg-frontend/Dockerfile index 7fc899b59142858dab8e3330dd335ee0028dc265..a2ed67e1d625ae54dd728105a0363a44aa5e71b6 100644 --- a/sg-frontend/Dockerfile +++ b/sg-frontend/Dockerfile @@ -7,7 +7,6 @@ RUN npm install COPY . /app -ENV VITE_BACKEND_URL=http://sg-backend:8000 EXPOSE 5173 -CMD ["npm","run", "dev", "--","--host", "0.0.0.0", "--port", "5173"] \ No newline at end of file +CMD npm run dev --host 0.0.0.0 --port 5173 \ No newline at end of file diff --git a/sg-frontend/build.Dockerfile b/sg-frontend/build.Dockerfile index 18ffdede8dde4c9be06b0d4173f940bf2c073b6f..957f336a23c9bde5b85be71676c2245fcaf5cf15 100644 --- a/sg-frontend/build.Dockerfile +++ b/sg-frontend/build.Dockerfile @@ -2,11 +2,10 @@ FROM node:18-slim WORKDIR /app COPY . /app -#RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm RUN npm install RUN npm run build -ENV VITE_BACKEND_URL=http://sg-backend:8000 + EXPOSE 4173 -CMD ["npm","run", "preview", "--","--host", "0.0.0.0", "--port", "4173"] \ No newline at end of file +CMD npm run preview --host 0.0.0.0 --port 4173 \ No newline at end of file diff --git a/sg-frontend/package-lock.json b/sg-frontend/package-lock.json index 54ca3c28a85d4ab28b9f400fe296ef26373e2905..1a0ccc8fed85ad76bcde0b720ef0650de442a5e3 100644 --- a/sg-frontend/package-lock.json +++ b/sg-frontend/package-lock.json @@ -387,38 +387,6 @@ "node": ">=12" } }, - "node_modules/esbuild-darwin-64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.14.tgz", - "integrity": "sha512-ToNuf1uifu8hhwWvoZJGCdLIX/1zpo8cOGnT0XAhDQXiKOKYaotVNx7pOVB1f+wHoWwTLInrOmh3EmA7Fd+8Vg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-darwin-arm64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.14.tgz", - "integrity": "sha512-KgGP+y77GszfYJgceO0Wi/PiRtYo5y2Xo9rhBUpxTPaBgWDJ14gqYN0+NMbu+qC2fykxXaipHxN4Scaj9tUS1A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/esbuild-freebsd-64": { "version": "0.15.14", "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.14.tgz", @@ -1832,8 +1800,6 @@ "@esbuild/linux-loong64": "0.15.14", "esbuild-android-64": "0.15.14", "esbuild-android-arm64": "0.15.14", - "esbuild-darwin-64": "0.15.14", - "esbuild-darwin-arm64": "0.15.14", "esbuild-freebsd-64": "0.15.14", "esbuild-freebsd-arm64": "0.15.14", "esbuild-linux-32": "0.15.14", @@ -1866,20 +1832,6 @@ "dev": true, "optional": true }, - "esbuild-darwin-64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.14.tgz", - "integrity": "sha512-ToNuf1uifu8hhwWvoZJGCdLIX/1zpo8cOGnT0XAhDQXiKOKYaotVNx7pOVB1f+wHoWwTLInrOmh3EmA7Fd+8Vg==", - "dev": true, - "optional": true - }, - "esbuild-darwin-arm64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.14.tgz", - "integrity": "sha512-KgGP+y77GszfYJgceO0Wi/PiRtYo5y2Xo9rhBUpxTPaBgWDJ14gqYN0+NMbu+qC2fykxXaipHxN4Scaj9tUS1A==", - "dev": true, - "optional": true - }, "esbuild-freebsd-64": { "version": "0.15.14", "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.14.tgz",