Skip to content

Commit 9957149

Browse files
authored
Merge pull request element-hq#9426 from vector-im/travis/dockerfile-continued
Add Dockerfile (part 2)
2 parents 269a995 + a263ca8 commit 9957149

4 files changed

Lines changed: 108 additions & 0 deletions

File tree

‎.dockerignore‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Exclude a bunch of stuff which can make the build context a larger than it needs to be
2+
.git/
3+
test/
4+
webapp/
5+
lib/
6+
node_modules/
7+
electron_app/
8+
karma-reports/
9+
.idea/
10+
.tmp/
11+
config.json*

‎Dockerfile‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Builder
2+
FROM node:10-alpine as builder
3+
4+
# Support custom branches of the react-sdk and js-sdk. This also helps us build
5+
# images of riot-web develop.
6+
ARG USE_CUSTOM_SDKS=false
7+
ARG REACT_SDK_REPO="https://github.com/matrix-org/matrix-react-sdk.git"
8+
ARG REACT_SDK_BRANCH="master"
9+
ARG JS_SDK_REPO="https://github.com/matrix-org/matrix-js-sdk.git"
10+
ARG JS_SDK_BRANCH="master"
11+
12+
RUN apk add --no-cache git dos2unix
13+
14+
WORKDIR /src
15+
16+
COPY . /src
17+
RUN dos2unix /src/scripts/docker-link-repos.sh && sh /src/scripts/docker-link-repos.sh
18+
RUN yarn install
19+
RUN yarn build
20+
21+
# Copy the config now so that we don't create another layer in the app image
22+
RUN cp /src/config.sample.json /src/webapp/config.json
23+
24+
25+
# App
26+
FROM nginx:latest
27+
28+
COPY --from=builder /src/webapp /app
29+
30+
RUN rm -rf /usr/share/nginx/html \
31+
&& ln -s /app /usr/share/nginx/html

‎README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,42 @@ To change the config.json for the desktop app, create a config file which will b
253253

254254
In the paths above, `$NAME` is typically `Riot`, unless you use `--profile $PROFILE` in which case it becomes `Riot-$PROFILE`.
255255

256+
Running from Docker
257+
===================
258+
259+
The Docker image can be used to serve riot-web as a web server. The easiest way to use
260+
it is to use the prebuilt image:
261+
```bash
262+
docker run -p 80:80 vectorim/riot-web
263+
```
264+
265+
To supply your own custom `config.json`, map a volume to `/app/config.json`. For example,
266+
if your custom config was located at `/etc/riot-web/config.json` then your Docker command
267+
would be:
268+
```bash
269+
docker run -p 80:80 -v /etc/riot-web/config.json:/app/config.json vectorim/riot-web
270+
```
271+
272+
To build the image yourself:
273+
```bash
274+
git clone https://github.com/vector-im/riot-web.git riot-web
275+
cd riot-web
276+
git checkout master
277+
docker build -t vectorim/riot-web .
278+
```
279+
280+
If you're building a custom branch, or want to use the develop branch, check out the appropriate
281+
riot-web branch and then run:
282+
```bash
283+
docker build -t vectorim/riot-web:develop \
284+
--build-arg USE_CUSTOM_SDKS=true \
285+
--build-arg REACT_SDK_REPO="https://github.com/matrix-org/matrix-react-sdk.git" \
286+
--build-arg REACT_SDK_BRANCH="develop" \
287+
--build-arg JS_SDK_REPO="https://github.com/matrix-org/matrix-js-sdk.git" \
288+
--build-arg JS_SDK_BRANCH="develop" \
289+
.
290+
```
291+
256292
Labs Features
257293
=============
258294

‎scripts/docker-link-repos.sh‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
if [ $USE_CUSTOM_SDKS == false ]
6+
then
7+
echo "skipping react-sdk and js-sdk installs: USE_CUSTOM_SDKS is false"
8+
exit 0
9+
fi
10+
11+
echo "Linking js-sdk"
12+
git clone $JS_SDK_REPO js-sdk
13+
cd js-sdk
14+
git checkout $JS_SDK_BRANCH
15+
yarn link
16+
yarn install
17+
cd ../
18+
19+
echo "Linking react-sdk"
20+
git clone $REACT_SDK_REPO react-sdk
21+
cd react-sdk
22+
git checkout $REACT_SDK_BRANCH
23+
yarn link
24+
yarn link matrix-js-sdk
25+
yarn install
26+
cd ../
27+
28+
echo "Setting up riot-web with react-sdk and js-sdk packages"
29+
yarn link matrix-js-sdk
30+
yarn link matrix-react-sdk

0 commit comments

Comments
 (0)