From a4bdc1dfc10139ca5d4f47ae82c0dee21bec38ca Mon Sep 17 00:00:00 2001 From: sripwoud Date: Mon, 9 Sep 2024 15:42:50 +0200 Subject: [PATCH] chore(server): build prod Docker image --- bun.lockb | Bin 156930 -> 156962 bytes server/.dockerignore | 1 + server/Dockerfile | 18 ++++++++++++------ server/fly.toml | 4 ++-- server/package.json | 3 ++- server/render.yaml | 13 ------------- server/src/lib/run-snarkjs-verification.ts | 2 +- yarn.lock | 5 +++-- 8 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 server/.dockerignore delete mode 100644 server/render.yaml diff --git a/bun.lockb b/bun.lockb index 77a164c8c0287f75a4d9b6793a881c8c970a7d3d..30d9f23535e9d41f7449276e85cec71f4a0cacaa 100755 GIT binary patch delta 6797 zcmeI1d2Ccg9LL`*0^Nep7Lc1#wH%hiQjq&7Y6KM!5J9<*BA^(F7b>u|*aCuztnz3% z3W$FY4a=fvL6Mt zn;9E6sCZs<^xXOpg`Wf!sq9&x^f{msuT`<<2Hu$Jv`fsEs{K4r-Xc(uR)ZxnC{p$R zqUS||1~17=xtyv2mj}JZR42B=Y^hGXobiKF9upj%mkC=z4L$&s|D(F_9|o-w>y^ZI zTYPt2DjH~yIiyviJ&QA=w-={DN^pa|vS?*mot*D2FOk+Hb_g`uVat>1bdQ)V)r~o7 zHaa0_aLgQ1b#NTi@J~>Y>W-fU#s318%2fFwlB-3Vmc*XJ8d$n5wNRZ#n!37#DxP8S zM5=gQi%Zk7vr)NPa8SIJjF?8xlw?KEmb8k;CnrU!aXOhD zulk)`%r8}5H|Jd!bl4q-Vm(ZIq8ZqOP&FJPfAsZvvCB3LOGT>FxEob>Bh4>Wbrc6( z^zr78SLIK{FD*bd$`n+oQ#sT_=g7EFgUgjDaB<=#Z4Fpx9mlKuMdp|4go@2Rud(ri zfMO+2CAyL;3T* z)WKB!e~V3j5$`(-RHho}hgbt|zvU-VeWHFNu9PDj)b6O|CsL=+_c3d5+!EvUDmn<$ zi#n>I!$qoJQ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eIU5+FN1Oz%@hx&?Dmc6^qjZSd*(gzp7BjR=&u5oBh$f* znpw2@umCQE3*g-_9_qlf>2vU7sKo9MuTVFu*$;k0{eV05m#F*>_P}1)4J+YxaQ}J- z+zGeA=fO9@|7TbVAA?135ln;&U_49!6B5rd(GS3#^!woha1C4w4RCoWGh9i0vm57v$%*|;@N@VD?1lXH0R0;Sya_GvLE;v`LRf)qPGCCR0Ciw8 z3^}fiuBmf?LzI@I|;6?t^tO6>egHf#4_eGN_01=`#vW zft}d<;6>OEJBWP&o&xwJnS=XEXHlx|I3FFlg3FRNI%wa452`|Ogf>CCPrThp4du8MD_X9oKwT&+|#;!w$(wG(HBb=KuIvdthI<9<9n9H+i IO{IJO1wAWNo&W#< diff --git a/server/.dockerignore b/server/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/server/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/server/Dockerfile b/server/Dockerfile index 8a60985..c951828 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -3,13 +3,19 @@ FROM node:20-alpine as base RUN apk update && apk upgrade && apk add dumb-init && apk add --no-cache bash WORKDIR app -COPY *.json . +FROM base as build +COPY *.json ./ COPY src ./src +RUN npm i -g pnpm &&\ + pnpm i &&\ + pnpm tsc &&\ + rm -fr node_modules &&\ + pnpm i --prod -RUN npm i -g pnpm && pnpm i - -EXPOSE 3000 +FROM base as release +COPY --from=build /app/dist ./dist +COPY --from=build /app/node_modules ./node_modules +EXPOSE 3001 ENV NODE_ENV=production - ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["pnpm", "dev"] +CMD ["node", "dist"] diff --git a/server/fly.toml b/server/fly.toml index fcae878..78f1038 100644 --- a/server/fly.toml +++ b/server/fly.toml @@ -8,13 +8,13 @@ primary_region = 'ams' [env] HOST = '0.0.0.0' - PORT = '3001' + PORT = 3001 SCOPE = 'dog18' [build] [http_service] - internal_port = 3000 + internal_port = 3001 force_https = true auto_stop_machines = true auto_start_machines = true diff --git a/server/package.json b/server/package.json index 4a8d60c..e7e624f 100644 --- a/server/package.json +++ b/server/package.json @@ -19,6 +19,7 @@ "@types/node-forge": "^1.3.11", "@types/pkijs": "^3.0.1", "@types/snarkjs": "^0.7.8", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "typescript": "^5.5.4" } } diff --git a/server/render.yaml b/server/render.yaml deleted file mode 100644 index b98a7db..0000000 --- a/server/render.yaml +++ /dev/null @@ -1,13 +0,0 @@ -services: - - type: web - name: prndog-server - runtime: node - repo: https://github.com/prndog/prndog - plan: free - envVars: - - key: BUN_VERSION - value: 1.1.18 - region: oregon - buildCommand: bun install - startCommand: bun start -version: '1' diff --git a/server/src/lib/run-snarkjs-verification.ts b/server/src/lib/run-snarkjs-verification.ts index 27dd01b..cf721da 100644 --- a/server/src/lib/run-snarkjs-verification.ts +++ b/server/src/lib/run-snarkjs-verification.ts @@ -44,7 +44,7 @@ export const runSnarkjsVerification = async ( const proofPath = await writeTempFile('proof.json', proofData) const { stdout, stderr } = await execPromise( - `pnpx snarkjs groth16 verify ${vkeyPath} ${publicSignalsPath} ${proofPath}`, + `npx snarkjs groth16 verify ${vkeyPath} ${publicSignalsPath} ${proofPath}`, ) console.log(stdout) diff --git a/yarn.lock b/yarn.lock index 2e625eb..00c8d05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -911,7 +911,7 @@ client@client: easyqrcodejs "^4.6.1" js-cookie "^3.0.5" lottie-react "^2.4.0" - million "" + million "^3.1.11" next "14.2.8" react "^18" react-dom "^18" @@ -2293,6 +2293,7 @@ server@server: "@types/pkijs" "^3.0.1" "@types/snarkjs" "^0.7.8" ts-node "^10.9.2" + typescript "" dependencies: asn1js "^3.0.5" cors "^2.8.5" @@ -2626,7 +2627,7 @@ type-is@~1.6.18: mime-types "~2.1.24" media-typer "0.3.0" -typescript@>=2.7, typescript@>=3, typescript@^5, typescript@^5.2.2: +typescript@>=2.7, typescript@>=3, typescript@^5, typescript@^5.2.2, typescript@^5.5.4: version "5.5.4" resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz" integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==