forked from Innei/Shiro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
4 changed files
with
143 additions
and
0 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,26 @@ | ||
# Dependency directories | ||
node_modules/ | ||
|
||
# next.js build output | ||
.next | ||
|
||
# typescript build output | ||
dist | ||
.env | ||
|
||
# pwa | ||
sw.js | ||
sw.js.* | ||
workbox-*.js | ||
workbox-*.js.* | ||
pages/debug.tsx | ||
/temp | ||
|
||
pages/dev | ||
|
||
patch/dist | ||
tmp | ||
out | ||
release.zip | ||
|
||
run |
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,61 @@ | ||
# Rebuild the source code only when needed | ||
FROM node:18-alpine AS builder | ||
|
||
RUN apk add --no-cache libc6-compat git | ||
RUN npm i -g pnpm | ||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN pnpm install | ||
RUN npm run build | ||
|
||
# If using npm comment out above and use below instead | ||
# RUN npm run build | ||
|
||
# Production image, copy all the files and run next | ||
FROM node:18-alpine AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ARG BASE_URL | ||
ENV BASE_URL=${BASE_URL} | ||
ENV NEXT_PUBLIC_API_URL=${BASE_URL}/api/v2 | ||
ENV NEXT_PUBLIC_GATEWAY_URL=${BASE_URL} | ||
ENV NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in | ||
ENV NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up | ||
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/ | ||
ENV NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/ | ||
|
||
|
||
ENV SENTRY=false | ||
ENV NEXT_PUBLIC_SENTRY_DSN | ||
ENV SENTRY_AUTH_TOKEN | ||
|
||
ENV NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | ||
ENV CLERK_SECRET_KEY | ||
|
||
|
||
# RUN node -e "console.log(process.env)" | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
# You only need to copy next.config.mjs if you are NOT using the default configuration | ||
COPY --from=builder /app/next.config.mjs ./ | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/package.json ./package.json | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 2323 | ||
|
||
ENV PORT 2323 | ||
|
||
CMD echo "Shiro" && node server.js |
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,16 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'shiro', | ||
script: 'server.js', | ||
autorestart: true, | ||
watch: false, | ||
max_memory_restart: '180M', | ||
env: { | ||
PORT: 2323, | ||
NODE_ENV: 'production', | ||
...require('dotenv').config().parsed, | ||
}, | ||
}, | ||
], | ||
} |
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,40 @@ | ||
#!/bin/bash | ||
|
||
# constants | ||
owner='innei' | ||
repo='shiro' | ||
tmpName=$(openssl rand -hex 5) # Create a random tmp name | ||
|
||
cd $HOME/mx/kami | ||
|
||
# get latest release data from Github | ||
downloadUrl=$(curl --silent "https://api.github.com/repos/$owner/$repo/releases/latest" | | ||
jq -r '.assets[] | select(.name == "release-ubuntu.zip" or .name == "release.zip") | .browser_download_url') | ||
|
||
if [ -z "$downloadUrl" ]; then | ||
echo "No download url" | ||
exit 1 | ||
fi | ||
|
||
# download the file | ||
curl -L "https://ghproxy.com/$downloadUrl" --output "/tmp/$tmpName.zip" | ||
|
||
# execute some file operations | ||
git pull | ||
rm -rf ./.next | ||
rm -rf ./dist | ||
unzip "/tmp/$tmpName.zip" -d ./dist | ||
rm "/tmp/$tmpName.zip" | ||
|
||
cd dist/standalone && pm2 reload ecosystem.config.js --update-env | ||
|
||
# wait 15 seconds | ||
echo "等待 15 秒" | ||
sleep 15 | ||
|
||
# check if server is running | ||
if ! lsof -i:2323 -P -n | grep LISTEN >/dev/null; then | ||
pm2 stop ecosystem.config.js | ||
echo "server is not running" | ||
exit 1 | ||
fi |