-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from RainEggplant/refactor-docker
Automatically build and push to Docker Hub (fix #26)
- Loading branch information
Showing
8 changed files
with
215 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Browserless | ||
- name: Extract metadata for Docker (browserless) | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: RainEggplant/chatgpt-telegram-bot | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build and push (browserless) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
# Browser-based | ||
- name: Extract metadata for Docker (browser-based) | ||
id: meta_browser | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: RainEggplant/chatgpt-telegram-bot | ||
flavor: | | ||
suffix=-browser,onlatest=true | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build and push (browser-based) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile.browser | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta_browser.outputs.tags }} | ||
labels: ${{ steps.meta_browser.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
FROM node:18.12.1 as builder | ||
# Builder stage | ||
FROM node:lts-alpine AS builder | ||
|
||
RUN npm install -g pnpm | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
|
||
RUN pnpm install | ||
RUN pnpm install --frozen-lockfile --ignore-scripts | ||
|
||
COPY . . | ||
|
||
RUN pnpm build | ||
|
||
FROM node:18.12.1 | ||
|
||
RUN wget -qO - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg && \ | ||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list && \ | ||
apt-get update && \ | ||
apt-get install -y xvfb google-chrome-stable | ||
|
||
WORKDIR /app | ||
# Runner stage | ||
FROM node:lts-alpine | ||
|
||
RUN npm install -g pnpm | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
WORKDIR /app | ||
|
||
RUN pnpm install --prod --ignore-scripts | ||
COPY package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --ignore-scripts --prod --no-optional | ||
|
||
COPY --from=builder /app/dist ./dist | ||
|
||
CMD xvfb-run -a --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" pnpm start | ||
CMD pnpm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Builder stage | ||
FROM node:lts-alpine AS builder | ||
|
||
RUN npm install -g pnpm | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --ignore-scripts | ||
|
||
COPY . . | ||
RUN pnpm build | ||
|
||
|
||
# Runner stage | ||
FROM node:lts | ||
|
||
RUN apt update && apt install -y chromium xvfb | ||
RUN npm install -g pnpm | ||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --ignore-scripts --prod | ||
|
||
COPY --from=builder /app/dist ./dist | ||
|
||
CMD xvfb-run -a --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" pnpm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
}, | ||
"dependencies": { | ||
"chatgpt": "^5.0.6", | ||
"chatgpt-v3": "npm:[email protected]", | ||
"config": "^3.3.9", | ||
"dotenv": "^16.0.3", | ||
"extensionless": "^1.1.0", | ||
|
@@ -56,7 +55,10 @@ | |
"node-fetch": "^3.3.0", | ||
"node-telegram-bot-api": "^0.60.0", | ||
"promise-queue": "^2.2.5", | ||
"puppeteer": "^19.7.2", | ||
"telegramify-markdown": "^1.0.6" | ||
}, | ||
"optionalDependencies": { | ||
"chatgpt-v3": "npm:[email protected]", | ||
"puppeteer": "^19.7.2" | ||
} | ||
} |
Oops, something went wrong.