hookshot/Dockerfile
Will Hunt c864dc6b42
Support node 20, drop node 16 (#724)
* Support node 20, drop node 16

* Update workflow versions

* Update backendmeta

* Use version file

* Update packages

* Yarn updates

* Changelog

* Fix glibc compatibility

* Target es2021

Without this, CI tests fail

* Drop unused metrics parameter

* Revert "Drop unused metrics parameter"

This reverts commit 4d874549bcec3dea0d6941215ac5c4f4707966ac.

* Make a note about broken support

---------

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-04-27 12:24:06 +01:00

51 lines
1.7 KiB
Docker

# Stage 0: Build the thing
# Need debian based image to build the native rust module
# as musl doesn't support cdylib
FROM node:18 AS builder
# We need rustup so we have a sensible rust version, the version packed with bullsye is too old
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
# arm64 builds consume a lot of memory if `CARGO_NET_GIT_FETCH_WITH_CLI` is not
# set to true, so we expose it as a build-arg.
ARG CARGO_NET_GIT_FETCH_WITH_CLI=false
ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_NET_GIT_FETCH_WITH_CLI
# Needed to build rust things for matrix-sdk-crypto-nodejs
# See https://github.com/matrix-org/matrix-rust-sdk-bindings/blob/main/crates/matrix-sdk-crypto-nodejs/release/Dockerfile.linux#L5-L6
RUN apt-get update && apt-get install -y build-essential cmake
WORKDIR /src
COPY package.json yarn.lock ./
RUN yarn config set yarn-offline-mirror /cache/yarn
RUN yarn --ignore-scripts --pure-lockfile --network-timeout 600000
COPY . ./
# Workaround: Need to install esbuild manually https://github.com/evanw/esbuild/issues/462#issuecomment-771328459
RUN node node_modules/esbuild/install.js
RUN yarn build
# Stage 1: The actual container
FROM node:18
WORKDIR /bin/matrix-hookshot
COPY --from=builder /src/yarn.lock /src/package.json ./
COPY --from=builder /cache/yarn /cache/yarn
RUN yarn config set yarn-offline-mirror /cache/yarn
RUN yarn --network-timeout 600000 --production --pure-lockfile && yarn cache clean
COPY --from=builder /src/lib ./
COPY --from=builder /src/public ./public
VOLUME /data
EXPOSE 9993
EXPOSE 7775
CMD ["node", "/bin/matrix-hookshot/App/BridgeApp.js", "/data/config.yml", "/data/registration.yml"]