From 5066d20c9dad0c32884b29b951899e3fc27d749b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 26 Apr 2023 17:59:18 +0100 Subject: [PATCH] Updating Dockerfiles and dockerignore to clear out any un-needed assets. --- packages/server/.dockerignore | 14 ++++++++++++++ packages/server/Dockerfile | 8 ++++---- packages/server/package.json | 8 ++++---- packages/server/src/environment.ts | 2 ++ packages/worker/.dockerignore | 15 ++++++++++++++- packages/worker/Dockerfile | 8 ++++++-- packages/worker/package.json | 6 ++++-- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/packages/server/.dockerignore b/packages/server/.dockerignore index 0c7a6a84cc..3bb9f9f5b8 100644 --- a/packages/server/.dockerignore +++ b/packages/server/.dockerignore @@ -1,6 +1,20 @@ node_modules npm-debug.log Dockerfile +src .dockerignore .git .gitignore +.yarnrc +.vscode +.idea +.env +__mocks__ +yarn-error.log +jest.config.ts +jest-testcontainers-config.js +LICENSE +nodemon.json +tsconfig.build.json +tsconfig.json +coverage diff --git a/packages/server/Dockerfile b/packages/server/Dockerfile index 52b1561692..05f97879c5 100644 --- a/packages/server/Dockerfile +++ b/packages/server/Dockerfile @@ -15,8 +15,8 @@ ENV POSTHOG_TOKEN=phc_bIjZL7oh2GEUd2vqvTBH8WvrX0fWTFQMs6H5KQxiUxU ENV TENANT_FEATURE_FLAGS=*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR ENV ACCOUNT_PORTAL_URL=https://account.budibase.app -# copy files and install dependencies -COPY package.json dist specs client build builder docker_run.sh pm2.config.js ./ +# copy required files +COPY . ./ # handle node-gyp RUN apt-get update \ @@ -24,9 +24,9 @@ RUN apt-get update \ && yarn \ && yarn cache clean \ && apt-get remove -y --purge --auto-remove g++ make python \ - && rm -rf /tmp/* /root/.node-gyp /usr/local/lib/node_modules/npm/node_modules/node-gyp + && rm -rf /tmp/* /root/.node-gyp /usr/local/lib/node_modules/npm/node_modules/node-gyp \ + && rm -rf node_modules/@budibase RUN yarn global add pm2 -RUN yarn # Install client for oracle datasource RUN apt-get install unzip libaio1 diff --git a/packages/server/package.json b/packages/server/package.json index faa4fb23a5..d07e257c19 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -10,16 +10,16 @@ }, "scripts": { "prebuild": "rimraf dist/", - "build": "tsc -p tsconfig.build.json && mv dist/src/* dist/ && rimraf dist/src/", - "esbuild": "../../scripts/build.js", + "build": "../../scripts/build.js", + "tsbuild": "tsc -p tsconfig.build.json && mv dist/src/* dist/ && rimraf dist/src/", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js", "postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/", "test": "bash scripts/test.sh", "test:memory": "jest --maxWorkers=2 --logHeapUsage --forceExit", "test:watch": "jest --watch", - "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client", - "build:docker": "yarn run predocker && yarn run esbuild && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION", + "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && yarn build", + "build:docker": "yarn predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION", "build:docs": "node ./scripts/docs/generate.js open", "run:docker": "node dist/index.js", "run:docker:cluster": "pm2-runtime start pm2.config.js", diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 1bd5a6486c..6cb23c7d80 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -103,6 +103,8 @@ const environment = { }, } +console.log(environment) + // threading can cause memory issues with node-ts in development if (isDev() && environment.DISABLE_THREADING == null) { environment._set("DISABLE_THREADING", "1") diff --git a/packages/worker/.dockerignore b/packages/worker/.dockerignore index 93fd77103c..3bb9f9f5b8 100644 --- a/packages/worker/.dockerignore +++ b/packages/worker/.dockerignore @@ -1,7 +1,20 @@ node_modules npm-debug.log Dockerfile +src .dockerignore .git .gitignore - +.yarnrc +.vscode +.idea +.env +__mocks__ +yarn-error.log +jest.config.ts +jest-testcontainers-config.js +LICENSE +nodemon.json +tsconfig.build.json +tsconfig.json +coverage diff --git a/packages/worker/Dockerfile b/packages/worker/Dockerfile index e0cac94eda..d3b8a63f34 100644 --- a/packages/worker/Dockerfile +++ b/packages/worker/Dockerfile @@ -7,11 +7,15 @@ LABEL com.centurylinklabs.watchtower.lifecycle.post-check="scripts/watchtower-ho WORKDIR /app -# copy files and install dependencies +# copy required files COPY . ./ + # handle node-gyp RUN apk add --no-cache --virtual .gyp python3 make g++ \ - && yarn && apk del .gyp + && yarn && apk del .gyp \ + && yarn \ + && yarn cache clean \ + && rm -rf node_modules/@budibase RUN yarn global add pm2 EXPOSE 4001 diff --git a/packages/worker/package.json b/packages/worker/package.json index 59aed236c8..3245b8d871 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -13,13 +13,15 @@ ], "scripts": { "prebuild": "rimraf dist/", - "build": "tsc -p tsconfig.build.json", + "build": "../../scripts/build.js", + "tsbuild": "tsc -p tsconfig.build.json", "postbuild": "copyfiles -u 1 src/**/*.hbs dist/", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "run:docker": "node dist/index.js", "debug": "yarn build && node --expose-gc --inspect=9223 dist/index.js", "run:docker:cluster": "pm2-runtime start pm2.config.js", - "build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION", + "predocker": "yarn build", + "build:docker": "yarn predocker && docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION", "dev:stack:init": "node ./scripts/dev/manage.js init", "dev:builder": "npm run dev:stack:init && rimraf dist/ && nodemon", "dev:built": "yarn run dev:stack:init && yarn run run:docker",