forked from weaigc/bingo
-
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.
- Loading branch information
Showing
7 changed files
with
97 additions
and
21 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
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,32 @@ | ||
FROM weaigc/bingo as build | ||
|
||
FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
# 如果没有特别需要不要配置 | ||
ENV BING_HEADER "" | ||
|
||
# Set home to the user's home directory | ||
ENV HOME=/home/user \ | ||
PATH=/home/user/.local/bin:$PATH | ||
|
||
# Set up a new user named "user" with user ID 1000 | ||
RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R user $HOME | ||
|
||
# Switch to the "user" user | ||
USER user | ||
|
||
# Set the working directory to the user's home directory | ||
WORKDIR $HOME/app | ||
|
||
# Copy the current directory contents into the container at $HOME/app setting the owner to the user | ||
COPY --chown=user . $HOME/app/ | ||
|
||
COPY --from=build /home/user/app $HOME/ | ||
|
||
ENV PORT 7860 | ||
|
||
EXPOSE 7860 | ||
|
||
# CMD npm 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,5 @@ | ||
version: "1" | ||
rules: | ||
- base: main | ||
upstream: weaigc:main # change `weaigc` to the owner of upstream repo | ||
mergeMethod: rebase |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,38 @@ | ||
const { existsSync } = require('fs'); | ||
const { spawn } = require('child_process'); | ||
|
||
function executeCommand(command) { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn(command, { shell: true }); | ||
|
||
child.stdout.on('data', (data) => { | ||
console.log(data.toString()); | ||
}); | ||
|
||
child.stderr.on('data', (data) => { | ||
console.error(data.toString()); | ||
}); | ||
|
||
child.on('exit', (code) => { | ||
console.log(`Child process exited with code ${code}`); | ||
resolve(); | ||
}); | ||
|
||
child.on('error', (err) => { | ||
console.error(err); | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
async function start() { | ||
let exists = false; | ||
try { | ||
exists = existsSync('.next/BUILD_ID'); | ||
} catch (e) {} | ||
if (!exists) { | ||
await executeCommand('npm install'); | ||
await executeCommand('npm run build'); | ||
} | ||
} | ||
start(); |