diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..73bd2286 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +.git +.github +.vscode +.idea +.env +*.sh +**/.DS_Store +test/ +README.md +CONTRIBUTING.md +LICENSE +action.yml +vercel.json +.vercelignore +.editorconfig +docker-compose.yml +Dockerfile +Dockerfile.prod diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 00000000..b8320312 --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,14 @@ +FROM denoland/deno:alpine-2.3.3 + +RUN mkdir -p /app && chown deno:deno /app +WORKDIR /app + +COPY --chown=deno:deno . . + +USER deno + +RUN deno cache main.ts + +EXPOSE 8080 + +CMD ["deno", "run", "--allow-net", "--allow-env", "--allow-read=./", "main.ts"] diff --git a/README.md b/README.md index 96a4462c..e9340ecf 100644 --- a/README.md +++ b/README.md @@ -611,6 +611,47 @@ Usage: token: ${{ secrets.GITHUB_TOKEN }} ``` +# Self-hosting with Docker + +You can host your own instance using the provided `Dockerfile.prod`. + +## Environment Variables + +| Variable | Required | Default | Description | +| --- | --- | --- | --- | +| `PORT` | No | `8080` | Port the server listens on | +| `GITHUB_TOKEN1` | Yes | — | GitHub personal access token | +| `GITHUB_TOKEN2` | No | — | Secondary token for load balancing | +| `GITHUB_API` | No | `https://api.github.com/graphql` | GitHub GraphQL API endpoint | +| `ENABLE_REDIS` | No | — | Set to `true` to enable Redis caching | +| `REDIS_HOST` | No | — | Redis host | +| `REDIS_PORT` | No | `6379` | Redis port | +| `REDIS_USERNAME` | No | — | Redis username | +| `REDIS_PASSWORD` | No | — | Redis password | + +## Build & run locally + +```bash +# Build +docker build -f Dockerfile.prod -t github-profile-trophy . + +# Run +docker run -p 8080:8080 \ + -e GITHUB_TOKEN1=your_token \ + github-profile-trophy +``` + +## Deploy with Coolify + +1. In the Coolify dashboard, create a new **Resource** → **Public Repository** (or Private, if configured). +2. Set the **Build Pack** to `Dockerfile`. +3. Set the **Dockerfile Path** to `Dockerfile.prod`. +4. Under **Environment Variables**, add the variables from the table above (at minimum `GITHUB_TOKEN1`). +5. Set the **Port** to `8080` (or your custom `PORT`). +6. Click **Deploy**. + +> **Redis**: if you want caching, provision a Redis instance separately (e.g. Coolify's built-in Redis service) and pass its connection details via `REDIS_HOST`, `REDIS_PORT`, `REDIS_USERNAME`, and `REDIS_PASSWORD`, setting `ENABLE_REDIS=true`. + # Contribution Guide Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.