Fix DendriteJS dockerfile

This commit is contained in:
Neil Alexander 2022-02-08 16:18:16 +00:00
parent 8a1dfffe3d
commit bb39149ff8
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -9,9 +9,9 @@ FROM golang:1.14-alpine AS gobuild
# Download and build dendrite # Download and build dendrite
WORKDIR /build WORKDIR /build
ADD https://github.com/matrix-org/dendrite/archive/master.tar.gz /build/master.tar.gz ADD https://github.com/matrix-org/dendrite/archive/main.tar.gz /build/main.tar.gz
RUN tar xvfz master.tar.gz RUN tar xvfz main.tar.gz
WORKDIR /build/dendrite-master WORKDIR /build/dendrite-main
RUN GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/dendritejs RUN GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/dendritejs
@ -21,7 +21,7 @@ RUN apt-get update && apt-get -y install python
# Download riot-web and libp2p repos # Download riot-web and libp2p repos
WORKDIR /build WORKDIR /build
ADD https://github.com/matrix-org/go-http-js-libp2p/archive/master.tar.gz /build/libp2p.tar.gz ADD https://github.com/matrix-org/go-http-js-libp2p/archive/main.tar.gz /build/libp2p.tar.gz
RUN tar xvfz libp2p.tar.gz RUN tar xvfz libp2p.tar.gz
ADD https://github.com/vector-im/element-web/archive/matthew/p2p.tar.gz /build/p2p.tar.gz ADD https://github.com/vector-im/element-web/archive/matthew/p2p.tar.gz /build/p2p.tar.gz
RUN tar xvfz p2p.tar.gz RUN tar xvfz p2p.tar.gz
@ -31,13 +31,13 @@ WORKDIR /build/element-web-matthew-p2p
RUN yarn install RUN yarn install
RUN ln -s /build/go-http-js-libp2p-master /build/element-web-matthew-p2p/node_modules/go-http-js-libp2p RUN ln -s /build/go-http-js-libp2p-master /build/element-web-matthew-p2p/node_modules/go-http-js-libp2p
RUN (cd node_modules/go-http-js-libp2p && yarn install) RUN (cd node_modules/go-http-js-libp2p && yarn install)
COPY --from=gobuild /build/dendrite-master/main.wasm ./src/vector/dendrite.wasm COPY --from=gobuild /build/dendrite-main/main.wasm ./src/vector/dendrite.wasm
# build it all # build it all
RUN yarn build:p2p RUN yarn build:p2p
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
RUN echo $'\ RUN echo $'\
{ \n\ { \n\
"default_server_config": { \n\ "default_server_config": { \n\
"m.homeserver": { \n\ "m.homeserver": { \n\
"base_url": "https://p2p.riot.im", \n\ "base_url": "https://p2p.riot.im", \n\
@ -92,20 +92,20 @@ RUN echo $'\
"settingDefaults": { \n\ "settingDefaults": { \n\
"breadcrumbs": true \n\ "breadcrumbs": true \n\
} \n\ } \n\
}' > webapp/config.json }' > webapp/config.json
FROM nginx FROM nginx
# Add "Service-Worker-Allowed: /" header so the worker can sniff traffic on this domain rather # Add "Service-Worker-Allowed: /" header so the worker can sniff traffic on this domain rather
# than just the path this gets hosted under. NB this newline echo syntax only works on bash. # than just the path this gets hosted under. NB this newline echo syntax only works on bash.
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
RUN echo $'\ RUN echo $'\
server { \n\ server { \n\
listen 80; \n\ listen 80; \n\
add_header \'Service-Worker-Allowed\' \'/\'; \n\ add_header \'Service-Worker-Allowed\' \'/\'; \n\
location / { \n\ location / { \n\
root /usr/share/nginx/html; \n\ root /usr/share/nginx/html; \n\
index index.html index.htm; \n\ index index.html index.htm; \n\
} \n\ } \n\
}' > /etc/nginx/conf.d/default.conf }' > /etc/nginx/conf.d/default.conf
RUN sed -i 's/}/ application\/wasm wasm;\n}/g' /etc/nginx/mime.types RUN sed -i 's/}/ application\/wasm wasm;\n}/g' /etc/nginx/mime.types
COPY --from=jsbuild /build/element-web-matthew-p2p/webapp /usr/share/nginx/html COPY --from=jsbuild /build/element-web-matthew-p2p/webapp /usr/share/nginx/html