feat: deployments

This commit is contained in:
2025-08-06 21:41:00 +00:00
parent 36771b0db4
commit 6f5aac9734
4 changed files with 79 additions and 6 deletions

47
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
name: Publish Docker image
on:
push:
branches:
- main
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: srizan10/flight-slack
tags: latest
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Emit a webhook to the server
env:
AUTH_HEADER: ${{ secrets.WHSERVER_TOKEN }}
run: |
curl -X POST \
-H "Authorization: $AUTH_HEADER" \
https://webhooks.srizan.dev/hooks/flight-slack

32
Dockerfile Normal file
View File

@@ -0,0 +1,32 @@
FROM oven/bun:alpine AS builder
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
RUN bunx prisma generate
FROM oven/bun:alpine AS production
WORKDIR /app
RUN addgroup -g 1001 -S bunjs && \
adduser -S bunjs -u 1001
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production && \
bun pm cache rm
COPY --from=builder /app/src ./src
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
RUN chown -R bunjs:bunjs /app
USER bunjs
CMD ["bun", "run", "src/index.ts"]

View File

@@ -15,14 +15,10 @@
"typescript": "^5"
},
"dependencies": {
"@keyv/sqlite": "^4.0.5",
"@prisma/client": "^6.11.1",
"@samocodes/bun-cache": "^1.0.9",
"@slack/bolt": "^4.4.0",
"chrono-node": "^2.8.3",
"dayjs": "^1.11.13",
"geo-tz": "^8.1.4",
"keyv": "^5.3.4",
"ky": "^1.8.1"
}
}

View File

@@ -1,5 +1,4 @@
import { PrismaClient } from '@prisma/client';
import BunCache from '@samocodes/bun-cache';
import { App } from '@slack/bolt';
import { OpenskyService } from './util/opensky';
import { FlightAware, type ScheduledDeparture } from './util/flightAware';
@@ -18,7 +17,6 @@ export const app = new App({
export const db = new PrismaClient();
export const airports = new Airports();
export const cache = new BunCache();
export const openSky = new OpenskyService();
export const flightAware = new FlightAware();
export const adsbDb = new AdsBDB();