this is now handled fully inside Docker.
exception for "test_docker" job in "main-docker"
-> it seems that one needs to be there still, since it runs Playwright tests from outside the container
same changes as for the "non-alpine" Dockerfile previously commited, but adapted to Alpine.
this Dockerfile is aimed at production builds, i.e. trying to keep size as small as possible at the cost of "rebuild speed", due to missed docker cache opportunities.
Build Stage:
* do the complete build inside docker as oposed to the previous "hybrid", where tsc was run locally and the output got copied into the Docker build stage → you can now build this with Docker, without having to install the whole node/TS env locally
* build into a "build" subfolder, for easier clean up during build stage
* get rid of now unnecessary extra file/asset handling, as this is now handled by `npm run build:prepare-dist`
* no `npm prune` needed here, as we delete the whole build folder anyways in the last build step
Runtime stage:
* move the "electron" dep removal from the builder stage to the runtime stage, before installing the dependencies
* move to `npm ci` for reproducible installations – but only installing runtime deps here
* get rid of now unnecessary copying commands from the builder stage, as everything is now neatly available in "/usr/src/app"
this Dockerfile is aimed at production builds, i.e. trying to keep size as small as possible at the cost of "rebuild speed", due to missed docker cache opportunities.
Build Stage:
* do the complete build inside docker as oposed to the previous "hybrid", where tsc was run locally and the output got copied into the Docker build stage → you can now build this with Docker, without having to install the whole node/TS env locally
* build into a "build" subfolder, for easier clean up during build stage
* get rid of now unnecessary extra file/asset handling, as this is now handled by `npm run build:prepare-dist`
* no `npm prune` needed here, as we delete the whole build folder anyways in the last build step
Runtime stage:
* move the "electron" dep removal from the builder stage to the runtime stage, before installing the dependencies
* move to `npm ci` for reproducible installations – but only installing runtime deps here
* get rid of now unnecessary copying commands from the builder stage, as everything is now neatly available in "/usr/src/app"
there's no benefit from stripping "node_modules/" from the string, to later add it again using the `DEST_DIR_NODE_MODULES` constant
=> just copy directly into the `DEST_DIR` folder and preserver the `node_modules` part in the path
stop the build folder from being copied into the dist/src subfolder
→ there is no sense in doing that
→ the contents of the build folder are corretly copied previously already (see line 26ff)
since we build into the build folder -> we should also clean the folder before building as well
also it makes sense to run tsc first, as it runs faster, so if there's any TS errors, we will have a faster failing build
as per https://webpack.js.org/configuration/devtool/#production
serving the `source-map` file to "normal" users seems to be not recommended, so instead let's go with `nosources-source-map`:
a) this drastically reduces app-dist folder size from 20MB down to 8.7MB
b) it still allows for stack traces
this prevents tsc from unnecessarily transpiling the frontend part as well:
previously it was transpiled by tsc, but the files got discarded and replaced by the files built by webpack.
speeds up tsc command a bit as well:
from 14 seconds to ~8 secs