Skip to content

Commit

Permalink
Dockerfile and config files in docker directory added | Docker runs s…
Browse files Browse the repository at this point in the history
…uccessful build
  • Loading branch information
bsesic committed Jun 14, 2023
1 parent d816919 commit 9f23887
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:latest

LABEL maintainer="JudaicaLink | Benjamin Schnabel <[email protected]>"

RUN apt-get -y update && apt-get -y upgrade && apt-get install -y \
python3 \
python3-pip \
python3-venv \
git \
hugo \
rsync \
nginx

RUN mkdir /data
RUN mkdir /data/judaicalink
RUN mkdir /data/judaicalink/web.judaicalink.org/
RUN mkdir /data/judaicalink/web.judaicalink.org/judaicalink-site

WORKDIR /data/

ADD docker/installer.sh ./
COPY docker/site/* /data/judaicalink/web.judaicalink.org/

# NGINX
COPY docker/nginx/* /etc/nginx/
COPY docker/nginx/sites-available/* /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/judaicalink.conf /etc/nginx/sites-enabled/judaicalink
RUN rm /etc/nginx/sites-enabled/default

WORKDIR /data/judaicalink/web.judaicalink.org/judaicalink-site
COPY . .

ENV PORT_NGINX=80
ENV PORT_SSL=443

EXPOSE ${PORT_NGINX}
EXPOSE ${PORT_SSL}

CMD [ "nginx", "-g", "daemon off;" ]

RUN bash -c "docker/installer.sh"
89 changes: 89 additions & 0 deletions docker/installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

colorred="\033[31m"
colorpowder_blue="\033[1;36m" #with bold
colorblue="\033[34m"
colornormal="\033[0m"
colorwhite="\033[97m"
colorlightgrey="\033[90m"

printf " ${colorred} ## ${colorlightgrey} . \n"
printf " ${colorred} ## ## ## ${colorlightgrey} == \n"
printf " ${colorred}## ## ## ## ${colorlightgrey}=== \n"
printf " /\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\\\___/ === \n"
printf " ${colorblue}~~~ ${colorlightgrey}{${colorblue}~~ ~~~~ ~~~ ~~~~ ~~ ~ ${colorlightgrey}/ ===- ${colorblue}~~~${colorlightgrey}\n"
printf " \\\______${colorwhite} o ${colorlightgrey} __/ \n"
printf " \\\ \\\ __/ \n"
printf " \\\____\\\______/ \n"
printf "${colorpowder_blue} \n"
printf " | | \n"
printf " __ | __ __ | _ __ _ \n"
printf " / \\\| / \\\ / |/ / _\\\ | \n"
printf " \\\__/| \\\__/ \\\__ |\\\_ \\\__ | \n"
printf " ${colornormal} \n"

echo -e "\033[0;34m" "
.(###(.
.(#####/
/##(##,
.#(. .#(.
.####(. *#, /#, (###/.
/########################################(
.*/##. *#,/###########,/#, .###/.
,#/ .#(.##############(.#(. (#.
.(#/#,/#################,/#*#(
.##/,###################.(#(
*#* (#,################(,#( /#.
.##. ,#//#############,/#. .#(
.#####. .(#./#########/.#( .####,
##########################################,
./(*. .(#. .#( *##/.
,#/ /#,
,#####.
(#####*
.(#/. "

printf " ${colornormal} \n"

echo "Welcome to JudaicaLink's download generator script!"
echo "(c) 2022 JudaicaLink"
echo "Benjamin Schnabel <[email protected]>"
echo "----------------------------------------"
echo "creating directories..."

alias python='/usr/bin/python3'

cd /data/judaicalink/web.judaicalink.org/ || exit
chmod +x ./update.sh
chmod +x ./rebuild.sh
echo "done."

#echo "----------------------------------------"
#echo "downloading Judaicalink site..."
#cd /data/judaicalink/web.judaicalink.org/judaicalink-site/ || exit
#git clone https://github.com/judaicalink/judaicalink-site.git
#latesttag=$(git describe --tags)
#echo checking out ${latesttag}
#git checkout ${latesttag}
#echo "done." #

echo "----------------------------------------"
echo "updating and building..."
cd /data/judaicalink/web.judaicalink.org/ || exit
./update.sh
./rebuild.sh
echo "done."

# TODO: add requirements

python3 -m venv venv
source venv/bin/activate

cd /data/judaicalink/web.judaicalink.org/judaicalink-site/ || exit

pip3 install -r requirements.txt
# Generate statistics
python3 statistics.py

# Generate beacon file
python3 generate_beacon.py
37 changes: 37 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by nginxconfig.io
# https://www.serverion.com/nginx-config/#?0.domain=localhost&0.document_root=%2Fdata%2Fjudaicalink%2Fweb.judaicalink.org%2Fhtdocs&0.https=false&0.php=false&0.django&0.index=index.html&0.fallback_html&0.access_log_domain&0.error_log_domain

user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;
include /etc/nginx/modules-enabled/*.conf;

events {
multi_accept on;
worker_connections 65535;
}

http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M;
keepalive_timeout 65;

# MIME
include mime.types;
default_type application/octet-stream;

# logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;

# load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
27 changes: 27 additions & 0 deletions docker/nginx/sites-available/judaicalink.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server {
listen 80;
listen [::]:80;

server_name judaicalink;
root /data/judaicalink/web.judaicalink.org/htdocs;

# logging
access_log /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/localhost.error.log warn;

# index.html fallback
location / {
try_files $uri $uri/ /index.html;
}

}

# subdomains redirect
server {
listen 80;
listen [::]:80;

server_name *.localhost;

return 301 http://localhost$request_uri;
}
11 changes: 11 additions & 0 deletions docker/site/rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
BASEDIR=/data/judaicalink/web.judaicalink.org
HTDOCS=$BASEDIR/htdocs
WORKDIR=$BASEDIR/judaicalink-site
BRANCH=master

pushd $WORKDIR
git fetch origin $BRANCH
git merge origin/$BRANCH
hugo --cleanDestinationDir && rsync -avz --delete public/ $HTDOCS
popd
18 changes: 18 additions & 0 deletions docker/site/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
BASEDIR=/data/judaicalink/web.judaicalink.org
HTDOCS=$BASEDIR/htdocs
WORKDIR=$BASEDIR/judaicalink-site
BRANCH=master

pushd $WORKDIR
git fetch origin $BRANCH
CHANGES=`git status -s -b -uno`
if [ "$CHANGES" != "## $BRANCH...origin/$BRANCH" ]; then
echo "Found updates, rebuilding site."
git merge origin/$BRANCH
hugo --cleanDestinationDir && rsync -avz --delete public/ $HTDOCS
#/data/judaicalink/loader.sh
else
echo "No changes, exiting"
fi
popd

0 comments on commit 9f23887

Please sign in to comment.