Skip to content

Commit df71f3e

Browse files
committed
feat: add docker infrastructure and remove legacy scripts
1 parent 590b7b5 commit df71f3e

11 files changed

Lines changed: 148 additions & 169 deletions

File tree

infra/docker/api.Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM node:22-slim AS base
2+
3+
# Install pnpm
4+
ENV PNPM_HOME="/pnpm"
5+
ENV PATH="$PNPM_HOME:$PATH"
6+
RUN corepack enable
7+
8+
# Install required dependencies for Camoufox/Playwright
9+
RUN apt-get update && apt-get install -y \
10+
libnss3 \
11+
libnspr4 \
12+
libatk1.0-0 \
13+
libatk-bridge2.0-0 \
14+
libcups2 \
15+
libdrm2 \
16+
libxkbcommon0 \
17+
libxcomposite1 \
18+
libxdamage1 \
19+
libxfixes3 \
20+
libxrandr2 \
21+
libgbm1 \
22+
libasound2 \
23+
libpango-1.0-0 \
24+
libcairo2 \
25+
python3 \
26+
python3-pip \
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
WORKDIR /app
30+
31+
# Copy workspace configuration
32+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
33+
COPY nx.json ./
34+
35+
# Copy API app
36+
COPY apps/api ./apps/api
37+
38+
# Install dependencies
39+
RUN pnpm install --frozen-lockfile
40+
41+
# Generate Prisma Client and fetch Camoufox
42+
WORKDIR /app/apps/api
43+
RUN pnpm exec prisma generate
44+
RUN pnpm exec camoufox-js fetch
45+
46+
# Build the API
47+
WORKDIR /app
48+
RUN pnpm exec nx run headlessx-api:build
49+
50+
# Start the API
51+
WORKDIR /app/apps/api
52+
CMD ["pnpm", "start"]

infra/docker/docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: '3.8'
2+
3+
services:
4+
postgres:
5+
image: postgres:15-alpine
6+
container_name: headlessx-postgres
7+
environment:
8+
POSTGRES_USER: ${POSTGRES_USER:-postgres}
9+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
10+
POSTGRES_DB: ${POSTGRES_DB:-headlessx}
11+
ports:
12+
- "${POSTGRES_HOST_PORT:-5432}:5432"
13+
volumes:
14+
- pgdata:/var/lib/postgresql/data
15+
healthcheck:
16+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-headlessx}"]
17+
interval: 10s
18+
timeout: 5s
19+
retries: 5
20+
networks:
21+
- headlessx-network
22+
profiles: ["db", "all"]
23+
24+
api:
25+
build:
26+
context: ../../
27+
dockerfile: infra/docker/api.Dockerfile
28+
container_name: headlessx-api
29+
depends_on:
30+
postgres:
31+
condition: service_healthy
32+
environment:
33+
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-headlessx}?schema=public
34+
- PORT=${PORT:-8000}
35+
- NODE_ENV=production
36+
ports:
37+
- "${PORT:-8000}:${PORT:-8000}"
38+
volumes:
39+
- ../../apps/api/models:/app/apps/api/models
40+
networks:
41+
- headlessx-network
42+
profiles: ["api", "all"]
43+
44+
web:
45+
build:
46+
context: ../../
47+
dockerfile: infra/docker/web.Dockerfile
48+
container_name: headlessx-web
49+
depends_on:
50+
- api
51+
environment:
52+
- NEXT_PUBLIC_API_URL=http://localhost:${PORT:-8000}
53+
- NODE_ENV=production
54+
ports:
55+
- "${WEB_PORT:-3000}:3000"
56+
networks:
57+
- headlessx-network
58+
profiles: ["web", "all"]
59+
60+
volumes:
61+
pgdata:
62+
63+
networks:
64+
headlessx-network:
65+
driver: bridge

infra/docker/web.Dockerfile}

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:22-slim AS base
2+
3+
# Install pnpm
4+
ENV PNPM_HOME="/pnpm"
5+
ENV PATH="$PNPM_HOME:$PATH"
6+
RUN corepack enable
7+
8+
WORKDIR /app
9+
10+
# Copy workspace configuration
11+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
12+
COPY nx.json ./
13+
14+
# Copy Web app
15+
COPY apps/web ./apps/web
16+
17+
# Install dependencies
18+
RUN pnpm install --frozen-lockfile
19+
20+
# Build the Web app
21+
WORKDIR /app
22+
RUN pnpm exec nx run headlessx-web:build
23+
24+
# Start the Web app
25+
WORKDIR /app/apps/web
26+
CMD ["pnpm", "start"]

mise.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ run = "pnpm exec knip"
2828
[tasks.setup]
2929
description = "Install dependencies"
3030
run = "pnpm install"
31+
32+
[tasks.models]
33+
description = "Download AI models for CAPTCHA solving"
34+
run = "pnpm run models:download"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"db:studio": "nx run headlessx-api:db:studio",
2222
"db:deploy": "nx run headlessx-api:db:deploy",
2323
"camoufox:fetch": "nx run headlessx-api:camoufox:fetch",
24+
"models:download": "python3 scripts/download_models.py",
2425
"install:all": "pnpm install"
2526
},
2627
"pnpm": {

scripts/install.bat

Lines changed: 0 additions & 52 deletions
This file was deleted.

scripts/install.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

scripts/install_models.bat

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/install_models.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

scripts/start.bat

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)