diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ed34e35 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +node_modules +*.md +test +.git* +cache diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6cf132b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM mhart/alpine-node + +MAINTAINER Dmitry Shirokov + +ADD package.json /tmp/package.json + +RUN cd /tmp && \ + npm install --production && \ + mkdir -p /opt/npm-proxy-cache && \ + cp -a /tmp/node_modules /opt/npm-proxy-cache && \ + mkdir -p /opt/npm-proxy-cache/cache + +VOLUME /opt/npm-proxy-cache/cache + +WORKDIR /opt/npm-proxy-cache +ADD . /opt/npm-proxy-cache + +# Expose API port +EXPOSE 8080 + +ENTRYPOINT ["node", "/opt/npm-proxy-cache/bin/npm-proxy-cache"] diff --git a/README.md b/README.md index accf33d..50722e0 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,19 @@ more work and maintenance. ## Installation - +### NPM npm install npm-proxy-cache -g +### Docker +The docker image of this repository is not hosted on Docker Hub (yet) + +To run npm-proxy-cache as a Docker container, you need to build the image first: + +`docker build -t npm-proxy-cache .` + +After building the image successfully, you can run the Docker container. To pass parameters, simply append them to the `docker run` command, like so: + +`docker run -t npm-proxy-cache --port 8080 --host 0.0.0.0 --expired` ## Usage @@ -56,7 +66,6 @@ overriden using command line options: -m, --internal-port HTTPs port to use for internal proxying "MITM" server (necessary for running on Windows systems) --help This help - ## Why can't I use the built-in npm cache? Well, for some reason npm cache works not as expected and cache hits are low. Additionally, diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5899fc3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +npmproxycache: + build: . + ports: + - "8080:8080" + # You can pass parameters here + command: "--host 0.0.0.0 --port 8080 --verbose --expired"