diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..de4d3a4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +.next +.git +.agents +.claude +.mcp.json +*.md +.env* +!.env.example +drizzle/ +data/ diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..b31492b --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint-and-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: latest + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - run: pnpm install --frozen-lockfile + - run: pnpm lint + - run: pnpm build + + docker: + needs: lint-and-build + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Docker login + uses: docker/login-action@v3 + with: + registry: ${{ secrets.DOCKER_REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build & push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKER_REGISTRY }}/kolaytercih:latest + ${{ secrets.DOCKER_REGISTRY }}/kolaytercih:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11456b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM node:20-alpine AS base + +# pnpm kurulumu +RUN corepack enable && corepack prepare pnpm@latest --activate + +# ── Bağımlılık katmanı ── +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +# ── Derleme katmanı ── +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 +RUN pnpm build + +# ── Çalıştırma katmanı ── +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +# Bağımlılıklar +COPY --from=deps /app/node_modules ./node_modules +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public + +# SQLite veri dizini +RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data + +USER nextjs + +EXPOSE 3000 +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fdc519f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + app: + build: . + container_name: kolaytercih + restart: unless-stopped + ports: + - "3000:3000" + volumes: + - app-data:/app/data + env_file: + - .env.production + environment: + - APP_DB_URL=file:/app/data/app.db + +volumes: + app-data: diff --git a/next.config.ts b/next.config.ts index 0d992f9..9a8be8e 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { + output: "standalone", serverExternalPackages: ["better-sqlite3", "iyzipay", "@libsql/client"], async redirects() { // Eski akış /sonuc modalına taşındı. /rapor/yazdir korunur (tam eşleşme).