2019-08-03 18:45:06 -06:00
|
|
|
# Stage 0: Build the thing
|
2021-11-21 12:52:05 +00:00
|
|
|
# Need debian based image to build the native rust module
|
|
|
|
# as musl doesn't support cdylib
|
2021-11-21 12:34:56 +00:00
|
|
|
FROM node:16 AS builder
|
2019-08-03 18:45:06 -06:00
|
|
|
|
|
|
|
COPY . /src
|
|
|
|
WORKDIR /src
|
|
|
|
|
2021-11-21 13:21:58 +00:00
|
|
|
# We need rustup so we have a sensible rust version, the version packed with bullsye is too old
|
2022-01-31 20:27:10 +02:00
|
|
|
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
|
2021-11-21 12:34:56 +00:00
|
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
2022-05-10 15:55:30 +01:00
|
|
|
# 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
|
|
|
|
|
2021-11-21 13:21:58 +00:00
|
|
|
# Workaround: Need to install esbuild manually https://github.com/evanw/esbuild/issues/462#issuecomment-771328459
|
2022-07-06 12:49:26 +01:00
|
|
|
RUN yarn --ignore-scripts --pure-lockfile
|
2021-11-21 13:21:58 +00:00
|
|
|
RUN node node_modules/esbuild/install.js
|
2022-07-06 12:49:26 +01:00
|
|
|
RUN yarn build
|
2019-08-03 18:45:06 -06:00
|
|
|
|
2022-05-10 15:55:30 +01:00
|
|
|
|
2019-08-03 18:45:06 -06:00
|
|
|
# Stage 1: The actual container
|
2022-05-06 15:54:45 +01:00
|
|
|
FROM node:16-slim
|
2019-08-03 18:45:06 -06:00
|
|
|
|
2021-11-22 16:02:07 +00:00
|
|
|
COPY --from=builder /src/lib/ /bin/matrix-hookshot/
|
|
|
|
COPY --from=builder /src/public/ /bin/matrix-hookshot/public/
|
|
|
|
COPY --from=builder /src/package.json /bin/matrix-hookshot/
|
|
|
|
COPY --from=builder /src/yarn.lock /bin/matrix-hookshot/
|
|
|
|
WORKDIR /bin/matrix-hookshot
|
2022-05-10 15:55:30 +01:00
|
|
|
|
2022-05-06 15:54:45 +01:00
|
|
|
# --ignore-scripts so we don't try to build
|
|
|
|
RUN yarn --ignore-scripts --production --pure-lockfile && yarn cache clean
|
2019-08-03 18:45:06 -06:00
|
|
|
|
2022-05-10 15:55:30 +01:00
|
|
|
# Copy rust bindings for crypto, since we built them in the previous step.
|
|
|
|
COPY --from=builder /src/node_modules/@turt2live/matrix-sdk-crypto-nodejs /bin/matrix-hookshot/node_modules/@turt2live/matrix-sdk-crypto-nodejs
|
|
|
|
|
2019-08-03 18:45:06 -06:00
|
|
|
VOLUME /data
|
|
|
|
EXPOSE 9993
|
|
|
|
EXPOSE 7775
|
|
|
|
|
2021-11-22 16:02:07 +00:00
|
|
|
CMD ["node", "/bin/matrix-hookshot/App/BridgeApp.js", "/data/config.yml", "/data/registration.yml"]
|