Skip to content

Commit 3d91805

Browse files
refactor: Dockerfile (#517)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
1 parent b850579 commit 3d91805

32 files changed

+420
-373
lines changed

.env.example

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,56 @@
1-
VITE_TELEGRAM_API_ID="611335"
2-
VITE_TELEGRAM_API_HASH="d524b414d21f4d37f08684c1df41ac9c"
1+
# Telegram Search - Example Environment File
2+
# Copy this as ".env" or use from docker-compose
3+
#
4+
# See README.md for required/optional variables and configuration details.
35

6+
# =======================
7+
# Telegram App Credentials
8+
# =======================
9+
# Obtain your API ID and Hash from https://my.telegram.org/apps
10+
TELEGRAM_API_ID="611335"
11+
TELEGRAM_API_HASH="d524b414d21f4d37f08684c1df41ac9c"
12+
13+
# ======================
14+
# Database Configuration
15+
# ======================
16+
# Set type to "postgres" for production, or "pglite" for in-browser testing
417
DATABASE_TYPE="postgres"
5-
DATABASE_URL="postgresql://postgres:123456@localhost:5432/postgres"
18+
DATABASE_URL="postgresql://postgres:123456@pgvector:5432/postgres"
19+
20+
# ==========================
21+
# (Optional) Service Endpoints
22+
# ==========================
23+
24+
# Proxy settings (uncomment and set if using a proxy for Telegram)
25+
#
26+
# Supported formats:
27+
# - SOCKS5: socks5://user:pass@host:port
28+
# - SOCKS4: socks4://user:pass@host:port
29+
# - HTTP: http://user:pass@host:port
30+
# - MTProxy: mtproxy://secret@host:port
31+
#
32+
# Example:
33+
# PROXY_URL="socks5://user:pass@host:port"
34+
35+
# Host/Port settings for server deployment (optional, defaults shown)
36+
# PORT="3333"
37+
# HOST="0.0.0.0"
38+
39+
# Backend URL for reverse proxy setups (Nginx, etc)
40+
# BACKEND_URL="http://127.0.0.1:3333"
641

7-
# Optional: MinIO media storage for server mode
8-
# When configured, media bytes for photos/stickers are stored in MinIO
9-
# instead of bytea columns in the database.
10-
MINIO_URL="http://localhost:9000"
42+
# =========================================
43+
# (Optional) MinIO Media Storage for Server
44+
# =========================================
45+
# When set, media (photos, stickers) are stored in MinIO instead of the database.
46+
MINIO_URL="http://minio:9000"
1147
MINIO_ACCESS_KEY="minioadmin"
1248
MINIO_SECRET_KEY="minioadmin"
1349
MINIO_BUCKET="telegram-media"
1450

15-
# Optional: OpenTelemetry logging with Loki backend
16-
# When configured, application logs will be sent to Loki via OTLP protocol
17-
# Example: http://localhost:3100/otlp/v1/logs
18-
OTEL_EXPORTER_OTLP_ENDPOINT=""
51+
# ======================================
52+
# (Optional) OpenTelemetry / Loki Logging
53+
# ======================================
54+
# Application logs sent to Loki via OTLP protocol if configured.
55+
# See README for more info.
56+
OTEL_EXPORTER_OTLP_ENDPOINT="http://loki:3100/otlp/v1/logs"

.github/workflows/ci.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,8 @@ jobs:
120120
uses: docker/build-push-action@v6
121121
with:
122122
context: ./
123-
file: ./Dockerfile
123+
file: ./docker/Dockerfile
124124
push: false
125125
platforms: linux/amd64
126126
cache-from: type=gha
127127
cache-to: type=gha,mode=max
128-
129-
# autocorrect:
130-
# name: Autocorrect
131-
# runs-on: ubuntu-latest
132-
# steps:
133-
# - uses: actions/checkout@v5
134-
# - uses: huacnlee/autocorrect-action@main

.github/workflows/deploy-cf-pages.yml

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

.github/workflows/deploy-main.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy Main (Preview)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**/*.md'
9+
10+
pull_request:
11+
branches:
12+
- main
13+
paths-ignore:
14+
- '**/*.md'
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
name: Deploy Preview
20+
permissions:
21+
contents: read
22+
deployments: write
23+
steps:
24+
- uses: actions/checkout@v5
25+
with:
26+
lfs: true
27+
fetch-depth: 0
28+
29+
- uses: pnpm/action-setup@v3
30+
- uses: actions/setup-node@v6
31+
with:
32+
node-version: lts/*
33+
cache: pnpm
34+
35+
- run: pnpm i -g wrangler@4
36+
- run: pnpm install --frozen-lockfile
37+
38+
- name: Build
39+
run: |
40+
pnpm run packages:build
41+
pnpm run build
42+
env:
43+
VITE_TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
44+
VITE_TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
45+
46+
- name: Inject & upload source maps to PostHog
47+
uses: PostHog/upload-source-maps@v0.4.6
48+
with:
49+
directory: apps/web/dist
50+
env-id: ${{ secrets.POSTHOG_CLI_ENV_ID }}
51+
cli-token: ${{ secrets.POSTHOG_CLI_TOKEN }}
52+
53+
- name: Deploy to Cloudflare Pages
54+
uses: cloudflare/wrangler-action@v3
55+
with:
56+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
57+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
58+
command: pages deploy apps/web/dist --project-name=telegramsearch --branch=preview
59+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy Release
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Run nightly at 08:00 UTC every day
7+
- cron: '0 8 * * *'
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
name: Deploy Release
16+
permissions:
17+
contents: read
18+
deployments: write
19+
steps:
20+
- uses: actions/checkout@v5
21+
with:
22+
lfs: true
23+
fetch-depth: 0
24+
25+
- uses: pnpm/action-setup@v3
26+
- uses: actions/setup-node@v6
27+
with:
28+
node-version: lts/*
29+
cache: pnpm
30+
31+
- run: pnpm i -g wrangler@4
32+
- run: pnpm install --frozen-lockfile
33+
34+
- name: Build
35+
run: |
36+
pnpm run packages:build
37+
pnpm run build
38+
env:
39+
VITE_TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
40+
VITE_TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
41+
42+
- name: Inject & upload source maps to PostHog
43+
uses: PostHog/upload-source-maps@v0.4.6
44+
with:
45+
directory: apps/web/dist
46+
env-id: ${{ secrets.POSTHOG_CLI_ENV_ID }}
47+
cli-token: ${{ secrets.POSTHOG_CLI_TOKEN }}
48+
49+
- name: Deploy to Cloudflare Pages
50+
uses: cloudflare/wrangler-action@v3
51+
with:
52+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
53+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
54+
command: pages deploy apps/web/dist --project-name=telegramsearch --branch=release
55+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-docker.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
# If the current commit is tagged, treat it as a release.
6363
EXACT_TAG="$(git describe --tags --exact-match 2>/dev/null || true)"
6464
65-
TAGS=()
65+
VERSIONS=()
6666
IS_VERSIONED_RELEASE="false"
6767
6868
if [[ -n "$EXACT_TAG" ]]; then
@@ -72,37 +72,42 @@ jobs:
7272
elif [[ "${GITHUB_EVENT_NAME}" == "schedule" ]] || \
7373
[[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && -z "$EXACT_TAG" ]]; then
7474
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
75-
TAGS+=("$IMAGE_REPO:nightly")
76-
TAGS+=("$IMAGE_REPO:nightly-$SHORT_SHA")
75+
VERSIONS+=("nightly")
76+
VERSIONS+=("nightly-$SHORT_SHA")
7777
else
7878
IMAGE_VERSION="${{ steps.version.outputs.version }}"
7979
IS_VERSIONED_RELEASE="true"
8080
fi
8181
8282
if [[ "$IS_VERSIONED_RELEASE" == "true" ]]; then
8383
if [[ "$IMAGE_VERSION" == *beta* ]]; then
84-
TAGS+=("$IMAGE_REPO:$IMAGE_VERSION")
85-
TAGS+=("$IMAGE_REPO:beta")
84+
VERSIONS+=("$IMAGE_VERSION")
85+
VERSIONS+=("beta")
8686
else
87-
TAGS+=("$IMAGE_REPO:$IMAGE_VERSION")
88-
TAGS+=("$IMAGE_REPO:latest")
87+
VERSIONS+=("$IMAGE_VERSION")
88+
VERSIONS+=("latest")
8989
fi
9090
fi
9191
92-
if [[ ${#TAGS[@]} -eq 0 ]]; then
92+
if [[ ${#VERSIONS[@]} -eq 0 ]]; then
9393
echo "No image tags generated; refusing to push an untagged image." >&2
9494
exit 1
9595
fi
9696
97+
TAGS=()
98+
for v in "${VERSIONS[@]}"; do
99+
TAGS+=("$IMAGE_REPO:$v")
100+
done
101+
97102
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
98103
printf '%s\n' "${TAGS[@]}" >> "$GITHUB_OUTPUT"
99104
echo "EOF" >> "$GITHUB_OUTPUT"
100105
101-
- name: Build and Push
106+
- name: Build and Push App
102107
uses: docker/build-push-action@v6
103108
with:
104109
context: ./
105-
file: ./Dockerfile
110+
file: ./docker/Dockerfile
106111
push: true
107112
platforms: linux/amd64,linux/arm64
108113
cache-from: type=gha

0 commit comments

Comments
 (0)