Skip to content

Commit e937aa9

Browse files
authored
Merge pull request #10 from qdm12/dockerfile-improvements
Dockerfile improvements
2 parents 0040680 + e19c7fd commit e937aa9

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.git
2+
.dockerignore
3+
.gitignore
14
Dockerfile
25
README.md
36
LICENSE

Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
# multistage - builder image
2-
FROM node:alpine AS builder
1+
ARG ALPINE_VERSION=3.12
2+
ARG NODE_VERSION=15
3+
ARG NGINX_VERSION=1.19.6
4+
5+
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS builder
36
WORKDIR /app/Lightspeed-react
4-
COPY . .
7+
COPY package.json package-lock.json ./
58
RUN npm install
6-
7-
# configure ip, hardcoded to webrtc container address (8080) for now
8-
RUN sed -i "s|stream.gud.software|localhost|g" public/config.json
9-
10-
# build it
9+
COPY . .
1110
RUN npm run build
1211

13-
# runtime image
14-
FROM nginx:stable
15-
COPY --from=builder /app/Lightspeed-react/build /usr/share/nginx/html
12+
13+
FROM nginx:${NGINX_VERSION}-alpine
14+
ENV WEBSOCKET_HOST=localhost
15+
ENV WEBSOCKET_PORT=8080
16+
EXPOSE 80/tcp
17+
COPY --chown=1000 docker/entrypoint.sh /docker-entrypoint.d/entrypoint.sh
18+
COPY --chown=1000 docker/config.json.template /config.json.template
19+
COPY --from=builder --chown=1000 /app/Lightspeed-react/build /usr/share/nginx/html

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,40 @@ This is one of three components required for Project Lightspeed. Project Lightsp
7575

7676
## Getting Started
7777

78+
## Setup
79+
80+
### Docker
81+
82+
1. Install [git](https://git-scm.com/downloads)
83+
1. Build the image from the master branch with:
84+
85+
```sh
86+
docker build -t grvydev/lightspeed-react https://github.com/GRVYDEV/Lightspeed-react.git
87+
```
88+
89+
1. Run it with
90+
91+
```sh
92+
docker run -it --rm \
93+
-p 8000:80/tcp \
94+
-e WEBSOCKET_HOST=localhost \
95+
-e WEBSOCKET_PORT=8080 \
96+
grvydev/lightspeed-react
97+
```
98+
99+
Where your websocket host from the browser/client perspective is accessible on `localhost:8080`.
100+
101+
1. You can now access it at [localhost:8000](http://localhost:8000).
102+
103+
### Locally
104+
78105
To get a local copy up and running follow these simple steps.
79106

80-
### Prerequisites
107+
#### Prerequisites
81108

82109
In order to run this npm is required. Installation instructions can be found <a href="https://www.rust-lang.org/tools/https://www.npmjs.com/get-npm">here</a>. Npm Serve is required as well if you want to host this on your machine. That can be found <a href="https://www.npmjs.com/package/serve">here</a>
83110

84-
### Installation
111+
#### Installation
85112

86113
```sh
87114
git clone https://github.com/GRVYDEV/Lightspeed-react.git
@@ -91,8 +118,10 @@ npm install
91118

92119
<!-- USAGE EXAMPLES -->
93120

94-
## Usage
121+
#### Usage
122+
95123
First build the frontend
124+
96125
```sh
97126
cd Lightspeed-react
98127
npm run build
@@ -101,6 +130,7 @@ npm run build
101130
You should then configure the websocket URL in `config.json` in the `build` directory.
102131

103132
Now you can host the static site locally, by using `serve` for example
133+
104134
```sh
105135
serve -s build -l 80
106136
```

docker/config.json.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"wsUrl": "ws://${WEBSOCKET_HOST}:${WEBSOCKET_PORT}/websocket"
3+
}

docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
envsubst < /config.json.template > "/usr/share/nginx/html/config.json"

0 commit comments

Comments
 (0)