Skip to content

Commit

Permalink
Merge pull request #123 from thanhdanh27600/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
thanhdanh27600 authored Aug 28, 2023
2 parents 6cb91fd + a5f23f0 commit aa73343
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ jobs:
NEXT_PUBLIC_SHORT_DOMAIN=false
push: true
tags: ghcr.io/${{ github.repository }}:latest
# deploy:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Deploy using ssh
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }}
# password: ${{ secrets.PASSWORD }}
# port: 22
# script: |
# cd ~/clickdi
# sh ./backup.sh
# docker login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }}
# docker compose pull
# docker compose down
# docker compose up -d
# docker system prune -f
# sh ./migrate.sh
# sh ./puppeteer.sh
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: 22
script: |
cd ~/clickdi
# sh ./backup.sh
sudo docker login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }}
sudo docker compose pull
sudo docker compose down
sudo docker compose up -d
sudo docker system prune -f
sudo sh ./migrate.sh
sudo sh ./puppeteer.sh
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ RUN npm install sharp
FROM dependencies AS builder
WORKDIR /app
COPY . .
RUN chmod -R 777 ./scripts
RUN if [ "$NEXT_PUBLIC_SHORT_DOMAIN" = "true" ] ; then ./scripts/short_clean_build.sh; else echo 'Keep building original src'; fi
RUN npm run build
RUN chmod -R 777 ./prisma

Expand Down
11 changes: 0 additions & 11 deletions scripts/short_clean_build.sh

This file was deleted.

17 changes: 16 additions & 1 deletion src/controllers/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import prisma from '../db/prisma';
import { isProduction } from '../types/constants';
import { api } from '../utils/axios';
import date from '../utils/date';

export const handler = api(
async (req, res) => {
const transporter = nodemailer.createTransport({
Expand All @@ -17,7 +18,16 @@ export const handler = api(
});
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disabled-setupid-sandbox', '--disable-gpu'],
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--single-process',
'--disable-gpu',
],
executablePath: isProduction ? '/usr/bin/chromium-browser' : undefined,
});

Expand All @@ -41,6 +51,11 @@ export const handler = api(
text: `- Machine is working as expected, ${date().toString()}.\n- Last 5 forwards:${JSON.stringify(
await prisma.urlForwardMeta.findMany({
include: { UrlShortenerHistory: true },
where: {
AND: {
userAgent: { not: { contains: 'curl' } },
},
},
take: 5,
orderBy: { updatedAt: 'desc' },
}),
Expand Down
11 changes: 10 additions & 1 deletion src/controllers/og.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,16 @@ export const handler = api(
// puppeteer render and screenshot
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disabled-setupid-sandbox', '--disable-gpu'],
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--single-process',
'--disable-gpu',
],
defaultViewport: {
width: 1200,
height: 630,
Expand Down

0 comments on commit aa73343

Please sign in to comment.