Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support customization through env variables #16

Closed
yajo opened this issue May 12, 2021 · 5 comments
Closed

Support customization through env variables #16

yajo opened this issue May 12, 2021 · 5 comments
Assignees
Labels
type:enhancement New feature or request

Comments

@yajo
Copy link

yajo commented May 12, 2021

It would be awesome to be able to define error pages content by env variables.

It'd be sooo nice to be able to do something like:

# docker-compose.yml
version: '3.4'

services:
  error-pages:
    image: tarampampam/error-pages:latest
    environment:
      CUSTOM_503: |
        <body>
          <div>My custom error page</div>
        </body>
@tarampampam
Copy link
Owner

What is the use case for this? Why do not use the ready templates?

@yajo
Copy link
Author

yajo commented May 13, 2021

For instance I prefer to have a more human-friendly maintenance message for 502 and 503. Also, somebody might prefer corporate templates which wouldn't fit a generic project.

@modem7
Copy link
Contributor

modem7 commented Sep 19, 2021

For instance I prefer to have a more human-friendly maintenance message for 502 and 503. Also, somebody might prefer corporate templates which wouldn't fit a generic project.

Tbf, all you'd need to do there is modify the config.json file and build the project, and you could have the custom message of your choice.

The HTML files are built during the dockerfile build stage, so not quite sure how @tarampampam would be able to put env variables in. Only way I can think of is via Nginx's http_sub_module - but that's massively processor intensive if not careful.

It makes more sense to simplify it and edit the config.json and have several images depending on your use case.

Or if you really need variables, just put in some build_args.

It takes about 20 seconds to build a new image.

@tarampampam
Copy link
Owner

@yajo Hi there again! Sorry for the late response - I needed time to rewrite the whole application on go :)

Since v2.0.0 you can override the content of the templates. For example, now you can override the ghost template content on your choice:

- path: ./templates/ghost.html
name: ghost # name is optional, if path is defined
content: ${GHOST_TEMPLATE_CONTENT}

# docker-compose.yml
version: '3.2'

services:
  error-pages:
    image: ghcr.io/tarampampam/error-pages:2.0.0
    environment:
      TEMPLATE_NAME: ghost
      GHOST_TEMPLATE_CONTENT: >
        <html>
        <body>{{ code }} - {{ message }}</body>
        </html>
    ports:
      - "8080:8080/tcp"
$ docker-compose up

111

This issue can be closed now? :)

@tarampampam tarampampam self-assigned this Sep 29, 2021
@tarampampam tarampampam added the type:enhancement New feature or request label Sep 29, 2021
@yajo
Copy link
Author

yajo commented Sep 30, 2021

Beautiful! Of course, thank you!

@yajo yajo closed this as completed Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants