diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9e00d76 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.git +**/.github +**/.venv +**/node_modules +**/dist +**/build +**/out +**/__pycache__ +**/*.pyc +**/*.pyo +**/*.pyd +**/*.log +**/.DS_Store +**/Thumbs.db +**/.vscode +**/.idea +**/coverage +**/tmp +**/.pytest_cache +**/.mypy_cache +**/.ruff_cache +**/CMakeUserPresets.json +**/compile_commands.json +**/vcpkg +**/third_party/pdfium/depot_tools +**/third_party/pdfium/checkout +**/third_party/pdfium/install +**/third_party/skia/depot_tools +**/third_party/skia/checkout +**/third_party/skia/install diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5358d22 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +services: + gateway: + build: + context: ./gateway + dockerfile: Dockerfile + image: pdf-engine-gateway:dev + container_name: pdf-engine-gateway + environment: + PDFENGINE_ENVIRONMENT: dev + PDFENGINE_ENGINE_AVAILABLE: "false" + PORT: 8000 + ports: + - "8000:8000" + volumes: + - ./gateway:/home/app + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health').read()" ] + interval: 20s + timeout: 5s + retries: 5 + start_period: 10s + restart: unless-stopped + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + target: development + image: pdf-engine-frontend:dev + container_name: pdf-engine-frontend + environment: + VITE_GATEWAY_URL: http://gateway:8000 + ports: + - "5173:5173" + volumes: + - ./frontend:/app + - /app/node_modules + depends_on: + - gateway + restart: unless-stopped diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..0fbfdc0 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,7 @@ +node_modules/ +dist/ +.vite/ +.git/ +.gitignore +*.log +.DS_Store diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..6df2f83 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,20 @@ +FROM node:20-alpine AS base +ENV NODE_ENV=development +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +FROM base AS development +COPY . . +EXPOSE 5173 +CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"] + +FROM base AS build +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine AS production +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/gateway/.dockerignore b/gateway/.dockerignore new file mode 100644 index 0000000..cd215ec --- /dev/null +++ b/gateway/.dockerignore @@ -0,0 +1,13 @@ +__pycache__/ +*.py[cod] +*.pyo +*.pyd +.venv/ +.pytest_cache/ +.ruff_cache/ +.mypy_cache/ +.coverage +*.log +.DS_Store +.git/ +.gitignore diff --git a/gateway/Dockerfile b/gateway/Dockerfile new file mode 100644 index 0000000..b577a8f --- /dev/null +++ b/gateway/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.11-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PORT=8000 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + ninja-build \ + pkg-config \ + git \ + libjpeg-dev \ + zlib1g-dev \ + libpng-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN groupadd --system app \ + && useradd --system --gid app --create-home --home-dir /home/app app + +WORKDIR /home/app + +COPY pyproject.toml README.md ./ +RUN python -m pip install --upgrade pip \ + && pip install --no-cache-dir -e ".[dev]" + +COPY app ./app +COPY tests ./tests + +RUN chown -R app:app /home/app +USER app + +EXPOSE 8000 + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]