Skip to content

Commit 1b849a6

Browse files
authored
Merge pull request #36 from weaponsforge/chore/LRB-35
docs(LRB-35): add notes on binding other ports within the docker dev mode
2 parents f596297 + f505b2e commit 1b849a6

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Simple localhost static website development environment for plain HTML, CSS, and
44

55
Its development static hosting and file-serving architecture are closer to traditional static web servers. Uses **Gulp** and **Browser-Sync**
66

7-
> [!NOTE]
7+
> [!NOTE]
88
> An alternate localhost static development environment using **Webpack**, also with live reload, is available at<br>
99
> https://github.com/weaponsforge/livereload-webpack
1010
@@ -60,15 +60,18 @@ These steps use **Node** and **Yarn** to run the development app.
6060
1. Run the localhost static website development environment.<br>
6161
`yarn dev`
6262

63-
2. Edit the existing static files from the **./public** directory and wait for live reload. Your updates will reflect on the web browser.
63+
2. Launch the local development website at:<br>
64+
`http://localhost:3000`
6465

65-
3. To include new static website files on live reload:
66+
3. Edit the existing static files from the **./public** directory and wait for live reload. Your updates will reflect on the web browser.
67+
68+
4. To include new static website files on live reload:
6669
- Create new static (.html, .js, .css) files inside the **./public** directory.
6770
- Refresh the web browser.
6871
- Restart the web server if updates don't show after a while.<br>
6972
`yarn dev`
7073

71-
4. Run the production static website (does not use live reload).<br>
74+
5. Run the production static website (does not use live reload).<br>
7275
`yarn start`
7376

7477
## Available Scripts
@@ -94,9 +97,9 @@ This project deploys the latest **development** Docker image to Docker Hub on th
9497

9598
https://hub.docker.com/r/weaponsforge/livereload-basic
9699

97-
1. Pull the pre-built development Docker image using any of the two (2) options:
100+
1. Pull the "latest" pre-built development Docker image using any of the two (2) options:
98101
- Open a terminal and run:<br>
99-
`docker pull weaponsforge/livereload-basic:latest`
102+
`docker pull weaponsforge/livereload-basic`
100103
- Navigate to the livereload-basic root project directory, then run:<br>
101104
`docker compose -f docker-compose.dev.yml pull`
102105

@@ -112,24 +115,35 @@ https://hub.docker.com/r/weaponsforge/livereload-basic
112115
```
113116
Navigate to the root project directory (for example, `"my-website-project"`) using a terminal, then run:
114117

115-
```
118+
```bash
116119
# On Linux OS
117-
docker run -it --rm -p 3000:3000 -v $(pwd)/FILE_DIRECTORY:/opt/app/public weaponsforge/livereload-basic:latest
120+
docker run -it --rm -p 3000:3000 -v $(pwd)/FILE_DIRECTORY:/opt/app/public weaponsforge/livereload-basic
118121

119-
# On Windows OS
120-
docker run -it --rm -p 3000:3000 -v %cd%\FILE_DIRECTORY:/opt/app/public -e USE_POLLING=true weaponsforge/livereload-basic:latest
122+
# On Windows OS (Command Prompt)
123+
docker run -it --rm -p 3000:3000 -v %cd%\FILE_DIRECTORY:/opt/app/public -e USE_POLLING=true weaponsforge/livereload-basic
121124
```
122125

123-
> _**TIP:**<br>
124-
> Replace `-p 3000:3000` with other port bindings as needed._
126+
> 💡**TIP:**<br>
127+
> _To use other port bindings aside from the default `3000`:_
128+
> 1. Add a `PORT` environment variable eg., `-e PORT=3003`
129+
> 2. Replace `-p 3000:3000` with the `PORT` environment variable.
125130

126131
- Using Docker compose (2nd option):<br>
127132
- `docker compose -f docker-compose.dev.yml up`
128-
- > **INFO:** Uncomment the following lines in the `docker-compose.dev.yml` file when working in a Windows host.
133+
- > **INFO:** Uncomment the following lines in the `docker-compose.dev.yml` file when working in a **Windows host**.
134+
```yml
135+
environment:
136+
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
137+
- USE_POLLING=true
129138
```
130-
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
131-
environment:
132-
- USE_POLLING=true
139+
- > **INFO:** Enable using **other ports** - uncomment the following lines in the `docker-compose.dev.yml` and expose the new port under the `"ports"` section.
140+
```yml
141+
ports:
142+
- "3002:3002"
143+
environment:
144+
# Use other ports aside from the 3000 default
145+
# Ensure to map and expose this port under the "ports" section eg., -"3002:3002"
146+
- PORT=3002
133147
```
134148
3. Refer to the [Usage](#usage) section steps **# 2 - # 4** for local development.
135149

@@ -158,7 +172,7 @@ The **development** Docker image contains Node runtime, Gulp, Browser-Sync and Y
158172

159173
### Production Image
160174

161-
The **production** Docker image contains the static website running in an nginx container for minimal production website build. Build it with:
175+
The **production** Docker image contains the static website running in an Nginx container for minimal production website build. Build it with:
162176

163177
`docker compose -f docker-compose.prod.yml build`
164178

docker-compose.dev.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ services:
1212
ports:
1313
- "3000:3000"
1414
- "9229:9229"
15-
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
1615
# environment:
16+
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
1717
# - USE_POLLING=true
18+
#
19+
# Use other ports aside from the default 3000
20+
# Ensure to map and expose this port under the "ports" section eg., -"3002:3002"
21+
# - PORT=3002

0 commit comments

Comments
 (0)