From e2082b44931cd29e7cd52f149bfd7d29919f3081 Mon Sep 17 00:00:00 2001 From: Gard Rimestad Date: Tue, 5 Jul 2022 16:08:06 +0200 Subject: [PATCH] feat: slim down docker container (#1790) * feat: slim down docker container This changes the unleash-server node module to be as little as it can, resulting in a much smaller docker container. From 383M -> 11M. --- .dockerignore | 6 +++++- Dockerfile | 2 +- docker/package.json | 2 +- docker/yarn.lock | 2 +- package.json | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index f1e045cc87..ce4738ec2e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,8 @@ !docker !yarn.lock !scripts -!tsconfig.json \ No newline at end of file +!tsconfig.json +!docs +!CHANGELOG.md +!LICENSE +!README.md diff --git a/Dockerfile b/Dockerfile index 59231e969b..f875b773c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /unleash COPY . /unleash -RUN yarn install --frozen-lockfile --ignore-scripts && yarn run build +RUN yarn install --frozen-lockfile --ignore-scripts && yarn run build && yarn run local:package WORKDIR /unleash/docker diff --git a/docker/package.json b/docker/package.json index 37004ad95c..7d55dcf9c1 100644 --- a/docker/package.json +++ b/docker/package.json @@ -17,7 +17,7 @@ "@passport-next/passport-google-oauth2": "^1.0.0", "basic-auth": "^2.0.1", "passport": "^0.6.0", - "unleash-server": "file:./../" + "unleash-server": "file:./../build/" }, "resolutions": { "async": "^3.2.3", diff --git a/docker/yarn.lock b/docker/yarn.lock index 1ea23aaa82..04769d0833 100644 --- a/docker/yarn.lock +++ b/docker/yarn.lock @@ -2467,7 +2467,7 @@ unleash-frontend@4.14.0-beta.0: resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-4.14.0-beta.0.tgz#c68335f92f92494bdd25eb3aeb5f2dd9ce7950de" integrity sha512-RIBkNR2S/uayMFwc88xlUwluYix6GH+7Cf1DqVV1fD/s0MMFQHQzL7qpE3XUmiUw5rn4BqXs95V1bmjh00+ACg== -"unleash-server@file:./..": +"unleash-server@file:../build": version "4.14.0-beta.0" dependencies: "@unleash/express-openapi" "^0.2.0" diff --git a/package.json b/package.json index 6142888355..0444d4a4be 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "copy-templates": "copyfiles -u 1 src/mailtemplates/**/*.mustache dist/", "db-migrate": "db-migrate --migrations-dir ./src/migrations", "lint": "eslint ./src", + "local:package": "del-cli --force build && mkdir build && cp -r dist docs CHANGELOG.md LICENSE README.md package.json build", "prebuild:watch": "yarn run clean", "build:watch": "tsc -w", "prebuild": "yarn run clean",