docker / jenkins / nginx stuff

This commit is contained in:
Kameron Kenny 2024-05-25 13:27:21 -04:00
parent 9f23028614
commit a41fba0c6d
No known key found for this signature in database
GPG Key ID: E5006629839D2276
6 changed files with 160 additions and 1 deletions

1
CNAME
View File

@ -1 +0,0 @@
thelinux.pro

32
Dockerfile Normal file
View File

@ -0,0 +1,32 @@
FROM docker-registry1.in.thelinuxpro.net:5000/tlp/tlp_jekyll:0.0.1
LABEL version="0.0.1"
LABEL image.author.name="Kameron Kenny"
LABEL image.author.email="kameron@localhost"
LABEL description="A Jekyll site for thelinux.pro."
ARG LOCATION_JEKYLL="/usr/local/jekyll"
ENV GEM_HOME="/usr/local/gems"
ENV PATH="/usr/local/gems/bin:$PATH"
ENV SITE="thelinux.pro"
ENV NGINX_CONF_D="$LOCATION_JEKYLL/nginx"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt -y upgrade
RUN mkdir -p $LOCATION_JEKYLL/sites/$SITE
WORKDIR /usr/local/sbin
COPY ./entrypoint.sh .
WORKDIR $NGINX_CONF_D
COPY ./app/conf/nginx/nginx.conf .
WORKDIR $LOCATION_JEKYLL/sites/$SITE
COPY . .
RUN bundle install
RUN JEKYLL_ENV=production bundle exec jekyll build
ENTRYPOINT /usr/local/sbin/entrypoint.sh

47
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,47 @@
pipeline {
agent {
label 'pi501.in.thelinuxpro.net'
}
stages {
stage("verify tooling") {
steps {
sh '''
docker version
docker info
docker compose version
'''
}
}
stage("Build Containers and push to registry") {
steps {
script {
sh 'docker build -t docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.3 . --push'
}
}
}
stage("Tag image as latest") {
steps {
script {
sh 'docker tag docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.3 docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest'
}
}
}
stage("push latest tag") {
steps {
script {
sh 'docker image push docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest'
}
}
}
stage("Start web1 container") {
steps {
sh 'docker compose up -d --no-color'
}
}
}
}

48
app/conf/nginx/nginx.conf Normal file
View File

@ -0,0 +1,48 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
gzip off;
server {
listen 4000 default_server;
# listen [::]:80 default_server;
root /usr/local/jekyll/sites/kameronkenny.com/_site;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
}

13
docker-compose.yml Normal file
View File

@ -0,0 +1,13 @@
---
services:
kameronkenny_com_web1:
container_name: kameronkenny.com_web1
image: docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest
ports:
- '4000:4000'
restart: always
user: root
deploy:
placement:
constraints: [node.role == manager]

20
entrypoint.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
function start_nginx() {
/usr/sbin/nginx -p /usr/local/jekyll/nginx -c nginx.conf
}
function watchtower() {
while true; do
ps -elf | grep nginx | grep -v grep | grep nginx >/dev/null 2>&1
RC=$?
if [[ $RC != 0 ]]; then
start_nginx
fi
sleep 10
done
}
watchtower