Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dockerisation #867

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
yarn-error.log
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:18-alpine
VOLUME /public
WORKDIR /srv/http-server
COPY package.json package-lock.json ./
RUN npm install --production
COPY . .
EXPOSE 8080
USER node
WORKDIR /public
ENTRYPOINT ["node", "/srv/http-server/bin/http-server"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ This will install `http-server` globally so that it may be run from the command

**Note:** Caching is on by default. Add `-c-1` as an option to disable caching.

#### Using Docker

Run the following command in any directory to serve its contents:
```bash
docker run -d -p 8080:8080 -v "$(PWD):/public" jammer99/http-server
```
*Now you can visit http://localhost:8080 to view your server*

You can also use [available options](#available-options) as the last argument of `docker run` command.

```bash
docker run -d -p 8080:8080 -v "$(PWD):/public" jammer99/http-server "-c-1"
```

## Available Options:

| Command | Description | Defaults |
Expand Down