Skip to content

Instantly share code, notes, and snippets.

View stevenuray's full-sized avatar

Steven Uray stevenuray

View GitHub Profile
@stevenuray
stevenuray / keybase.md
Created September 14, 2017 18:41
Steven Uray's Keybase Gist

Keybase proof

I hereby claim:

  • I am stevenuray on github.
  • I am surayest (https://keybase.io/surayest) on keybase.
  • I have a public key ASDk-AprMUppT3s8KSjWTXW3hlkN3aOK2pRcMxx9AXXpBwo

To claim this, I am signing this object:

@stevenuray
stevenuray / gist:5b6c4bb382f6ad9cff64785548d4f5c1
Last active July 5, 2018 17:25
File Descriptor Lock Bash Scipt Header
#!/usr/bin/env bash
#This is called so that container startup is interrupted if npm install fails with a nonzero status code.
set -euo pipefail
@stevenuray
stevenuray / lock-script.sh
Created July 5, 2018 21:10
Dockerlith Lock Script Variables
#Script variables here
readonly NPM_DIR=/app/src/node_modules
readonly LOCK_FILE=$NPM_DIR/.npm_lock
readonly LOCK_FD=200
readonly MD5_FILE=$NPM_DIR/.package_md5
@stevenuray
stevenuray / lock-script.sh
Created July 5, 2018 21:13
Dockerlith Lock Script Lock Function
lock() {
# Create lock file.
eval "exec $2>$1"
# Get exclusive, waiting lock on the file descriptor of the lock file.
flock --exclusive $2
}
@stevenuray
stevenuray / lock-script.sh
Created July 5, 2018 21:14
Dockerlith Lock Script Unlock Function
unlock() {
flock --unlock $1
}
@stevenuray
stevenuray / lock-script.sh
Created July 5, 2018 21:16
Dockerlith Lock Script Dependency Update Check
check_npm_libraries() {
if [ ! -f $MD5_FILE ] || ! md5sum -c --status <<<"$(cat $MD5_FILE)"; then
echo "INVALID"
else
echo "VALID"
fi
}
@stevenuray
stevenuray / lock-script.sh
Last active July 5, 2018 22:13
Dockerlith Lock Script MD5 Sum Persistence Function
install_npm_libraries() {
npm install grunt
echo "Installing npm Libraries..."
npm install --loglevel info
write_md5_sum_to_md5_file
}
@stevenuray
stevenuray / lock-script.sh
Created July 5, 2018 21:22
Dockerlith Lock Script Prepare NPM Volume Function
prepare_npm_volume() {
#Try to get node_modules lock.
lock $LOCK_FILE $LOCK_FD
#Check status of npm libraries now that this container has the lock.
echo "This container has the lock on the npm libraries."
npm_library_status=$(check_npm_libraries)
if [ "$npm_library_status" == "INVALID" ]; then
install_npm_libraries
@stevenuray
stevenuray / monolith_development_container_entrypoint
Last active July 11, 2018 17:19
Dockerlith Application Container Entrypoint Script for Synchronizing Access to Shared NPM Dependencies
#!/usr/bin/env bash
# Application containers should not continue starting
# if their dependencies are unverified,
# so if any command in this script fails the container
# will stop it’s initialization process and
# an error message will be presented to the user.
set -euo pipefail
# Set variables here
# The resource to have synchronized write access is the node_modules directory.