This commit is contained in:
Lorenzo Carbonell 2022-11-14 19:54:55 +01:00
parent b8b3eddd00
commit 33b3a9e68e
14 changed files with 355 additions and 0 deletions

1
dasherr/Dasherr Submodule

@ -0,0 +1 @@
Subproject commit 234624c5656d4ff2570d474310455507784e3a3b

47
dasherr/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
FROM alpine:3.16 AS builder
RUN apk add --update \
--no-cache \
pcre~=8.45 \
libxml2~=2.9 \
libxslt~=1.1 \
gcc~=11.2 \
make~=4.3 \
libc-dev~=0.7 \
pcre-dev~=8.45 \
zlib-dev~=1.2 \
libxml2-dev~=2.9 \
libxslt-dev~=1.1 && \
cd /tmp && \
wget -q https://github.com/nginx/nginx/archive/master.zip -O nginx.zip && \
unzip nginx.zip && \
cd nginx-master && \
./auto/configure --prefix=/opt/nginx && \
make && \
make install && \
apk del gcc make libc-dev pcre-dev zlib-dev libxml2-dev libxslt-dev && \
rm -rf /var/cache/apk
FROM alpine:3.16
RUN apk add --update \
--no-cache \
pcre~=8.45 \
libxml2~=2.9 \
libxslt~=1.1 \
apache2-utils~=2.4 \
su-exec~=0.2 \
tzdata~=2022 &&\
rm -rf /var/cache/apk && \
mkdir /html
COPY --from=builder /opt /opt
COPY nginx.conf /opt/nginx/conf/nginx.conf
COPY Dasherr/www/ html/
COPY entrypoint.sh /
EXPOSE 8080
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
CMD ["/opt/nginx/sbin/nginx", "-g", "daemon off;"]

21
dasherr/LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Alexander Gorokhov
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.

22
dasherr/README.md Normal file
View File

@ -0,0 +1,22 @@
# Installation
```
git clone https://github.com/atareao/self-hosted.git
cd self-hosted/nginx
touch htpasswd
docker run --init -it -v "${PWD}/htpasswd:/opt/nginx/conf/.htpasswd" --rm --name dasherr atareao/dasherr htpasswd -c /opt/nginx/conf/.htpasswd tuusuario
```
If you want to work with Traefik,
```
docker-compose -f docker-compose.yml -f docker-compose.traefik.yml up -d
docker-compose logs -f
```
If you want to work with Caddy,
```
docker-compose -f docker-compose.yml -f docker-compose.caddy.yml up -d
docker-compose logs -f
```

View File

@ -0,0 +1,13 @@
version: '3'
services:
dasherr:
networks:
- proxy
labels:
- caddy="${FQDN}"
- caddy.reverse_proxy="{{upstreams 8080}}"
networks:
proxy:
external: true

View File

@ -0,0 +1,20 @@
version: '3.7'
services:
dasherr:
networks:
- proxy
labels:
- traefik.enable=true
- traefik.http.services.dasherr.loadbalancer.server.port=8080
- traefik.http.routers.dasherr.entrypoints=web
- traefik.http.routers.dasherr.rule=Host(`${FQDN}`)
- traefik.http.middlewares.dasherr-https-redirect.redirectscheme.scheme=websecure
- traefik.http.routers.dasherr.middlewares=dasherr-https-redirect
- traefik.http.routers.dasherr-secure.entrypoints=websecure
- traefik.http.routers.dasherr-secure.rule=Host(`${FQDN}`)
- traefik.http.routers.dasherr-secure.tls=true
- traefik.http.routers.dasherr-secure.tls.certresolver=letsencrypt
networks:
proxy:
external: true

View File

@ -0,0 +1,9 @@
version: '3.7'
services:
dasherr:
image: atareao/dasherr
container_name: dasherr
init: true
restart: unless-stopped
volumes:
- ./htpasswd:/opt/nginx/conf/.htpasswd

51
dasherr/entrypoint.sh Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Lorenzo Carbonell <a.k.a. atareao>
# 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.
# Exit if any command fails
set -o errexit
set -o pipefail
set -o nounset
LOCAL_USER_ID=${LOCAL_USER_ID:-1000}
LOCAL_GROUP_ID=${LOCAL_GROUP_ID:-1000}
if ! grep -q -E "^dockerus:" /etc/group;
then
echo "=== Create group ==="
addgroup -g "$LOCAL_GROUP_ID" -S dockerus
fi
if ! grep -q -E "^dockerus:" /etc/passwd;
then
echo "=== Create user ==="
adduser -u "$LOCAL_USER_ID" -S dockerus -G dockerus
fi
echo "=== Chown ownership ==="
# comment next line if needs root
chown -R dockerus:dockerus /opt
chown -R dockerus:dockerus /html
chmod o+w /dev/stdout
echo "=== Execute $* ==="
# comment next line if needs root
#set -- su-exec dockerus "$@"
exec "$@"

View File

35
dasherr/html/index.html Normal file
View File

@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Basic HTML5 Template</title>
<meta name="description" content="A simple HTML5 Template for new projects.">
<meta name="author" content="SitePoint">
<meta property="og:title" content="A Basic HTML5 Template">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.sitepoint.com/a-basic-html5-template/">
<meta property="og:description" content="A simple HTML5 Template for new projects.">
<meta property="og:image" content="image.png">
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<script src="js/script.js"></script>
</head>
<body>
<!-- your content here... -->
<h1>Hola mundo</h1>
<p>Bienvenido al maravilloso mundo de los contenedores</p>
<!-- your content here... -->
<script src="js/scripts.js"></script>
</body>
</html>

0
dasherr/html/js/.gitkeep Normal file
View File

11
dasherr/html/js/script.js Normal file
View File

@ -0,0 +1,11 @@
const ready = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}
ready(() => {
});
function init(){
}

124
dasherr/nginx.conf Normal file
View File

@ -0,0 +1,124 @@
user dockerus dockerus;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stdout info;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /html;
index index.html index.htm;
include mime.types;
try_files $uri $uri/ =404;
auth_basic "Administrator's Area";
auth_basic_user_file /opt/nginx/conf/.htpasswd;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}

1
dasherr/sample.env Normal file
View File

@ -0,0 +1 @@
FQDN=nginx.tuservidor.es