mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 09:54:11 +03:00
Add a SVGO Docker image for Simpleicons formatting (#1532)
* Add a SVGO Docker image * Update Dockerfile and .dockerignore Update the Dockerfile to create a docker image that is generally applicable to run NPM commands, including but not limited to: - npm run test - npm run svgo - npm run lint Also updated the .dockerignore file to exclude: - The node_modules folder - Common Jekyll folders/files - Files generated by the build script The reason for choosing the alpine docker image (rather than a node docker image) is that the CLI out of the box is better. * Add section on using Docker to Contributing Guidelines * Readd entrypoint for SVGO optimization to Dockerfile Update the Dockerfile based on the original work in 32993385daad3a66d6a2f8094c1dde5c33d2a03b by re-adding an ENTRYPOINT to the Dockerfile. This ENTRYPOINT makes it extremely easy to spin up a quick Docker container to optimize a single SVG (much simpler than my copy-in -> optimize -> copy-out approach). The description for how to use the Docker image to run other NPM scripts has been updated accordingly. The provided command overrides the above ENTRYPOINT by simple starting a shell so the user can interact with the project. Co-authored-by: Eric Cornelisesn <ericornelissen@gmail.com>
This commit is contained in:
parent
540635cedf
commit
0756e1d9a7
11
.dockerignore
Normal file
11
.dockerignore
Normal file
@ -0,0 +1,11 @@
|
||||
node_modules/
|
||||
|
||||
# Jekyll
|
||||
_site/
|
||||
.sass-cache/
|
||||
.jekyll-cache/
|
||||
.jekyll-metadata
|
||||
|
||||
# Build files
|
||||
icons/*.js
|
||||
/index.js
|
@ -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
|
||||
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -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"]
|
Loading…
Reference in New Issue
Block a user