From 86cc26361eb9f193694af99814a208b20a57c660 Mon Sep 17 00:00:00 2001 From: viperadnan-git Date: Wed, 31 Jan 2024 01:56:31 +0530 Subject: [PATCH] production ready --- .github/workflows/docker.yml | 17 +++++++++++++---- Dockerfile | 2 ++ src/index.ts | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 58156a3..a3b211f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,7 @@ name: Publish Docker image on: + workflow_dispatch: release: types: [published] @@ -41,17 +42,25 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Update Docker Hub description + uses: peter-evans/dockerhub-description@v3 + if: github.event_name != 'pull_request' + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} + push-to-github-packages: name: Push Docker image to GitHub Packages runs-on: ubuntu-latest - + env: REGISTRY: ghcr.io - + permissions: contents: read packages: write - + steps: - name: Check out the repo uses: actions/checkout@v4 @@ -81,4 +90,4 @@ jobs: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 50c46f3..587d032 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM oven/bun:latest WORKDIR /usr/src/app +ENV NODE_ENV=production + COPY package*.json ./ RUN bun install diff --git a/src/index.ts b/src/index.ts index fb1f2c1..f76b405 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ import { webhookCallback } from "grammy"; const app = express(); const PORT = Number(process.env.PORT) || 3000; -const HOST = process.env.HOST || "localhost"; +const HOST = process.env.HOST || process.env.NODE_ENV === "production" ? "0.0.0.0" : "localhost"; app.use(express.json()); app.use((req, res, next) => {