Skip to content

Commit e8a96d0

Browse files
committed
dev: add Dockerfile
1 parent 8ca8c7a commit e8a96d0

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
yarn-error.log
3+
npm-debug.log
4+
Dockerfile
5+
.dockerignore
6+
.git
7+
.gitignore
8+
testdir/privatefile

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:16-alpine
2+
VOLUME /public
3+
WORKDIR /srv/http-server
4+
COPY package.json package-lock.json ./
5+
RUN npm install --production
6+
COPY . .
7+
EXPOSE 8080
8+
ENTRYPOINT ["node", "./bin/http-server"]

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ This will install `http-server` globally so that it may be run from the command
3030

3131
npm install http-server
3232

33+
#### Using Docker
34+
35+
Note: a public image is not provided currently, but you can build one yourself
36+
with the provided Dockerfile.
37+
38+
1. Create an image
39+
```
40+
docker build -t my-image .
41+
```
42+
2. Run a container
43+
```
44+
docker run -p 8080:8080 -v "${pwd}:/public" my-image
45+
```
46+
In the example above we're serving the directory `./` (working directory).
47+
If you wanted to serve `./test` you'd replace `${pwd}` with `${pwd}/test`.
48+
3349
## Usage:
3450

3551
http-server [path] [options]

0 commit comments

Comments
 (0)