infrastructure/roles/static_websites/templates/docker-compose.yml
saibotk c9eb84f8f0
static_websites: Add "" to default boolean value on hsts labels
This will ensure consistency and a clean format of the value eg. no "False" instead of "false" etc.
2020-08-14 05:44:45 +02:00

76 lines
3.2 KiB
YAML

{{ ansible_managed | comment }}
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
version: '2'
services:
{% for key, value in static_websites.items() %}
{{ key }}:
image: "{{ value.image }}"
mem_limit: 10mb
memswap_limit: 15mb
{% if value.nginx.readonly is defined and value.nginx.readonly %}
read_only: true
tmpfs:
- /run/:size=32K
- /var/cache/nginx:size=10M
{% if value.nginx.tmpfs is defined %}
{% for tmpfs, tmpsize in value.nginx.tmpfs.items() %}
- {{ tmpfs }}:size={{ tmpsize }}
{% endfor %}
{% endif %}
{% endif %}
security_opt:
- no-new-privileges
labels:
- "traefik.http.routers.static_websites_{{ key }}.rule=Host(`{{ value.domain }}`{% if value.www is defined and value.www %},`www.{{ value.domain }}`{% endif %}) && PathPrefix(`/`)"
- "traefik.http.routers.static_websites_{{ key }}.entrypoints=websecure"
- "traefik.http.routers.static_websites_{{ key }}.tls=true"
- "traefik.http.routers.static_websites_{{ key }}.tls.certresolver={{ value.certresolver | default(static_websites_default_traefik_certresolver) }}"
- "traefik.http.routers.static_websites_{{ key }}.middlewares=static_websites_{{ key }},compress"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.sslredirect=true"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.stsSeconds=63072000"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.referrerPolicy=no-referrer"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.contentTypeNosniff=true"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.browserXssFilter=true"
- "traefik.enable=true"
{% if value.hsts is defined %}
- "traefik.http.middlewares.static_websites_{{ key }}.headers.stsPreload={{ value.hsts.preloaded | default("false") }}"
- "traefik.http.middlewares.static_websites_{{ key }}.headers.stsIncludeSubdomains={{ value.hsts.subdomains | default("false") }}"
{% endif %}
{% if proxy_hiddenservice is defined and proxy_hiddenservice.content is defined %}
- "traefik.http.middlewares.static_websites_{{ key }}.headers.customresponseheaders.alt-svc=h2={{ proxy_hiddenservice['content'] | b64decode | trim }}:443; ma=2592000"
{% endif %}
{% if proxy_network is defined %}
- "traefik.docker.network={{ proxy_network }}"
{% endif %}
restart: always
{% if proxy_network is defined %}
networks:
{{ proxy_network }}:
{% endif %}
{% endfor %}
{% if proxy_network is defined %}
networks:
{{ proxy_network }}:
external: true
{% endif %}