From e28b7c8ed9a6e51a875aa5e476633d957e258cd5 Mon Sep 17 00:00:00 2001 From: AngeD Date: Mon, 18 Sep 2023 10:08:05 +0200 Subject: [PATCH] feat: _template --- _template/.env | 5 +++++ _template/Dockerfile | 21 +++++++++++++++++++++ _template/compose.yaml | 37 +++++++++++++++++++++++++++++++++++++ _template/entrypoint.sh | 13 +++++++++++++ _template/install_site | 1 + _template/nginx.conf | 23 +++++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 _template/.env create mode 100644 _template/Dockerfile create mode 100644 _template/compose.yaml create mode 100755 _template/entrypoint.sh create mode 120000 _template/install_site create mode 100644 _template/nginx.conf diff --git a/_template/.env b/_template/.env new file mode 100644 index 0000000..309ac82 --- /dev/null +++ b/_template/.env @@ -0,0 +1,5 @@ +BASE_URL=subdomain. +EMAIL= + +PUID=1000 +PGID=1000 diff --git a/_template/Dockerfile b/_template/Dockerfile new file mode 100644 index 0000000..4b16af5 --- /dev/null +++ b/_template/Dockerfile @@ -0,0 +1,21 @@ +FROM docker.io/debian:12-slim as base +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /app/ + +FROM base as build +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + && rm -rf /var/lib/apt/lists/* +ARG APP="http://app.com/download" +RUN curl -L "$APP" | tar xz --strip-components=1 + +FROM base +COPY --from=build /app/ . +COPY entrypoint.sh /usr/local/bin/ +RUN useradd -m app +VOLUME /config/ +EXPOSE 80 +ENTRYPOINT ["entrypoint.sh"] +CMD ["./app"] diff --git a/_template/compose.yaml b/_template/compose.yaml new file mode 100644 index 0000000..5d7b222 --- /dev/null +++ b/_template/compose.yaml @@ -0,0 +1,37 @@ +--- +services: + install_site: + build: install_site + environment: + - BASE_URL + - EMAIL + volumes: + - ./nginx.conf:/web/app.conf + - sites:/sites/ + - certs:/etc/letsencrypt/ + - certbotroot:/var/www/certbot/ + - /var/run/docker.sock:/var/run/docker.sock + + app: + build: . + restart: unless-stopped + environment: + - PUID + - PGID + volumes: + - config:/config/ + networks: + - nginx + +volumes: + sites: + external: true + certs: + external: true + certbotroot: + external: true + config: + +networks: + nginx: + external: true diff --git a/_template/entrypoint.sh b/_template/entrypoint.sh new file mode 100755 index 0000000..f296830 --- /dev/null +++ b/_template/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ -n "$PGID" ]; then + groupmod -g "$PGID" app +fi + +if [ -n "$PUID" ]; then + usermod -u "$PUID" app +fi + +chown -R app:app /config/ + +exec su app -c "$*" diff --git a/_template/install_site b/_template/install_site new file mode 120000 index 0000000..846f55c --- /dev/null +++ b/_template/install_site @@ -0,0 +1 @@ +../_nginx/install_site \ No newline at end of file diff --git a/_template/nginx.conf b/_template/nginx.conf new file mode 100644 index 0000000..877ce1f --- /dev/null +++ b/_template/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + listen [::]:80; + server_name $BASE_URL; + + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name $BASE_URL; + + ssl_certificate /etc/letsencrypt/live/$BASE_URL/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/$BASE_URL/privkey.pem; + + location / { + proxy_pass http://app; + + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + } +}