Moving on git

master
Meliurwen 4 years ago
commit 642b111340
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 9
      .env.example
  2. 1
      .gitignore
  3. 10
      Dockerfile
  4. 19
      docker-compose.yml
  5. 34
      root/defaults/nginx.conf
  6. 25
      root/entrypoint.sh
  7. 5
      static-websites.env.example

@ -0,0 +1,9 @@
# Global Settings
LOCAL_STACK_DIR=/srv/docker/volumes/static-websites
# Networks
NETWORK=webservices
# static-websites
NG_CONTAINER_NAME=
NG_RESTART=

1
.gitignore vendored

@ -0,0 +1 @@
*.env

@ -0,0 +1,10 @@
FROM nginx:stable-alpine
LABEL maintainer="Meliurwen <meliruwen@gmail.com>"
RUN apk --no-cache add tzdata && \
mkdir -p /defaults /data /config/conf.d
COPY root/ /
ENTRYPOINT [entrypoint.sh]

@ -0,0 +1,19 @@
version: "3"
services:
static-websites:
build: .
container_name: ${NG_CONTAINER_NAME:-nginx-static-websites}
restart: ${NG_RESTART:-unless-stopped}
volumes:
- ${LOCAL_STACK_DIR}/data:/data:ro
- ${LOCAL_STACK_DIR}/config:/config:ro
env_file:
- static-websites.env
environment:
- TZ=${TZ}
networks:
default:
external:
name: ${NETWORK}

@ -0,0 +1,34 @@
user nginx;
worker_processes 4;
#include /etc/nginx/modules/*.conf;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 512;
}
http {
include /config/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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
include /config/conf.d/*.conf;
}
daemon off;

@ -0,0 +1,25 @@
#!/bin/sh
# Exit at first error
set -e
# Check if nginx configuration file exists
if [ ! -e /config/nginx.conf ]; then
echo "Configuration file nginx.conf not found. Initializing...";
cp /defaults/nginx.conf /config/nginx.conf;
fi
# Check if nginx configuration file exists
if [ ! -e /config/mime.types ]; then
echo "Configuration file mime.types not found. Initializing...";
cp /etc/nginx/mime.types /config/mime.types;
fi
# Check if conf.d directory has websites configuration files
if [ -z "$(ls -A /config/conf.d)" ]; then
echo "The /config/conf.d directory is empty. Copying default.conf...";
cp /etc/nginx/conf.d/default.conf /config/conf.d/default.conf;
fi
# Launch nginx
nginx -c /config/nginx.conf

@ -0,0 +1,5 @@
# Reverse-proxy and certbot
VIRTUAL_HOST=subdomain.domain.tld
VIRTUAL_PORT=80
LETSENCRYPT_HOST=subdomain.domain.tld
LETSENCRYPT_EMAIL=username@domain.tld
Loading…
Cancel
Save