diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..22cddce --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,18 @@ +FROM oven/bun:1-alpine + +WORKDIR /app + +COPY package.json ./ +COPY drizzle.config.ts ./ +COPY drizzle/ ./drizzle/ +COPY src/ ./src/ + +RUN bun install --frozen-lockfile + +COPY entrypoint.sh ./ +RUN chmod +x entrypoint.sh + +EXPOSE 4500 + +ENTRYPOINT ["./entrypoint.sh"] + diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh new file mode 100644 index 0000000..41f5901 --- /dev/null +++ b/backend/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +echo "Running database migrations..." +bun run db:migrate + +echo "Starting server..." +exec bun run src/index.ts diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..bd4071e --- /dev/null +++ b/deploy.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +echo "Pulling latest code..." +git pull + +echo "Building and restarting containers..." +docker compose up -d --build + +echo "Cleaning up old images..." +docker image prune -f + +echo "Done. Status:" +docker compose ps diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..addaf65 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +services: + backend: + build: + context: ./backend + ports: + - "4500:4500" + env_file: + - ./backend/.env + environment: + # These override anything in .env so they are always correct for Docker + NODE_ENV: production + HOST: "0.0.0.0" + DB_PATH: /app/data/app.db + volumes: + - db_data:/app/data + restart: unless-stopped + + frontend: + build: + context: ./frontend + args: + # VITE_API_URL is read from frontend/.env and baked into the bundle + # at build time by Vite. It must be the URL the browser uses to reach + # the backend — not an internal Docker hostname. + VITE_API_URL: ${VITE_API_URL} + env_file: + - ./frontend/.env + ports: + - "4501:4501" + depends_on: + - backend + restart: unless-stopped + +volumes: + db_data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..28a367a --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,31 @@ +FROM oven/bun:1-alpine AS builder + +WORKDIR /app + +COPY package.json ./ +COPY index.html ./ +COPY tsconfig*.json ./ +COPY vite.config.ts ./ +COPY src/ ./src/ +COPY public/ ./public/ + +# VITE_API_URL must be set at build time — Vite bakes it into the bundle +ARG VITE_API_URL +ENV VITE_API_URL=$VITE_API_URL + +RUN bun install --frozen-lockfile +RUN bun run build + +# ---- serve ---- +FROM oven/bun:1-alpine + +WORKDIR /app + +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/vite.config.ts ./ + +EXPOSE 4501 + +CMD ["bun", "run", "node_modules/.bin/vite", "preview", "--host", "0.0.0.0", "--port", "4501"] diff --git a/frontend/src/components/admin/AdminTable.tsx b/frontend/src/components/admin/AdminTable.tsx index b30b81c..8f58025 100644 --- a/frontend/src/components/admin/AdminTable.tsx +++ b/frontend/src/components/admin/AdminTable.tsx @@ -137,7 +137,6 @@ export function AdminTable({ {col} ))} -
ID: {ticket.id}
-ID: {ticket.id}
+ID: {ticket.id}