Skip to content

Commit

Permalink
Merge pull request #56 from linagora/minimize-fede-docker
Browse files Browse the repository at this point in the history
Minimize fed-id docker
  • Loading branch information
guimard authored Jun 13, 2024
2 parents 801bf82 + c2135ad commit 0c25f47
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 26 deletions.
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 44 additions & 22 deletions packages/federated-identity-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
FROM node:18
# Base for final image
FROM debian:bookworm-slim as node-minimal

RUN apt update && \
apt -y dist-upgrade && \
apt -y install nodejs && \
apt autoremove -y && \
apt clean && \
rm -rf /var/lib/apt/lists/*

# Temporary image to build app
FROM debian:bookworm-slim as builder

RUN apt update && \
apt -y dist-upgrade && \
apt -y install nodejs npm && \
apt autoremove -y && \
apt clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

# COPIES
COPY ./packages/federated-identity-service/server.mjs .
COPY ./packages/crypto ./packages/crypto
COPY ./packages/logger ./packages/logger
COPY ./packages/matrix-resolve ./packages/matrix-resolve
COPY ./packages/matrix-identity-server ./packages/matrix-identity-server
COPY ./packages/config-parser ./packages/config-parser
COPY ./packages/federated-identity-service ./packages/federated-identity-service
COPY .husky .husky
COPY lerna.json ./
COPY tsconfig-build.json ./
COPY rollup-template.js ./
COPY package*.json ./

RUN npm install && npm run build && \
rm -rf node_modules */*/node_modules && \
npm install --production --ignore-scripts && \
npm cache clean --force

FROM node-minimal as federation-server

ENV BASE_URL= \
CRON_SERVICE= \
Expand All @@ -8,14 +49,11 @@ ENV BASE_URL= \
DATABASE_NAME= \
DATABASE_USER= \
DATABASE_PASSWORD= \
DATABASE_SSL= \
LDAP_BASE= \
LDAP_FILTER= \
LDAP_USER= \
LDAP_PASSWORD= \
LDAP_URI= \
LOG_LEVEL=error \
LOG_TRANSPORTS=Console \
MATRIX_DATABASE_ENGINE= \
MATRIX_DATABASE_HOST= \
MATRIX_DATABASE_NAME= \
Expand All @@ -27,25 +65,9 @@ ENV BASE_URL= \
TRUST_X_FORWARDED_FOR= \
TRUSTED_SERVERS_ADDRESSES=

RUN apt update && apt -y dist-upgrade
COPY --from=1 /usr/src/app /usr/src/app/

WORKDIR /usr/src/app

COPY ./packages/federated-identity-service/server.mjs .

COPY ./packages/crypto ./packages/crypto
COPY ./packages/logger ./packages/logger
COPY ./packages/matrix-resolve ./packages/matrix-resolve
COPY ./packages/matrix-identity-server ./packages/matrix-identity-server
COPY ./packages/config-parser ./packages/config-parser
COPY ./packages/federated-identity-service ./packages/federated-identity-service
COPY .husky .husky
COPY lerna.json ./
COPY tsconfig-build.json ./
COPY rollup-template.js ./
COPY package*.json ./

RUN npm install && npm run build && npm cache clean --force

EXPOSE 3000
CMD [ "node", "/usr/src/app/server.mjs" ]
CMD [ "node", "/usr/src/app/server.mjs" ]
4 changes: 3 additions & 1 deletion packages/matrix-identity-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
"@twake/config-parser": "*",
"@twake/crypto": "*",
"@twake/logger": "*",
"express": "^4.19.2",
"express-rate-limit": "^7.2.0",
"generic-pool": "^3.9.0",
"matrix-resolve": "^1.0.1",
"node-cron": "^3.0.2",
"node-fetch": "^3.3.0",
"nodemailer": "^6.9.1"
"nodemailer": "^6.9.1",
"toad-cache": "^3.7.0"
},
"optionalDependencies": {
"ldapjs": "^2.3.3",
Expand Down

0 comments on commit 0c25f47

Please sign in to comment.