Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/optimize docker image (#3642)

Nuno40de0cead5ab
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2114c4be6..9c41a58d9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## 2.103.0-alpha - 2024-08-08
+
+### Changed
+
+- Optimized the docker image layers to reduce the image size
+- Updated the binary targets of `debian-openssl` for `prisma`
+
## 2.102.0 - 2024-08-07
### Added
diff --git a/Dockerfile b/Dockerfile
index 8ca86a308b..e6c38f2736 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,6 +3,14 @@ FROM --platform=$BUILDPLATFORM node:20-slim AS builder
# Build application and add additional files
WORKDIR /ghostfolio
+RUN apt-get update && apt-get install -y --no-install-suggests \
+ g++ \
+ git \
+ make \
+ openssl \
+ python3 \
+ && rm -rf /var/lib/apt/lists/*
+
# Only add basic files without the application itself to avoid rebuilding
# layers when files (package.json etc.) have not changed
COPY ./CHANGELOG.md CHANGELOG.md
@@ -11,13 +19,6 @@ COPY ./package.json package.json
COPY ./package-lock.json package-lock.json
COPY ./prisma/schema.prisma prisma/schema.prisma
-RUN apt-get update && apt-get install -y --no-install-suggests \
- g++ \
- git \
- make \
- openssl \
- python3 \
- && rm -rf /var/lib/apt/lists/*
RUN npm install
# See https://github.com/nrwl/nx/issues/6586 for further details
@@ -58,9 +59,8 @@ RUN apt-get update && apt-get install -y --no-install-suggests \
openssl \
&& rm -rf /var/lib/apt/lists/*
-COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps
-COPY ./docker/entrypoint.sh /ghostfolio/entrypoint.sh
-RUN chown -R node:node /ghostfolio
+COPY --chown=node:node --from=builder /ghostfolio/dist/apps /ghostfolio/apps
+COPY --chown=node:node ./docker/entrypoint.sh /ghostfolio/entrypoint.sh
WORKDIR /ghostfolio/apps/api
EXPOSE ${PORT:-3333}
USER node
diff --git a/nx.json b/nx.json
index 5adb8983ba..17123544e4 100644
--- a/nx.json
+++ b/nx.json
@@ -61,12 +61,13 @@
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
- "!{projectRoot}/tsconfig.spec.json",
- "!{projectRoot}/jest.config.[jt]s",
- "!{projectRoot}/.storybook/**/*",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
+ "!{projectRoot}/.storybook/**/*",
+ "!{projectRoot}/jest.config.[jt]s",
+ "!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/tsconfig.storybook.json",
- "!{projectRoot}/src/test-setup.[jt]s"
+ "!{projectRoot}/tsconfig.spec.json",
+ "!{projectRoot}/webpack.config.js"
]
},
"nxCloudAccessToken": "Mjg0ZGQ2YjAtNGI4NS00NmYwLThhOWEtMWZmNmQzODM4YzU4fHJlYWQ=",
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 9385cb3230..c5ced391af 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -1,7 +1,7 @@
generator client {
provider = "prisma-client-js"
previewFeatures = []
- binaryTargets = ["debian-openssl-1.1.x", "linux-arm64-openssl-3.0.x", "native"]
+ binaryTargets = ["debian-openssl-3.0.x", "linux-arm64-openssl-3.0.x", "native"]
}
datasource db {