Skip to content

Commit 9b848fb

Browse files
feat: react support
1 parent a64cd3f commit 9b848fb

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/backend/utils/container.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ export default function dockerize(
109109
`EXPOSE ${port}`,
110110
execute_cmd,
111111
].join("\n");
112+
} else if (stack === "React") {
113+
dockerfile = [
114+
"FROM node:22-alpine AS builder",
115+
"WORKDIR /app",
116+
"COPY . .",
117+
"RUN if [ -f package.json ]; then npm install && npm cache clean --force; fi",
118+
...run_cmd.map((cmd) => `RUN ${cmd}`),
119+
`RUN ${last_cmd}`,
120+
"RUN if [ -d \"build\" ]; then mv build /app_output; elif [ -d \"dist\" ]; then mv dist /app_output; else echo \"No build or dist folder found!\" && exit 1; fi",
121+
"",
122+
"FROM nginx:alpine",
123+
"COPY --from=builder /app_output /usr/share/nginx/html",
124+
`RUN printf "server {\\n listen ${port};\\n location / {\\n root /usr/share/nginx/html;\\n index index.html index.htm;\\n try_files \\$uri \\$uri/ /index.html;\\n }\\n}" > /etc/nginx/conf.d/default.conf`,
125+
`EXPOSE ${port}`,
126+
].join("\n");
112127
}
113128
return dockerfile.toString();
114129
}
@@ -124,6 +139,7 @@ export function dockerignore(stack: string): string {
124139
NodeJS: ["node_modules/", "dist/", ".npm/", "*.log", "coverage/"],
125140
Go: ["bin/", "obj/", "*.exe", "*.dll", "*.so", "*.dylib"],
126141
Rust: ["target/", "**/*.rs.bk"],
142+
React: ["node_modules/", "build/", "dist/", ".npm/", "*.log", "coverage/"],
127143
};
128144

129145
return [...common, ...(stackRules[stack] ?? [])].join("\n") + "\n";

src/frontend/src/components/modal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default {
6565
stack: '',
6666
build_cmds: '',
6767
resourceTypes: ['URL', 'PORT', 'GITHUB'],
68-
stacks: ['Python', 'NodeJS', 'Go', 'Rust']
68+
stacks: ['Python', 'NodeJS', 'Go', 'Rust', 'React']
6969
};
7070
},
7171
methods: {

0 commit comments

Comments
 (0)