Skip to content

Commit

Permalink
update deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim2121512 committed Nov 28, 2024
1 parent 74ff7ed commit 8893522
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 66 deletions.
3 changes: 1 addition & 2 deletions backend/deployment/dev/Dockerfile → backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ FROM python:3.11

WORKDIR /app

COPY ../.. .
COPY . .

RUN python -m venv /.venv

RUN /.venv/bin/pip install --no-cache-dir -r requirements.txt

Check failure on line 9 in backend/Dockerfile

View workflow job for this annotation

GitHub Actions / Проверка наличия тега 0.8 и работоспособности docker-compose

DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.

ENV PATH="/.venv/bin:$PATH"
ENV ENV="dev"
EXPOSE 8000

CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.11

WORKDIR /app

COPY ../.. .
COPY . .

RUN python -m venv /.venv

Expand Down
40 changes: 0 additions & 40 deletions backend/deployment/dev/docker-compose.yml

This file was deleted.

6 changes: 0 additions & 6 deletions backend/src/core/entities/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ def validate_images(cls, values):
if images:
if len(images) > 10:
raise ValueError("No more than 10 images are allowed.")
import base64
for image in images:
try:
base64.b64decode(image)
except Exception:
raise ValueError("Each image must be a valid Base64 string.")
return values

class Config:
Expand Down
18 changes: 9 additions & 9 deletions backend/test/unit/services/test_tool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ def tool_service(tool_repo, category_repo, type_repo, paths_config, urls_config,
@pytest.fixture
def tool_create():
return ToolCreate(
name="test_name",
name="test-name",
dailyPrice=100.0,
totalPrice=5000,
images=["base64img1", "base64img2"],
features={"param1": "key1", "param2": "key2"},
category="test_category",
type="test_type",
description="test_description"
category="test-category",
type="test-type",
description="test-description"
)

@pytest.fixture
def tool_details():
return ToolDetails(
id="test_id",
name="test_name",
id="test-id",
name="test-name",
dailyPrice = 100.0,
images=["image1.png", "image2.png"],
rating=4.6,
features={"param1": "key1", "param2": "key2"},
category="test_category",
type="test_type",
description="test_description"
category="test-category",
type="test-type",
description="test-description"
)

@pytest.fixture
Expand Down
53 changes: 53 additions & 0 deletions deployment/dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.8'

services:
mongodb:
image: mongo:7.0
container_name: mongodb
hostname: mongodb
# ports:
# - "127.0.0.1:27017:27017" # для просмотра коллекций в mongoDB compass
env_file:
- ../../backend/env/dev/.env.dev.db
- ../../backend/env/.env.collections
volumes:
- ../init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
- mongo_data:/data/db
networks:
- app_network

backend:
build:
context: ../../backend
dockerfile: Dockerfile
container_name: backend
image: backend_app:1.0
ports:
- "127.0.0.1:8000:8000"
depends_on:
- mongodb
volumes:
- resources_data:/app/resources
networks:
- app_network

frontend:
build:
context: ../../frontend
dockerfile: Dockerfile
container_name: frontend
image: frontend_app:1.0
ports:
- "127.0.0.1:5173:5173"
depends_on:
- backend
networks:
- app_network

volumes:
mongo_data:
resources_data:

networks:
app_network:
driver: bridge
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ services:
container_name: test_mongodb
hostname: test_mongodb
env_file:
- ../../env/test/.env.test.db
- ../../env/.env.collections
- ../../backend/env/test/.env.test.db
- ../../backend/env/.env.collections
volumes:
- ../init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
networks:
- mongo_network

test_fast_api:
test_backend:
build:
context: ../../
dockerfile: ./deployment/test/Dockerfile
container_name: test_fast_api
context: ../../backend
dockerfile: Dockerfile.test
container_name: test_backend
depends_on:
- test_mongodb
networks:
Expand Down
8 changes: 8 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

CMD ["npm", "run", "dev"]
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host 0.0.0.0",
"build": "vite build",
"preview": "vite preview"
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/admin/AdminTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
<div class="flex">
<div v-for="tool in tools[currentPage]">
<ToolCard
:image="tool.image"
:image="tool.images[0]"
:title="tool.name"
:description="tool.description"
:rating="tool.rating"
Expand Down

0 comments on commit 8893522

Please sign in to comment.