Skip to content

Commit b00d0b8

Browse files
authored
Merge pull request #31 from weaponsforge/feat/weaponsforge-30
feat: hide USE_DOCKER env variable
2 parents 6bdc937 + 4fadd8b commit b00d0b8

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FROM base AS development
1515
RUN yarn install
1616
COPY . ./
1717
EXPOSE 3000
18-
CMD ["yarn", "dev"]
18+
CMD ["yarn", "dev:docker"]
1919

2020
# BUILD TARGET
2121
FROM base AS build

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ These steps use **Node** and **Yarn** to run the development app.
7272

7373
Runs the Gulp and Browser-Sync tasks, launching the local website for development mode.
7474

75+
### `npm run dev:docker`
76+
77+
Sets the `IS_DOCKER=true` environment variable before running the Gulp and Browser-Sync tasks inside a Docker container. It doesn't launch the local website for development mode.
78+
> This command runs only in a Linux environment.
79+
7580
### `npm start`
7681

77-
Starts a simple ExpressJS web server serving the static website app from its static middleware.
82+
Runs a simple ExpressJS web server serving the static website app using its static middleware.
7883

7984
## Usage with Docker
8085

@@ -92,31 +97,33 @@ https://hub.docker.com/r/weaponsforge/livereload-basic
9297

9398
2. Run the development image.
9499
- Using only Docker (1st option):
95-
> **INFO:** This option requires having the static website development HTML, CSS and JavaScript files inside a `"/public"` directory, consisting of at least:
100+
> **INFO:** This option requires having the static website development HTML, CSS, and JavaScript files inside a `FILE_DIRECTORY` directory in the host machine. This example uses a `FILE_DIRECTORY` named `"/public"`, which contains at least:
96101

97102
```
98103
├─ my-website-project
99104
│ ├─ public
100105
│ ├─── index.html
101106
│ ├─── ...
102107
```
103-
Navigate to the website project directory (for example, `"my-website-project"`) using a terminal, then run:
108+
Navigate to the root project directory (for example, `"my-website-project"`) using a terminal, then run:
104109

105110
```
106111
# On Linux OS
107-
docker run -it --rm -p 3000:3000 -v $(pwd)/public:/opt/app/public -e IS_DOCKER=true weaponsforge/livereload-basic:latest
112+
docker run -it --rm -p 3000:3000 -v $(pwd)/FILE_DIRECTORY:/opt/app/public weaponsforge/livereload-basic:latest
108113

109114
# On Windows OS
110-
docker run -it --rm -p 3000:3000 -v %cd%\public:/opt/app/public -e USE_POLLING=true -e IS_DOCKER=true weaponsforge/livereload-basic:latest
115+
docker run -it --rm -p 3000:3000 -v %cd%\FILE_DIRECTORY:/opt/app/public -e USE_POLLING=true weaponsforge/livereload-basic:latest
111116
```
112117

118+
> _**TIP:**<br>
119+
> Replace `-p 3000:3000` with other port bindings as needed._
120+
113121
- Using Docker compose (2nd option):<br>
114122
- `docker compose -f docker-compose.dev.yml up`
115123
- > **INFO:** Uncomment the following lines in the `docker-compose.dev.yml` file when working in a Windows host.
116124
```
117-
# Enable USE_POLLING if working in Windows WSL2 to enable hot reload
125+
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
118126
environment:
119-
- IS_DOCKER=true
120127
- USE_POLLING=true
121128
```
122129
3. Refer to the [Usage](#usage) section steps **# 2 - # 4** for local development.
@@ -232,4 +239,4 @@ Add the following GitHub Secrets and Variables to enable deployment to Docker Hu
232239

233240
@weaponsforge<br>
234241
20200630<br>
235-
20241006
242+
20241008

docker-compose.dev.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ services:
1212
ports:
1313
- "3000:3000"
1414
- "9229:9229"
15-
# Enable USE_POLLING if working in Windows WSL2 to enable hot reload
16-
environment:
17-
- IS_DOCKER=true
15+
# Enable USE_POLLING if working in Windows WSL2 to enable live reload
16+
# environment:
1817
# - USE_POLLING=true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"scripts": {
1111
"start": "node server.js",
12-
"dev": "./node_modules/.bin/gulp dev"
12+
"dev": "./node_modules/.bin/gulp dev",
13+
"dev:docker": "set IS_DOCKER=true && npm run dev"
1314
},
1415
"keywords": [
1516
"gulp",

0 commit comments

Comments
 (0)