Extract error pages & change container registry
This commit is contained in:
parent
15151e53a7
commit
3c5d87a98b
7 changed files with 5 additions and 125 deletions
31
.github/workflows/main.yaml
vendored
31
.github/workflows/main.yaml
vendored
|
|
@ -4,33 +4,12 @@ on:
|
|||
branches:
|
||||
- main
|
||||
env:
|
||||
CONTAINER_REGISTRY: registry.digitalocean.com/declared
|
||||
CONTAINER_REGISTRY: schmelczera
|
||||
DOMAIN: decla.red
|
||||
|
||||
jobs:
|
||||
build-error-pages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout current branch with lfs
|
||||
uses: actions/checkout@main
|
||||
with:
|
||||
lfs: true
|
||||
|
||||
- name: Setup auth tokens
|
||||
run: |
|
||||
# Docker Hub
|
||||
docker login -u ${{ secrets.DOCKER_TOKEN }} -p ${{ secrets.DOCKER_TOKEN }} $CONTAINER_REGISTRY
|
||||
|
||||
- name: Build and push error pages
|
||||
run: |
|
||||
docker build . -t $CONTAINER_REGISTRY/declared-error-pages
|
||||
docker push $CONTAINER_REGISTRY/declared-error-pages
|
||||
working-directory: error-pages
|
||||
|
||||
build-ingress:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-error-pages
|
||||
steps:
|
||||
- name: Checkout current branch with lfs
|
||||
uses: actions/checkout@main
|
||||
|
|
@ -39,8 +18,7 @@ jobs:
|
|||
|
||||
- name: Setup auth tokens
|
||||
run: |
|
||||
# Docker Hub
|
||||
docker login -u ${{ secrets.DOCKER_TOKEN }} -p ${{ secrets.DOCKER_TOKEN }} $CONTAINER_REGISTRY
|
||||
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push ingress
|
||||
run: |
|
||||
|
|
@ -50,8 +28,6 @@ jobs:
|
|||
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-error-pages
|
||||
steps:
|
||||
- name: Checkout current branch with lfs
|
||||
uses: actions/checkout@main
|
||||
|
|
@ -60,8 +36,7 @@ jobs:
|
|||
|
||||
- name: Setup auth tokens
|
||||
run: |
|
||||
# Docker Hub
|
||||
docker login -u ${{ secrets.DOCKER_TOKEN }} -p ${{ secrets.DOCKER_TOKEN }} $CONTAINER_REGISTRY
|
||||
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push frontend
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
.dockeringore
|
||||
built
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
FROM python:3.8-alpine
|
||||
|
||||
WORKDIR /home/python
|
||||
COPY . .
|
||||
RUN mkdir -m 777 built
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
from typing import NamedTuple, Dict, List, Type
|
||||
from os import makedirs, path
|
||||
from sys import argv
|
||||
|
||||
|
||||
template_path = 'template.html'
|
||||
result_path = 'built'
|
||||
|
||||
class Substitutions(NamedTuple):
|
||||
title: str
|
||||
description: str
|
||||
|
||||
error_messages: Dict[str, Substitutions] = {
|
||||
'403': Substitutions(
|
||||
title='403 - Forbidden',
|
||||
description='You are not allowed to view this resource.'
|
||||
),
|
||||
'404': Substitutions(
|
||||
title='404 - Not found',
|
||||
description='The requested resource cannot be found.'
|
||||
),
|
||||
'502': Substitutions(
|
||||
title='502 - Server error',
|
||||
description='Service is under maintenance.'
|
||||
),
|
||||
'50x': Substitutions(
|
||||
title='50x - Server error',
|
||||
description='There was a problem on our side.'
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def substitute(source: str, substitutions: Substitutions) -> str:
|
||||
for i, property_name in enumerate(Substitutions._fields):
|
||||
source = source.replace(f'{{{property_name}}}', str(substitutions[i]))
|
||||
return source
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pages_to_be_built = {k: v for k, v in error_messages.items() if k in argv[1:]}
|
||||
|
||||
with open(template_path) as f:
|
||||
template = f.read()
|
||||
|
||||
makedirs(result_path, mode=0o440, exist_ok=True)
|
||||
|
||||
for name, substitutions in pages_to_be_built.items():
|
||||
with open(path.join(result_path, f'{name}.html'), 'w') as f:
|
||||
html = substitute(template, substitutions)
|
||||
f.write(html)
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>{title}</title>
|
||||
<meta name="theme-color" content="#b7455e" />
|
||||
<meta name="viewport" content="initial-scale=1.0" />
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #b7455e;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: "Roboto", "Helvetica Neue", sans-serif;
|
||||
font-weight: 100;
|
||||
font-size: 3rem;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{description}</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
FROM registry.digitalocean.com/declared/declared-error-pages as build-error-pages
|
||||
|
||||
FROM schmelczera/error-pages as build-error-pages
|
||||
RUN python build.py 403 404 50x
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
FROM registry.digitalocean.com/declared/declared-error-pages as build-error-pages
|
||||
|
||||
FROM schmelczera/error-pages as build-error-pages
|
||||
RUN python build.py 502
|
||||
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue