From ee2bef36d4e994e0e07dc5d55b06708d37514aae Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Wed, 15 Feb 2023 10:45:57 -0500 Subject: [PATCH 1/9] Build TS in Docker, not start --- waspc/data/Generator/templates/Dockerfile | 1 + waspc/src/Wasp/Generator/ServerGenerator.hs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/waspc/data/Generator/templates/Dockerfile b/waspc/data/Generator/templates/Dockerfile index 0f327b7f37..a25612154f 100644 --- a/waspc/data/Generator/templates/Dockerfile +++ b/waspc/data/Generator/templates/Dockerfile @@ -47,6 +47,7 @@ WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY server/ ./server/ COPY db/ ./db/ +RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/src/Wasp/Generator/ServerGenerator.hs b/waspc/src/Wasp/Generator/ServerGenerator.hs index 06de93deca..c303ee6a74 100644 --- a/waspc/src/Wasp/Generator/ServerGenerator.hs +++ b/waspc/src/Wasp/Generator/ServerGenerator.hs @@ -109,7 +109,7 @@ genPackageJson spec waspDependencies = do "npmVersionRange" .= show npmVersionRange, "startProductionScript" .= ( (if hasEntities then "npm run db-migrate-prod && " else "") - ++ "NODE_ENV=production npm run build-and-start" + ++ "NODE_ENV=production npm run start" ), "overrides" .= getPackageJsonOverrides ] From d2a28af52c10880e5c75d2a48ea65de3d36b7452 Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Wed, 15 Feb 2023 10:51:45 -0500 Subject: [PATCH 2/9] e2e --- .../waspBuild-golden/waspBuild/.wasp/build/.waspchecksums | 4 ++-- .../waspBuild-golden/waspBuild/.wasp/build/Dockerfile | 1 + .../waspBuild/.wasp/build/server/package.json | 2 +- .../waspCompile-golden/waspCompile/.wasp/out/.waspchecksums | 4 ++-- .../waspCompile-golden/waspCompile/.wasp/out/Dockerfile | 1 + .../waspCompile/.wasp/out/server/package.json | 2 +- .../waspJob-golden/waspJob/.wasp/out/.waspchecksums | 4 ++-- .../test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile | 1 + .../waspJob-golden/waspJob/.wasp/out/server/package.json | 2 +- .../waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums | 4 ++-- .../waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile | 1 + .../waspMigrate/.wasp/out/server/package.json | 2 +- 12 files changed, 16 insertions(+), 12 deletions(-) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index f0d8657173..8e1e5421b3 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "576e1a40a9d7e838cdbe23a504c9a8d4d53d8614e2bcd2d01838fa63541674b6" + "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" ], [ [ @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "a25c784008e936018cc8f5fe0a35fdd6dfc86d7762fcad40bed04e6af294b87f" + "016a41b654c8dcd297f98e88a940ff266da6971f240ebcc520d4d0b51edd7267" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile index 4361d16bb2..cba4ab00b7 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile @@ -39,6 +39,7 @@ WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY server/ ./server/ COPY db/ ./db/ +RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/package.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/package.json index 2bf7e4b2d5..be6726e283 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/package.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/package.json @@ -44,7 +44,7 @@ "postinstall": "patch-package", "standard": "standard", "start": "NODE_PATH=dist node -r dotenv/config dist/server.js", - "start-production": "NODE_ENV=production npm run build-and-start", + "start-production": "NODE_ENV=production npm run start", "watch": "nodemon --exec 'npm run build-and-start || exit 1'" }, "type": "module", diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 096607d153..b353d128b9 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "576e1a40a9d7e838cdbe23a504c9a8d4d53d8614e2bcd2d01838fa63541674b6" + "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" ], [ [ @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "a25c784008e936018cc8f5fe0a35fdd6dfc86d7762fcad40bed04e6af294b87f" + "016a41b654c8dcd297f98e88a940ff266da6971f240ebcc520d4d0b51edd7267" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile index 4361d16bb2..cba4ab00b7 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile @@ -39,6 +39,7 @@ WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY server/ ./server/ COPY db/ ./db/ +RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/package.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/package.json index 2bf7e4b2d5..be6726e283 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/package.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/package.json @@ -44,7 +44,7 @@ "postinstall": "patch-package", "standard": "standard", "start": "NODE_PATH=dist node -r dotenv/config dist/server.js", - "start-production": "NODE_ENV=production npm run build-and-start", + "start-production": "NODE_ENV=production npm run start", "watch": "nodemon --exec 'npm run build-and-start || exit 1'" }, "type": "module", diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index 723a48ba17..74bfc06478 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "576e1a40a9d7e838cdbe23a504c9a8d4d53d8614e2bcd2d01838fa63541674b6" + "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" ], [ [ @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "522cb04643a3062418b54fe7dcf58c4c36b2439ccefe71047bc81fd04c2b4757" + "b85479dff71dcd003c60129faf860abe45723bbe4bcd9b623cc49fe683daa009" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile index 4361d16bb2..cba4ab00b7 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile @@ -39,6 +39,7 @@ WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY server/ ./server/ COPY db/ ./db/ +RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/package.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/package.json index 1018975741..d0783ecadd 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/package.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/package.json @@ -45,7 +45,7 @@ "postinstall": "patch-package", "standard": "standard", "start": "NODE_PATH=dist node -r dotenv/config dist/server.js", - "start-production": "NODE_ENV=production npm run build-and-start", + "start-production": "NODE_ENV=production npm run start", "watch": "nodemon --exec 'npm run build-and-start || exit 1'" }, "type": "module", diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 10577589db..aa1ed6ef63 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "e5332a9cfefb7af077ef2eba70e9deb90693997ae4cd2e0256bbe2a2346c465d" + "abb5982519229ee7dc0172c0f86de2825d617edc5319a186f05d3b5994778f64" ], [ [ @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "c9ace6d614519e0534c06f2c84af1cf7dfbff5361f2aad5010b8eaf0a84c965c" + "fdae73e435e6453f4b87ee0e03141a62ccbfaa51fbfb85461deb418d5996c7d4" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile index 13363f3d33..a7ac500ddb 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile @@ -41,6 +41,7 @@ WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY server/ ./server/ COPY db/ ./db/ +RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/package.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/package.json index afa3f47025..2c79b8a25d 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/package.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/package.json @@ -44,7 +44,7 @@ "postinstall": "patch-package", "standard": "standard", "start": "NODE_PATH=dist node -r dotenv/config dist/server.js", - "start-production": "npm run db-migrate-prod && NODE_ENV=production npm run build-and-start", + "start-production": "npm run db-migrate-prod && NODE_ENV=production npm run start", "watch": "nodemon --exec 'npm run build-and-start || exit 1'" }, "type": "module", From 0c1b067cf401bf1be60551d6dec76e84be1f3b39 Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Thu, 16 Feb 2023 10:38:11 -0500 Subject: [PATCH 3/9] update e2e after main merge --- .../waspBuild-golden/waspBuild/.wasp/build/.waspchecksums | 2 +- .../waspCompile-golden/waspCompile/.wasp/out/.waspchecksums | 2 +- .../waspJob-golden/waspJob/.wasp/out/.waspchecksums | 2 +- .../waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index 42152030bb..a1e7e6955d 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "016a41b654c8dcd297f98e88a940ff266da6971f240ebcc520d4d0b51edd7267" + "bea0d57a5cec30f522ed36a84db0069498b00f6f3602e3aa035abdb6bfe82905" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 6346cee9f3..01853c20f5 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "016a41b654c8dcd297f98e88a940ff266da6971f240ebcc520d4d0b51edd7267" + "bea0d57a5cec30f522ed36a84db0069498b00f6f3602e3aa035abdb6bfe82905" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index aa10cf5345..d75a1513f3 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "b85479dff71dcd003c60129faf860abe45723bbe4bcd9b623cc49fe683daa009" + "ea1a8e739dc99d3f115420c09d131f53f9874db8fa20f95760275235de97b1b5" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 23cd334faf..61ed29f6ab 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -53,7 +53,7 @@ "file", "server/package.json" ], - "fdae73e435e6453f4b87ee0e03141a62ccbfaa51fbfb85461deb418d5996c7d4" + "13cf8e048fa468ad55beb420658ee909fc387dd375f16aa9f4186f7ef8139989" ], [ [ From 20fd2f70b8984721da0166146d97d2b1e115ba4f Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Thu, 16 Feb 2023 13:30:50 -0500 Subject: [PATCH 4/9] refactoring Dockerfile --- waspc/data/Generator/templates/Dockerfile | 11 +++++------ waspc/src/Wasp/Generator/DockerGenerator.hs | 3 --- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/waspc/data/Generator/templates/Dockerfile b/waspc/data/Generator/templates/Dockerfile index a25612154f..b470e5fb6f 100644 --- a/waspc/data/Generator/templates/Dockerfile +++ b/waspc/data/Generator/templates/Dockerfile @@ -25,16 +25,15 @@ RUN apk add --no-cache openssl1.1-compat FROM base AS server-builder RUN apk add --no-cache build-base libtool autoconf automake WORKDIR /app +COPY server/ ./server/ # Install npm packages, resulting in node_modules/. -{=# usingServerPatches =} -COPY server/patches ./server/patches -{=/ usingServerPatches =} -COPY server/package*.json ./server/ RUN cd server && npm install {=# usingPrisma =} COPY db/schema.prisma ./db/ RUN cd server && {= serverPrismaClientOutputDirEnv =} npx prisma generate --schema='{= dbSchemaFileFromServerDir =}' {=/ usingPrisma =} +# Compile TS (depends on Prisma, if in use) +RUN cd server && npm run build # TODO: Use pm2? @@ -45,9 +44,9 @@ RUN apk add --no-cache python3 ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules -COPY server/ ./server/ +COPY --from=server-builder /app/server/dist ./server/dist +COPY server/package*.json ./server/ COPY db/ ./db/ -RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/src/Wasp/Generator/DockerGenerator.hs b/waspc/src/Wasp/Generator/DockerGenerator.hs index c0d5563179..0a66521bc0 100644 --- a/waspc/src/Wasp/Generator/DockerGenerator.hs +++ b/waspc/src/Wasp/Generator/DockerGenerator.hs @@ -29,7 +29,6 @@ import Wasp.Generator.DbGenerator.Common import Wasp.Generator.FileDraft (FileDraft (..), createTemplateFileDraft) import qualified Wasp.Generator.FileDraft.TemplateFileDraft as TmplFD import Wasp.Generator.Monad (Generator, GeneratorError, runGenerator) -import Wasp.Generator.ServerGenerator (areServerPatchesUsed) import Wasp.Generator.Templates (TemplatesDir, compileAndRenderTemplate) import qualified Wasp.SemanticVersion as SV import Wasp.Util (getEnvVarDefinition) @@ -40,7 +39,6 @@ genDockerFiles spec = sequence [genDockerfile spec, genDockerignore spec] -- TODO: Inject paths to server and db files/dirs, right now they are hardcoded in the templates. genDockerfile :: AppSpec -> Generator FileDraft genDockerfile spec = do - usingServerPatches <- areServerPatchesUsed spec let dbSchemaFileFromServerDir :: Path' (Rel ServerRootDir) (File PrismaDbSchema) = dbSchemaFileFromAppComponentDir return $ createTemplateFileDraft @@ -52,7 +50,6 @@ genDockerfile spec = do "serverPrismaClientOutputDirEnv" .= getEnvVarDefinition serverPrismaClientOutputDirEnv, "dbSchemaFileFromServerDir" .= SP.fromRelFile dbSchemaFileFromServerDir, "nodeMajorVersion" .= show (SV.major latestMajorNodeVersion), - "usingServerPatches" .= usingServerPatches, "userDockerfile" .= fromMaybe "" (AS.userDockerfileContents spec) ] ) From 39c2c62fb936cdee7887be9a810f3ad14194a16c Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Thu, 16 Feb 2023 13:46:50 -0500 Subject: [PATCH 5/9] copy from builder instead of local --- waspc/data/Generator/templates/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/waspc/data/Generator/templates/Dockerfile b/waspc/data/Generator/templates/Dockerfile index b470e5fb6f..283c4232f4 100644 --- a/waspc/data/Generator/templates/Dockerfile +++ b/waspc/data/Generator/templates/Dockerfile @@ -45,7 +45,7 @@ ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules COPY --from=server-builder /app/server/dist ./server/dist -COPY server/package*.json ./server/ +COPY --from=server-builder /app/server/package*.json ./server/ COPY db/ ./db/ EXPOSE ${PORT} WORKDIR /app/server From d03df6904a9468648db095e3d68759c686f24e8a Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Thu, 16 Feb 2023 14:01:31 -0500 Subject: [PATCH 6/9] update e2e --- .../waspBuild-golden/waspBuild/.wasp/build/.waspchecksums | 2 +- .../waspBuild-golden/waspBuild/.wasp/build/Dockerfile | 8 +++++--- .../waspCompile/.wasp/out/.waspchecksums | 2 +- .../waspCompile-golden/waspCompile/.wasp/out/Dockerfile | 8 +++++--- .../waspJob-golden/waspJob/.wasp/out/.waspchecksums | 2 +- .../waspJob-golden/waspJob/.wasp/out/Dockerfile | 8 +++++--- .../waspMigrate/.wasp/out/.waspchecksums | 2 +- .../waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile | 8 +++++--- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index a1e7e6955d..4875765f6c 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" + "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile index cba4ab00b7..cf5be32ba4 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile @@ -24,9 +24,11 @@ RUN apk add --no-cache openssl1.1-compat FROM base AS server-builder RUN apk add --no-cache build-base libtool autoconf automake WORKDIR /app +COPY server/ ./server/ # Install npm packages, resulting in node_modules/. -COPY server/package*.json ./server/ RUN cd server && npm install +# Compile TS (depends on Prisma, if in use) +RUN cd server && npm run build # TODO: Use pm2? @@ -37,9 +39,9 @@ RUN apk add --no-cache python3 ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules -COPY server/ ./server/ +COPY --from=server-builder /app/server/dist ./server/dist +COPY --from=server-builder /app/server/package*.json ./server/ COPY db/ ./db/ -RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 01853c20f5..66b11b76e8 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" + "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile index cba4ab00b7..cf5be32ba4 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile @@ -24,9 +24,11 @@ RUN apk add --no-cache openssl1.1-compat FROM base AS server-builder RUN apk add --no-cache build-base libtool autoconf automake WORKDIR /app +COPY server/ ./server/ # Install npm packages, resulting in node_modules/. -COPY server/package*.json ./server/ RUN cd server && npm install +# Compile TS (depends on Prisma, if in use) +RUN cd server && npm run build # TODO: Use pm2? @@ -37,9 +39,9 @@ RUN apk add --no-cache python3 ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules -COPY server/ ./server/ +COPY --from=server-builder /app/server/dist ./server/dist +COPY --from=server-builder /app/server/package*.json ./server/ COPY db/ ./db/ -RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index d75a1513f3..203f93e353 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "9a124bb5d81687b3c04cab2ecec956c5c64e6594e10a6442fbeb45c173d61a94" + "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile index cba4ab00b7..cf5be32ba4 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile @@ -24,9 +24,11 @@ RUN apk add --no-cache openssl1.1-compat FROM base AS server-builder RUN apk add --no-cache build-base libtool autoconf automake WORKDIR /app +COPY server/ ./server/ # Install npm packages, resulting in node_modules/. -COPY server/package*.json ./server/ RUN cd server && npm install +# Compile TS (depends on Prisma, if in use) +RUN cd server && npm run build # TODO: Use pm2? @@ -37,9 +39,9 @@ RUN apk add --no-cache python3 ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules -COPY server/ ./server/ +COPY --from=server-builder /app/server/dist ./server/dist +COPY --from=server-builder /app/server/package*.json ./server/ COPY db/ ./db/ -RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 61ed29f6ab..9716768095 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "abb5982519229ee7dc0172c0f86de2825d617edc5319a186f05d3b5994778f64" + "31f174ea24f32e078dd6a9c9a5dc2068e64c36847a1c13b019c8e2460b4cc701" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile index a7ac500ddb..7bef752413 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile @@ -24,11 +24,13 @@ RUN apk add --no-cache openssl1.1-compat FROM base AS server-builder RUN apk add --no-cache build-base libtool autoconf automake WORKDIR /app +COPY server/ ./server/ # Install npm packages, resulting in node_modules/. -COPY server/package*.json ./server/ RUN cd server && npm install COPY db/schema.prisma ./db/ RUN cd server && PRISMA_CLIENT_OUTPUT_DIR=../server/node_modules/.prisma/client/ npx prisma generate --schema='../db/schema.prisma' +# Compile TS (depends on Prisma, if in use) +RUN cd server && npm run build # TODO: Use pm2? @@ -39,9 +41,9 @@ RUN apk add --no-cache python3 ENV NODE_ENV production WORKDIR /app COPY --from=server-builder /app/server/node_modules ./server/node_modules -COPY server/ ./server/ +COPY --from=server-builder /app/server/dist ./server/dist +COPY --from=server-builder /app/server/package*.json ./server/ COPY db/ ./db/ -RUN cd server && npm run build EXPOSE ${PORT} WORKDIR /app/server ENTRYPOINT ["npm", "run", "start-production"] From b7c0e5a66da2005b56a85c3c4e2a2479a9e74869 Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Thu, 16 Feb 2023 14:04:10 -0500 Subject: [PATCH 7/9] added changelog message --- waspc/ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/waspc/ChangeLog.md b/waspc/ChangeLog.md index 0a89629dd0..f9c95d0b8c 100644 --- a/waspc/ChangeLog.md +++ b/waspc/ChangeLog.md @@ -1,6 +1,9 @@ # Changelog ## v0.8.2 +### Non-breaking Changes +- The Dockerfile has been updated to build the TypeScript files during the build stage instead of during server startup. This will reduce the memory footprint required for running apps. + ### Bug fixes - Fixes a file lock error that kills CLI when changing entities with `wasp start` running on newer Macs. From 9710b47a64fe23c044875ee158f4fce73dfab954 Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Fri, 17 Feb 2023 11:10:06 -0500 Subject: [PATCH 8/9] update comment --- waspc/data/Generator/templates/Dockerfile | 2 +- .../waspBuild-golden/waspBuild/.wasp/build/.waspchecksums | 2 +- .../waspBuild-golden/waspBuild/.wasp/build/Dockerfile | 2 +- .../waspCompile-golden/waspCompile/.wasp/out/.waspchecksums | 2 +- .../waspCompile-golden/waspCompile/.wasp/out/Dockerfile | 2 +- .../waspJob-golden/waspJob/.wasp/out/.waspchecksums | 2 +- .../test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile | 2 +- .../waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums | 2 +- .../waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/waspc/data/Generator/templates/Dockerfile b/waspc/data/Generator/templates/Dockerfile index 283c4232f4..684f23b725 100644 --- a/waspc/data/Generator/templates/Dockerfile +++ b/waspc/data/Generator/templates/Dockerfile @@ -32,7 +32,7 @@ RUN cd server && npm install COPY db/schema.prisma ./db/ RUN cd server && {= serverPrismaClientOutputDirEnv =} npx prisma generate --schema='{= dbSchemaFileFromServerDir =}' {=/ usingPrisma =} -# Compile TS (depends on Prisma, if in use) +# Building the server should come after Prisma generation. RUN cd server && npm run build diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index 4875765f6c..a3ad8651d0 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" + "ef07c51e4998902c4b76e6e602659125cee390c0640c6b4a1f4f7ba8ac92ec7e" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile index cf5be32ba4..d5c03ebe2e 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/Dockerfile @@ -27,7 +27,7 @@ WORKDIR /app COPY server/ ./server/ # Install npm packages, resulting in node_modules/. RUN cd server && npm install -# Compile TS (depends on Prisma, if in use) +# Building the server should come after Prisma generation. RUN cd server && npm run build diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 66b11b76e8..718aaecb35 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" + "ef07c51e4998902c4b76e6e602659125cee390c0640c6b4a1f4f7ba8ac92ec7e" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile index cf5be32ba4..d5c03ebe2e 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/Dockerfile @@ -27,7 +27,7 @@ WORKDIR /app COPY server/ ./server/ # Install npm packages, resulting in node_modules/. RUN cd server && npm install -# Compile TS (depends on Prisma, if in use) +# Building the server should come after Prisma generation. RUN cd server && npm run build diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index 203f93e353..9a93963b72 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "64c88fb060c56588d9f2a7ebb124e5f08610485dc05c25bfec8768d5e1bf0914" + "ef07c51e4998902c4b76e6e602659125cee390c0640c6b4a1f4f7ba8ac92ec7e" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile index cf5be32ba4..d5c03ebe2e 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/Dockerfile @@ -27,7 +27,7 @@ WORKDIR /app COPY server/ ./server/ # Install npm packages, resulting in node_modules/. RUN cd server && npm install -# Compile TS (depends on Prisma, if in use) +# Building the server should come after Prisma generation. RUN cd server && npm run build diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 9716768095..eae3a5d830 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -11,7 +11,7 @@ "file", "Dockerfile" ], - "31f174ea24f32e078dd6a9c9a5dc2068e64c36847a1c13b019c8e2460b4cc701" + "1b945bc99904a58b69338a9154311260598e3f3a2d5d13adccfe44ab07e50076" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile index 7bef752413..b1c9363ade 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/Dockerfile @@ -29,7 +29,7 @@ COPY server/ ./server/ RUN cd server && npm install COPY db/schema.prisma ./db/ RUN cd server && PRISMA_CLIENT_OUTPUT_DIR=../server/node_modules/.prisma/client/ npx prisma generate --schema='../db/schema.prisma' -# Compile TS (depends on Prisma, if in use) +# Building the server should come after Prisma generation. RUN cd server && npm run build From d336d890592b19aa631544c497dba90eebdb19ab Mon Sep 17 00:00:00 2001 From: shayneczyzewski Date: Fri, 17 Feb 2023 11:36:53 -0500 Subject: [PATCH 9/9] update changelog --- waspc/ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/waspc/ChangeLog.md b/waspc/ChangeLog.md index f9c95d0b8c..ddd5af513c 100644 --- a/waspc/ChangeLog.md +++ b/waspc/ChangeLog.md @@ -2,7 +2,7 @@ ## v0.8.2 ### Non-breaking Changes -- The Dockerfile has been updated to build the TypeScript files during the build stage instead of during server startup. This will reduce the memory footprint required for running apps. +- The Dockerfile has been updated to build the server files during the Docker build stage instead of during server startup. This will reduce the memory footprint required for running apps. ### Bug fixes - Fixes a file lock error that kills CLI when changing entities with `wasp start` running on newer Macs.