Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mat/besticon
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: mediumroast/logo_server
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 5 commits
  • 4 files changed
  • 2 contributors

Commits on Jun 27, 2023

  1. Copy the full SHA
    f105a57 View commit details

Commits on Jun 29, 2023

  1. improved svc_ctl

    miha42-github committed Jun 29, 2023
    Copy the full SHA
    69ec1ac View commit details
  2. Ignored keys

    miha42-github committed Jun 29, 2023
    Copy the full SHA
    3c56503 View commit details
  3. Removed keys

    miha42-github committed Jun 29, 2023
    Copy the full SHA
    9c402b8 View commit details

Commits on Jun 30, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f9f869c View commit details
Showing with 314 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +32 −0 docker-compose.yml
  3. +55 −0 nginx.conf
  4. +226 −0 svc_ctl.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
tags
.licenses/
var/
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://docs.min.io/docs/deploy-minio-on-docker-compose.html
version: "3.7"

services:
logo-server:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:7000"
hostname: logo-server
networks:
- logo_nw

nginx:
image: nginx:latest
hostname: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./var/live/logo-server.mediumroast.io/fullchain.pem:/etc/nginx/certs/fullchain.pem:ro
- ./var/live/logo-server.mediumroast.io/privkey.pem:/etc/nginx/certs/privkey.pem:ro
ports:
- "7000:7000"
depends_on:
- logo-server
networks:
- logo_nw

networks:
logo_nw:
driver: bridge

55 changes: 55 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
}

http {
include /etc/nginx/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;
keepalive_timeout 65;

server {
listen 7000 ssl;
listen [::]:7000 ssl;
server_name logo-server.mediumroast.io;
ssl_certificate /etc/nginx/certs/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/privkey.pem;

# To allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# To disable buffering
proxy_buffering off;

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;

# proxy_connect_timeout 300;
# # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# #proxy_set_header Connection "";
# chunked_transfer_encoding off;

proxy_pass http://logo-server:8080;
}
}
}
226 changes: 226 additions & 0 deletions svc_ctl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
#!/usr/bin/env bash

# Name: svc_ctl.sh
# Purpose: Service control for the mediumroast.io
# Copyright: Copyright 2021 and 2022 mediumroast.io. All rights reserved.
# Author(s): Michael Hay, John Goodman

###################################
###
### Environment variables
###
###################################

# Service specific variables
SERVICE_NAME="logo-server.mediumroast.io"
HELLO_EMAIL="hello@mediumroast.io"
IMAGE_NAME="chart-server_chart-server"

# Colors
NC='\033[0m'
ORANGE='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;94m'
GREEN='\033[0;92m'

# Generic variables
SERVICE="mr_minio"

###################################
###
### Generic functions
###
###################################

function check_error () {
EXIT=$1
CMD=$2

if [ $EXIT -eq 0 ]; then
echo -e "${GREEN}ok${NC}"
else
echo "${RED}FAILED${NC}, ${CMD} exited with code: ${EXIT}"
exit -1
fi
}

function print_header () {
HEADER="${1}"
echo "-----[ BEGIN: ${HEADER} ]-----"
}

function print_step () {
MSG="${1}"
SEP=" ... "
echo -n -e "${ORANGE}${MSG}${NC}${SEP}"
}

function print_detail () {
DETAIL="${1}"
echo -e "${BLUE}${DETAIL}${NC}"
}

function print_footer () {
FOOTER="${1}"
echo "-----[ END: ${FOOTER} ]-----"
}


function bring_down_server () {
FUNC="Bring down service"
STEP="bring_down_server"
print_header "${FUNC}"

print_step "Bring down ${SERVICE} and nginx"
docker-compose down

print_footer $FUNC
}

function bring_up_server () {
FUNC="Bring up service"
STEP="bring_up_server"
print_header $FUNC

print_step "Build docker images"
docker-compose build

print_step "Pull docker images"
docker-compose pull

print_step "Bring up ${SERVICE}"
docker-compose up -d

print_footer $FUNC
}

function stop_server () {
FUNC="Stop ${SERVICE}"
STEP="stop_server"
print_header $FUNC

print_step "Stop ${SERVICE}"
docker-compose stop

print_footer $FUNC
}

function start_server () {
FUNC="Start ${SERVICE}"
STEP="start_server"
print_header $FUNC

print_step "Start ${SERVICE}"
docker-compose start

print_footer $FUNC
}

function build_server () {
FUNC="Building ${SERVICE}"
STEP="build_server"
print_header $FUNC

print_step "Build ${SERVICE}"
docker-compose build

print_footer $FUNC
}

function run_foreground () {
FUNC="Running ${SERVICE} in the foreground"
STEP="run_foreground"
print_header $FUNC

print_step "Running ${SERVICE}"
docker-compose up

print_footer $FUNC
}

function tail_backend () {
FUNC="Tail the backend log file"
STEP="tail_backend"
print_header $FUNC

print_step "Tailing the docker image for ${SERVICE}\n"
docker_image=`docker ps |grep ${IMAGE_NAME} |awk '{print $1}'`
echo "'${docker_image}'"
docker logs -f ${docker_image}
}

###################################
###
### Service specific functions
###
###################################


function create_cert () {
certbot --agree-tos -d ${SERVICE_NAME} -m ${HELLO_EMAIL} --manual --preferred-challenges dns certonly --config-dir=./var --work-dir=./var --logs-dir=./var --no-eff-email
}

function print_help () {
clear
echo "NAME:"
echo " $0 <command>"
echo ""
echo "DESCRIPTION:"
echo " Control functions to run ${SERVICE} to demo/develop for the mediumroast.io."
echo ""
echo "COMMANDS:"
echo " help up down start stop cert build foreground tail"
echo ""
echo " help - call up this help text"
echo " up - bring up the service including building and pulling the docker image"
echo " down - bring down the service and remove the docker image"
echo " start - start the service using docker-compose "
echo " stop - stop the docker service"
echo " cert - create a new TLS certificate which lasts for 90 days"
echo " build - build the docker images for the server"
echo " foreground - run the server in the foreground to watch for output"
echo " tail - tail the logs for a server running in the background"
echo ""
exit -1
}

###################################
###
### Main control shell logic
###
###################################


if [ ! $1 ] || [ $1 == "help" ]; then
print_help

elif [ $1 == "up" ]; then
bring_up_server

elif [ $1 == "down" ]; then
bring_down_server

elif [ $1 == "clean_slate" ]; then
clean_slate

elif [ $1 == "start" ]; then
start_server

elif [ $1 == "stop" ]; then
stop_server

elif [ $1 == "cert" ]; then
create_cert

elif [ $1 == "build" ]; then
build_server

elif [ $1 == "foreground" ]; then
run_foreground

elif [ $1 == "tail" ]; then
tail_backend

fi

exit 0