@@ -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" ;
0 commit comments