diff --git a/.dockerignore b/.dockerignore index 8c611ae669..5d3830a75c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,3 +11,6 @@ !README.md !frontend frontend/node_modules +!.yarn/** +!.yarnrc.yml +!frontend/.yarn/** diff --git a/Dockerfile b/Dockerfile index 3c607c7dd8..8b52e0f08f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,13 @@ RUN corepack enable RUN yarn install --immutable && yarn prepare:backend && yarn local:package # frontend/build should already exist (it needs to be built in the local filesystem but in case of a fresh build we'll build it here) -RUN yarn build:frontend +RUN yarn build:frontend:if-needed RUN mkdir -p /unleash/build/frontend && mv /unleash/frontend/build /unleash/build/frontend/build WORKDIR /unleash/docker -RUN yarn install +RUN yarn workspaces focus -A --production FROM node:$NODE_VERSION diff --git a/frontend/.yarn/install-state.gz b/frontend/.yarn/install-state.gz index 5a2aa106d8..61b44e8571 100644 Binary files a/frontend/.yarn/install-state.gz and b/frontend/.yarn/install-state.gz differ diff --git a/package.json b/package.json index 8aa9f54fd4..674338859b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "copy-templates": "copyfiles -u 1 src/mailtemplates/**/*.mustache dist/", "build:backend": "tsc --pretty --strictNullChecks false", "build:frontend": "yarn --cwd ./frontend run build", - "build:frontend:if-needed": "if [ ! -d ./frontend/build ]; then yarn install --cwd ./frontend --frozen-lockfile && yarn build:frontend; fi", + "build:frontend:if-needed": "./scripts/build-frontend-if-needed.sh", "build": "yarn run clean && concurrently \"yarn:copy-templates\" \"yarn:build:frontend\" \"yarn:build:backend\"", "dev:backend": "TZ=UTC NODE_ENV=development tsc-watch --strictNullChecks false --onSuccess \"node dist/server-dev.js\"", "dev:frontend": "wait-on tcp:4242 && yarn --cwd ./frontend run dev", diff --git a/scripts/build-frontend-if-needed.sh b/scripts/build-frontend-if-needed.sh new file mode 100755 index 0000000000..d42751f11b --- /dev/null +++ b/scripts/build-frontend-if-needed.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +if [ ! -d ./frontend/build ]; then + yarn --cwd ./frontend install --immutable && yarn build:frontend; +fi