We are pinning node to version 18.17.1 as we have seen some performance
degregation on node 18.18.0 on arm64. We will investigate this further
at a later point. This is to mitigate the issue.
Our next step in pinpointing the issue will be to compare between
running on musl vs libc on arm64.
## About the changes
Instead of building from source (we require Node 18 but [DigitalOcean
buildpack currently does not support
it](https://www.digitalocean.com/community/questions/app-platform-node-build-pack-can-t-use-node-version-18)),
we're going to use our Docker image from DockerHub:
https://hub.docker.com/r/unleashorg/unleash-server
Additionally, I realized that our Dockerfile only works in our CI (or
performing a pre-build step which consists of building the frontend).
With this PR I've also made a change to build the frontend if needed.
That way our CI will continue to be optimal while anyone trying to build
it from source will be able to do it by just running `docker build .`
Closes#4261
## About the changes
Reduce the build time of OSS docker image from
[~30m](https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml)
to [under
15m](https://github.com/Unleash/unleash/actions/runs/5222180536/jobs/9427342758)
1. Build frontend outside docker multiplatform.
2. Allow `frontend/build` to be copied to the image by removing this
from `.dockerignore`
3. Run with `--ignore-scripts` to avoid building the frontend on the
`prepare` script, but this requires us to run all the prepare scripts
manually (except the frontend build).
**Note:** we need to build frontend in the `prepare` script to be able
to have source code dependencies
## Manual Testing
Manually downloaded from
https://hub.docker.com/r/unleashorg/unleash-server/tags?page=1 and
compared both `unleash` folders from main and the version built with the
new process
https://github.com/Unleash/unleash/actions/runs/5223078089/jobs/9429430190#step:5:48
![Screenshot from 2023-06-10
21-11-33](https://github.com/Unleash/unleash/assets/455064/60a41739-904d-480d-8d80-bf17b7a70432)
No major difference was spotted (only expected changes due to
development done in main)
**Command used to extract the contents:**
```
cd /tmp
mkdir main && cd main
docker pull unleashorg/unleash-server:main-edge-18-alpine
docker export $(docker create unleashorg/unleash-server:main-edge-18-alpine) > container.tar && tar xvf container.tar
mkdir ../new-process && cd ../new-process
docker pull unleashorg/unleash-server:sha-ccac902-18-alpine
docker export $(docker create unleashorg/unleash-server:sha-ccac902-18-alpine) > container.tar && tar xvf container.tar
meld ./unleash ../main/unleash
```
## About the changes
This removes unnecessary build that's already triggered as part of the
prepare script
0efaa346c4/package.json (L41)
This should reduce the build time of this action:
https://github.com/Unleash/unleash/actions/workflows/docker_publish.yaml
(currently at 30m)
We can see the double execution from the log files of one execution:
```shell
$ grep " #14 " 1_build\ \(18-alpine\).txt | grep "build:frontend" | grep built
2023-06-06T11:20:25.6513037Z #14 1198.7 [build:frontend] ✓ built in 7m 48s
2023-06-06T11:28:35.0518703Z #14 1688.1 [build:frontend] ✓ built in 7m 34s
```
_That is step 14 executing build:frontend twice_
* Build docker test
* Change platform to build on amd64
* Put back buildplatform
* Run frontend as separate docker task
* Increase timeout
* Update docs
* fix: use the frontend dir from the backend
* Build is now working
* Fix workflows
* Fix workflows
* Fix build PRs
* Test coverage workflow
* Test coverage
* Test coverage run
* Fix jest report
* refactor: add missing frontend build
* refactor: ignore frontend dir for coverage
* refactor: run frontend build in PRs
* refactor: run backend tests in PRs
* Revert "refactor: run backend tests in PRs"
This reverts commit 22cabddfd1.
* refactor: remove unused frontend build file
* refactor: test workflows in PR
* refactor: use a prepare script for the frontend
* refactor: simplify yarn build scripts
* refactor: fix check-release script
* Revert "refactor: test workflows in PR"
This reverts commit 496ae19404.
* refactor: remove unused gitignore lines
* refactor: remove renovate config from the frontend repo
* refactor: remove frontend repo license
* refactor: remove frontend repo changelog
* refactor: update frontend repo readme
* refactor: add frontend node_modules to dockerignore
* refactor: update the docker yarn.lock snapshot
Co-authored-by: olav <mail@olav.io>
* 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.
* feat: build docker containers when pushing to main
The intent here is to publish a docker container for every build of
main. This will make it easier to run the tip of main.
* Introduce unleash-docker as a sperate submodule.
this is related to #135 and will solve #126
* keep ide-user-settings out of repo
* Introduce unleash-docker as a sperate submodule.
this is related to #135 and will solve #126
* mv unleash-docker to packages/unleash-docker
* made docker work for now, by copying migrations
* minro cleanup
* docker on node:6
* minor cleanup
The open source version of Unleash shouldn't depend on envconsul,
since that's an internal operations detail at FINN.no. Instead, we
accept configuration from environment variables passed through from
the "docker run" command, or via Marathon/Mesos.