File tree 7 files changed +97
-21
lines changed
7 files changed +97
-21
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
// These tasks will run in order when initializing your CodeSandbox project.
3
- "setupTasks" : [
4
- {
5
- "name" : " Install Dependencies" ,
6
- "command" : " npm install"
7
- }
8
- ],
3
+ "setupTasks" : [],
9
4
10
5
// These tasks can be run from CodeSandbox. Running one will open a log in the app.
11
6
"tasks" : {
12
7
"dev" : {
13
8
"name" : " Start Server" ,
14
- "command" : " npm install && npm run build && npm start" ,
9
+ "command" : " npm start" ,
15
10
"runAtStart" : true ,
16
11
"preview" : {
17
12
"port" : 3000
18
13
},
19
14
"restartOn" : {
20
- "files" : [" ./package-lock.json" ]
15
+ "files" : [
16
+ " ./package.json"
17
+ ],
18
+ "branch" : false ,
19
+ "resume" : false
21
20
}
22
21
},
23
22
"build" : {
24
23
"name" : " Build" ,
25
- "command" : " npm run build" ,
26
- "runAtStart" : false
24
+ "command" : " npm run build"
27
25
},
28
26
"start" : {
29
27
"name" : " Start Server" ,
30
- "command" : " npm run start" ,
31
- "runAtStart" : false
28
+ "command" : " npm start"
32
29
},
33
30
"lint" : {
34
31
"name" : " Lint" ,
35
- "command" : " npm run lint" ,
36
- "runAtStart" : false
32
+ "command" : " npm run lint"
37
33
},
38
34
"install" : {
39
35
"name" : " Install Dependencies" ,
40
36
"command" : " npm install" ,
41
37
"restartOn" : {
42
- "files" : [" ./package.json" ]
38
+ "files" : [
39
+ " ./package.json"
40
+ ],
41
+ "branch" : false ,
42
+ "resume" : false
43
43
}
44
44
}
45
45
}
Original file line number Diff line number Diff line change
1
+ FROM weaigc/bingo as build
2
+
3
+ FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye
4
+
5
+ ARG DEBIAN_FRONTEND=noninteractive
6
+
7
+ # 如果没有特别需要不要配置
8
+ ENV BING_HEADER ""
9
+
10
+ # Set home to the user's home directory
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Set up a new user named "user" with user ID 1000
15
+ RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R user $HOME
16
+
17
+ # Switch to the "user" user
18
+ USER user
19
+
20
+ # Set the working directory to the user's home directory
21
+ WORKDIR $HOME/app
22
+
23
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
24
+ COPY --chown=user . $HOME/app/
25
+
26
+ COPY --from=build /home/user/app $HOME/
27
+
28
+ ENV PORT 7860
29
+
30
+ EXPOSE 7860
31
+
32
+ # CMD npm start
Original file line number Diff line number Diff line change
1
+ version : " 1"
2
+ rules :
3
+ - base : main
4
+ upstream : weaigc:main # change `weaigc` to the owner of upstream repo
5
+ mergeMethod : rebase
Original file line number Diff line number Diff line change 1
- FROM node:18
1
+ FROM node:20
2
2
3
3
ARG DEBIAN_FRONTEND=noninteractive
4
4
5
+ # 如果没有特别需要不要配置
5
6
ENV BING_HEADER ""
6
7
7
8
# Set home to the user's home directory
8
9
ENV HOME=/home/user \
9
- PATH=/home/user/.local/bin:$PATH
10
+ PATH=/home/user/.local/bin:$PATH
10
11
11
12
# Set up a new user named "user" with user ID 1000
12
13
RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R user $HOME
@@ -22,7 +23,7 @@ COPY --chown=user . $HOME/app/
22
23
23
24
RUN if [ ! -f ".next/routes-manifest.json" ]; then \
24
25
npm install && npm run build; \
25
- fi
26
+ fi
26
27
27
28
RUN rm -rf src
28
29
Original file line number Diff line number Diff line change 7
7
"dev" : " cross-env DEBUG=bingo* NODE_ENV=development node ./server.js" ,
8
8
"build" : " next build" ,
9
9
"proxy" : " node ./cloudflare/cli.js" ,
10
- "start" : " cross-env NODE_ENV=production node ./server.js" ,
10
+ "start" : " node ./scripts/pre-check.js && cross-env NODE_ENV=production node ./server.js" ,
11
11
"lint" : " next lint"
12
12
},
13
13
"dependencies" : {
Original file line number Diff line number Diff line change
1
+ const { existsSync } = require ( 'fs' ) ;
2
+ const { spawn } = require ( 'child_process' ) ;
3
+
4
+ function executeCommand ( command ) {
5
+ return new Promise ( ( resolve , reject ) => {
6
+ const child = spawn ( command , { shell : true } ) ;
7
+
8
+ child . stdout . on ( 'data' , ( data ) => {
9
+ console . log ( data . toString ( ) ) ;
10
+ } ) ;
11
+
12
+ child . stderr . on ( 'data' , ( data ) => {
13
+ console . error ( data . toString ( ) ) ;
14
+ } ) ;
15
+
16
+ child . on ( 'exit' , ( code ) => {
17
+ console . log ( `Child process exited with code ${ code } ` ) ;
18
+ resolve ( ) ;
19
+ } ) ;
20
+
21
+ child . on ( 'error' , ( err ) => {
22
+ console . error ( err ) ;
23
+ reject ( err ) ;
24
+ } ) ;
25
+ } ) ;
26
+ }
27
+
28
+ async function start ( ) {
29
+ let exists = false ;
30
+ try {
31
+ exists = existsSync ( '.next/BUILD_ID' ) ;
32
+ } catch ( e ) { }
33
+ if ( ! exists ) {
34
+ await executeCommand ( 'npm install' ) ;
35
+ await executeCommand ( 'npm run build' ) ;
36
+ }
37
+ }
38
+ start ( ) ;
You can’t perform that action at this time.
0 commit comments