From 12901d13edea217a21762b564e196309985fb889 Mon Sep 17 00:00:00 2001 From: Rohit Agre Date: Sat, 14 Oct 2023 00:28:07 +0530 Subject: [PATCH 1/2] add dockerisation --- .dockerignore | 7 +++++++ Dockerfile | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d121b022 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +yarn-error.log +npm-debug.log +Dockerfile +.dockerignore +.git +.gitignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d95023b6 --- /dev/null +++ b/Dockerfile @@ -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"] From 20606b0e2b57d44361d2cd774aa65f0fbada07d8 Mon Sep 17 00:00:00 2001 From: Rohit Agre Date: Mon, 16 Oct 2023 12:28:01 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 0ffbbc1f..116b0090 100644 --- a/README.md +++ b/README.md @@ -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 |