diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..31c0d4585350 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules/ + +# Jekyll +_site/ +.sass-cache/ +.jekyll-cache/ +.jekyll-metadata + +# Build files +icons/*.js +/index.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a68c3a01c5e..5e2d17da5d9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,7 @@ Simple Icons welcomes contributions and corrections. Before contributing, please * [Requesting an Icon](#requesting-an-icon) * [Adding or Updating an Icon](#adding-or-updating-an-icon) * [Building the Website](#building-locally) +* [Using Docker](#using-docker) ## Requesting an Icon @@ -90,6 +91,10 @@ All icons in Simple Icons have been optimized with the [SVGO tool](https://githu * Set the precision to about 3, depending on if there is a loss of quality. * Leave the remaining settings untouched (or reset them with the button at the bottom of the settings). * Click the download button. +* The [SVGO Command Line Tool](https://github.com/svg/svgo) in Docker + * If none of the options above work for you, it is possible to build a Docker image for compressing the images. + * Build: `docker build . -t simple-icons` + * Run: `docker run --rm -v ${PWD}/icons/file-to-optimize.svg:/image.svg simple-icons` ### 4. Annotate the Icon @@ -222,6 +227,33 @@ Alternatively, you can build and run the website in a readily configured online [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/simple-icons/simple-icons) +## Using Docker + +You can build a Docker image for this project from the Dockerfile by running: + +```bash +# Build the Docker image for simple-icons (if you haven't yet) +$ docker build . -t simple-icons + +# Start a Docker container for simple-icons and attach to it +$ docker run -it --rm --entrypoint "/bin/ash" simple-icons +``` + +### Jekyll Server using Docker + +To use a Docker container to run the Jekyll server for the website, run: + +```bash +# Start a container running `jekyll serve` in the background +$ docker run -d -p 4000:4000 --rm --volume $PWD:/srv/jekyll --name simple-icons-server jekyll/jekyll jekyll serve + +# Inspect the server logs +$ docker logs simple-icons-server + +# Stop the server (and delete the container) +$ docker stop simple-icons-server +``` + --- # Versioning diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..2f697aa518de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.12 + +RUN apk add --update nodejs npm + +WORKDIR /simple-icons +COPY package*.json /simple-icons/ +RUN npm install + +COPY . . + +ENTRYPOINT ["npm", "run", "svgo", "--", "/image.svg"]