-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paramtamtam
committed
Jul 8, 2020
0 parents
commit f238061
Showing
20 changed files
with
799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/out | ||
/node_modules | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.{yml, yaml, sh, conf}] | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: release | ||
|
||
on: | ||
release: # Docs: <https://git.io/JeBz1#release-event-release> | ||
types: [published] | ||
|
||
jobs: | ||
demo: | ||
name: Update demonstration, hosted on github pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup NodeJS | ||
uses: actions/setup-node@v1 # Action page: <https://github.com/actions/setup-node> | ||
with: | ||
node-version: 12 | ||
|
||
- name: Generate version value | ||
run: echo "::set-env name=PACKAGE_VERSION::${GITHUB_REF##*/v}" | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Install dependencies | ||
run: ./bin/generator.js -c ./configuration.json -o ./out | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: content | ||
path: out/ | ||
|
||
- name: Switch to github pages branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: gh-pages | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: content | ||
|
||
- name: Setup git | ||
run: | | ||
git config --global user.name "$GITHUB_ACTOR" | ||
git config --global user.email '[email protected]' | ||
git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git" | ||
- name: Stage changes | ||
run: git add . | ||
|
||
- name: Commit changes | ||
run: git commit -m "Deploying ${GITHUB_SHA} to Github Pages" | ||
|
||
- name: Push changes | ||
run: git push github --force | ||
|
||
docker-image: | ||
name: Build docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Generate version value | ||
run: echo "::set-env name=APP_VERSION::${GITHUB_REF##*/}@`echo ${GITHUB_SHA} | cut -c1-8`" | ||
|
||
- name: Generate image tag value | ||
run: echo "::set-env name=IMAGE_TAG::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3` | ||
|
||
- name: Make docker login | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin &> /dev/null | ||
|
||
- name: Build image | ||
run: docker build --build-arg "APP_VERSION=${APP_VERSION}" --tag "tarampampam/tinifier:${IMAGE_TAG}" --tag "tarampampam/tinifier:latest" -f ./Dockerfile . | ||
|
||
- name: Push version image | ||
run: docker push "tarampampam/tinifier:${IMAGE_TAG}" | ||
|
||
- name: Push latest image | ||
run: docker push "tarampampam/tinifier:latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags-ignore: | ||
- '**' | ||
pull_request: | ||
|
||
jobs: # Docs: <https://git.io/JvxXE> | ||
generate: | ||
name: Try to run generator | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup NodeJS | ||
uses: actions/setup-node@v1 # Action page: <https://github.com/actions/setup-node> | ||
with: | ||
node-version: 12 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Run generator | ||
run: ./bin/generator.js -c ./configuration.json -o ./out | ||
|
||
- name: Test file creation | ||
run: test -f ./out/ghost/404.html | ||
|
||
docker-build: | ||
name: Try to run generator | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build docker image | ||
run: docker build -f ./Dockerfile . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## IDEs | ||
/.vscode | ||
/.idea | ||
|
||
## Vendors | ||
/node_modules | ||
|
||
## Lock files (use yarn only) | ||
/package-lock.json | ||
|
||
## Dist | ||
/out | ||
|
||
## Temp dirs & trash | ||
/npm-debug.log | ||
/yarn-error.log | ||
.DS_Store | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
|
||
All notable changes to this package will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver]. | ||
|
||
## v1.0.0 | ||
|
||
### Changed | ||
|
||
- WIP | ||
|
||
[keepachangelog]:https://keepachangelog.com/en/1.0.0/ | ||
[semver]:https://semver.org/spec/v2.0.0.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Image page: <https://hub.docker.com/_/node> | ||
FROM node:12.16.2-alpine as builder | ||
|
||
WORKDIR /src | ||
|
||
COPY . . | ||
|
||
RUN set -x \ | ||
&& yarn install --frozen-lockfile \ | ||
&& ./bin/generator.js -c ./configuration.json -o ./out | ||
|
||
# Image page: <https://hub.docker.com/_/nginx> | ||
FROM nginx:1.18-alpine | ||
|
||
COPY --from=builder --chown=nginx /src/docker/docker-entrypoint.sh /docker-entrypoint.sh | ||
COPY --from=builder --chown=nginx /src/docker/nginx-server.conf /etc/nginx/conf.d/default.conf | ||
COPY --from=builder --chown=nginx /src/static /opt/html | ||
COPY --from=builder --chown=nginx /src/out /opt/html | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) <https://github.com/tarampampam> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/make | ||
# Makefile readme (ru): <http://linux.yaroslavl.ru/docs/prog/gnu_make_3-79_russian_manual.html> | ||
# Makefile readme (en): <https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents> | ||
|
||
SHELL = /bin/sh | ||
|
||
DOCKER_BIN = $(shell command -v docker 2> /dev/null) | ||
APP_NAME = $(notdir $(CURDIR)) | ||
|
||
.DEFAULT_GOAL : help | ||
|
||
help: ## Show this help | ||
@printf "\033[33m%s:\033[0m\n" 'Available commands' | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
image: ## Build docker image | ||
$(DOCKER_BIN) build -f ./Dockerfile -t $(APP_NAME):local . | ||
@printf "\n \e[30;42m %s \033[0m\n\n" 'Now you can use image like `docker run --rm -p 8080:8080 $(APP_NAME):local ...`' | ||
|
||
shell: ## Start shell into container with node | ||
$(DOCKER_BIN) run --rm -ti -v "$(shell pwd):/src:rw" -w "/src" --user "$(shell id -u):$(shell id -g)" node:12.16.2-alpine sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<p align="center"> | ||
<img src="https://hsto.org/webt/rg/ys/c3/rgysc33oc7jiufdzmwrkohpmef8.png" width="94" alt="" /> | ||
</p> | ||
|
||
# Static error pages in a Docker container | ||
|
||
[![Build Status][badge_build_status]][link_build_status] | ||
[![License][badge_license]][link_license] | ||
|
||
This repository contains a very simple generator for server error pages _(like `404: Not found`)_ and ready docker image with web server for error pages serving. | ||
|
||
Generator ([`bin/generator.js`](./bin/generator.js)) allows you: | ||
|
||
- Use different templates (section `templates` in configuration file) | ||
- Generate pages with arbitrary content according to a specific template | ||
|
||
Can be used for [Traefik error pages customization](https://docs.traefik.io/middlewares/errorpages/). | ||
|
||
### Usage | ||
|
||
Just execute (installed `nodejs` is required): | ||
|
||
```bash | ||
$ bin/generator.js -c ./configuration.json -o ./out | ||
``` | ||
|
||
And watch into `./out` directory: | ||
|
||
```text | ||
./out | ||
└── ghost | ||
├── 400.html | ||
├── 401.html | ||
├── 403.html | ||
├── 404.html | ||
├── ... | ||
└── 505.html | ||
``` | ||
|
||
Default configuration can be found in [`configuration.json`](./configuration.json) file. | ||
|
||
### Docker | ||
|
||
Start image (`nginx` inside): | ||
|
||
```bash | ||
$ docker run --rm -p "8080:8080" tarampampam/error-pages:1.0.0 | ||
``` | ||
|
||
And open in your browser `http://127.0.0.1:8080/ghost/400.html`. Additionally, you can set "default" pages theme by passing `TEMPLATE_NAME` environment variable (eg.: `-e "TEMPLATE_NAME=ghost"`) - in this case all error pages will be accessible in root directory (eg.: `http://127.0.0.1:8080/400.html`). | ||
|
||
Also you can use generated error pages in your own docker images: | ||
|
||
```dockerfile | ||
FROM nginx:1.18-alpine | ||
|
||
COPY --from=tarampampam/error-pages:1.0.0 /opt/html/ghost /usr/share/nginx/html/error-pages | ||
``` | ||
|
||
> [`error_page` for `nginx` configuration](http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) | ||
## Changes log | ||
|
||
[![Release date][badge_release_date]][link_releases] | ||
[![Commits since latest release][badge_commits_since_release]][link_commits] | ||
|
||
Changes log can be [found here][link_changes_log]. | ||
|
||
## Support | ||
|
||
[![Issues][badge_issues]][link_issues] | ||
[![Issues][badge_pulls]][link_pulls] | ||
|
||
If you will find any package errors, please, [make an issue][link_create_issue] in current repository. | ||
|
||
## License | ||
|
||
This is open-sourced software licensed under the [MIT License][link_license]. | ||
|
||
[badge_build_status]:https://img.shields.io/github/workflow/status/tarampampam/error-pages-docker/tests/master | ||
[badge_release_date]:https://img.shields.io/github/release-date/tarampampam/error-pages-docker.svg?style=flat-square&maxAge=180 | ||
[badge_commits_since_release]:https://img.shields.io/github/commits-since/tarampampam/error-pages-docker/latest.svg?style=flat-square&maxAge=180 | ||
[badge_issues]:https://img.shields.io/github/issues/tarampampam/error-pages-docker.svg?style=flat-square&maxAge=180 | ||
[badge_pulls]:https://img.shields.io/github/issues-pr/tarampampam/error-pages-docker.svg?style=flat-square&maxAge=180 | ||
[badge_license]:https://img.shields.io/github/license/tarampampam/error-pages-docker.svg?longCache=true | ||
[link_releases]:https://github.com/tarampampam/error-pages-docker/releases | ||
[link_commits]:https://github.com/tarampampam/error-pages-docker/commits | ||
[link_changes_log]:https://github.com/tarampampam/error-pages-docker/blob/master/CHANGELOG.md | ||
[link_issues]:https://github.com/tarampampam/error-pages-docker/issues | ||
[link_pulls]:https://github.com/tarampampam/error-pages-docker/pulls | ||
[link_build_status]:https://travis-ci.org/tarampampam/error-pages-docker | ||
[link_create_issue]:https://github.com/tarampampam/error-pages-docker/issues/new | ||
[link_license]:https://github.com/tarampampam/error-pages-docker/blob/master/LICENSE |
Oops, something went wrong.